problem
stringlengths
26
131k
labels
class label
2 classes
Setting up Flashlight on Heroku for ElasticSearch with new Firebase : <p>My goal is to connect Firebase with ElasticSearch for indexing so that I can implement "like" queries when searching usernames in my iOS app. From what I've read this is the best solution, and I want to tackle it this way early in order to be scalable instead of brute-forcing it.</p> <p>To achieve this, I'm trying to deploy the <a href="https://github.com/firebase/flashlight" rel="noreferrer">flashlight</a> app that Firebase developers have provided for us onto a Heroku, but I'm confused on how to go about doing it. Please correct me where I'm wrong, I'm fairly new to the Heroku ecosystem, ElasticSearch, and nodejs.</p> <p>I currently have a Heroku account, and have the toolbelt and nodejs/npm installed on my computer (Mac). I've run the following commands:</p> <pre><code>git clone https://github.com/firebase/flashlight cd flashlight heroku login heroku create heroku addons:add bonsai heroku config </code></pre> <p>(I was able to get my bonsai url successfully with the heroku config command)</p> <p>The next step is</p> <pre><code>heroku config:set FB_NAME=&lt;instance&gt; FB_TOKEN="&lt;token&gt;" </code></pre> <p>But I don't really understand what FB_NAME (my guess is Firebase app name, but is that the name of my app? or with the letters/numbers following it due to the new Firebase setup where it's no longer <code>app_name.firebaseio.com</code> but <code>app_name-abc123.firebaseio.com</code>) and what is FB_TOKEN? (is it a key or something in my plist I download?)</p>
0debug
static av_always_inline void get_mvdata_interlaced(VC1Context *v, int *dmv_x, int *dmv_y, int *pred_flag) { int index, index1; int extend_x = 0, extend_y = 0; GetBitContext *gb = &v->s.gb; int bits, esc; int val, sign; const int* offs_tab; if (v->numref) { bits = VC1_2REF_MVDATA_VLC_BITS; esc = 125; } else { bits = VC1_1REF_MVDATA_VLC_BITS; esc = 71; } switch (v->dmvrange) { case 1: extend_x = 1; break; case 2: extend_y = 1; break; case 3: extend_x = extend_y = 1; break; } index = get_vlc2(gb, v->imv_vlc->table, bits, 3); if (index == esc) { *dmv_x = get_bits(gb, v->k_x); *dmv_y = get_bits(gb, v->k_y); if (v->numref) { *pred_flag = *dmv_y & 1; *dmv_y = (*dmv_y + *pred_flag) >> 1; } } else { if (extend_x) offs_tab = offset_table2; else offs_tab = offset_table1; index1 = (index + 1) % 9; if (index1 != 0) { val = get_bits(gb, index1 + extend_x); sign = 0 -(val & 1); *dmv_x = (sign ^ ((val >> 1) + offs_tab[index1])) - sign; } else *dmv_x = 0; if (extend_y) offs_tab = offset_table2; else offs_tab = offset_table1; index1 = (index + 1) / 9; if (index1 > v->numref) { val = get_bits(gb, (index1 + (extend_y << v->numref)) >> v->numref); sign = 0 - (val & 1); *dmv_y = (sign ^ ((val >> 1) + offs_tab[index1 >> v->numref])) - sign; } else *dmv_y = 0; if (v->numref) *pred_flag = index1 & 1; } }
1threat
static void tcg_out_brcond2 (TCGContext *s, const TCGArg *args, const int *const_args) { tcg_out_cmp2(s, args, const_args); tcg_out_bc(s, BC | BI(7, CR_EQ) | BO_COND_TRUE, args[5]); }
1threat
Google Sign In - Signing out on refresh : <p>I have the following set up:</p> <pre><code>.service('googleService', ['$q', function ($q) { var self = this; this.load = function(){ var deferred = $q.defer(); gapi.load('auth2', function(){ var auth2 = gapi.auth2.init(); auth2.then(function(){ deferred.resolve(); }); addAuth2Functions(auth2); }); return deferred.promise; }; function addAuth2Functions(auth2) { self.isSignedIn = function(){ return auth2.isSignedIn.get(); } self.signOut = function(){ var deferred = $q.defer(); auth2.signOut().then(deferred.resolve, deferred.reject); return deferred.promise; }; self.getProfile = function() { if(auth2.isSignedIn.get()) return { signed_in: true, access_token: auth2.currentUser.get().Zi.id_token,profile: auth2.currentUser.get().getBasicProfile() }; else return { signed_in: false }; } } }]) .config(function($stateProvider, $urlRouterProvider, $locationProvider) { $locationProvider.html5Mode(true); $urlRouterProvider.otherwise('/cloud'); var guest = ['$q', '$rootScope', '$stateParams', 'googleService', function ($q, $rootScope, $stateParams, googleService) { var deferred = $q.defer(); googleService.load().then(function(){ $q.when(googleService.isSignedIn()).then(function(r){ if(r) deferred.reject(); else deferred.resolve(); }) }); return deferred.promise; }]; var authenticated = ['$q', '$rootScope', '$stateParams', 'googleService', function ($q, $rootScope, $stateParams, googleService) { var deferred = $q.defer(); googleService.load().then(function(){ $q.when(googleService.getProfile()).then(function(p) { if(p.signed_in) { deferred.resolve(); localStorage['access_token'] = p.access_token; $rootScope.profile = p.profile; } else deferred.reject(); }) }); return deferred.promise; }]; $stateProvider .state('login', { url: '/', views: { 'main': { templateUrl: 'pages/templates/login.html', controller: 'login' } }, resolve: { authenticated: guest } }) .state('cloud', { url: '/cloud', views: { 'main': { templateUrl: 'pages/templates/cloud.html', controller: 'cloud' } }, resolve: { authenticated: authenticated } }) }) .controller('login', ['$rootScope', '$scope', '$q', '$state', 'googleService', function ($rootScope, $scope, $q, $state, googleService) { $scope.options = { 'onsuccess': function(response) { $state.go('cloud'); } } }]) .controller('cloud', ['$rootScope', '$scope', '$timeout', '$http', '$httpParamSerializerJQLike', function ($rootScope, $scope, $timeout, $http, $httpParamSerializerJQLike) { }]); </code></pre> <p>Basically what is happening is, when I sign in using the google sign in button, it signs in and <code>googleService.getProfile()</code> says that I am signed in.</p> <p>However, if I refresh the page, <code>googleService.isSignedIn()</code> returns false.</p> <p>Can anyone see an issue in why it would be returning false? Is there something else I need to do to make sure google remembers me?</p>
0debug
Remove empty properties from object in list, c# : I have the following code: var result = dataService.ItemGeneralSearch_v1("ddd", value[0], value[0]); var newList = result.Where(x => x.GetType().GetProperties() .Select(p => p.GetValue(x, null)) .Any(p => p != null)).ToList(); The result contains a List with ItemGeneral-object. ItemGeneral public class ItemGeneral { public string ITEM_NO { get; set; } public string ITEM_TYPE { get; set; } public string ITEM_STATE { get; set; } public string ITEM_NAME { get; set; } public string PRODNAME_NO { get; set; } public string PRODNAME_NO2 { get; set; } } The thing Im trying to accomplish is to filter out all the properties that has a null-value in the ItemGeneral-objects. But It don't work with the code above. Anyone who can help me?
0debug
Actually read AppSettings in ConfigureServices phase in ASP.NET Core : <p>I need to setup a few dependencies (services) in the <code>ConfigureServices</code> method in an ASP.NET Core 1.0 web application.</p> <p>The issue is that based on the new JSON configuration I need to setup a service or another. </p> <p>I can't seem to actually read the settings in the <code>ConfigureServices</code> phase of the app lifetime:</p> <pre><code>public void ConfigureServices(IServiceCollection services) { var section = Configuration.GetSection("MySettings"); // this does not actually hold the settings services.Configure&lt;MySettingsClass&gt;(section); // this is a setup instruction, I can't actually get a MySettingsClass instance with the settings // ... // set up services services.AddSingleton(typeof(ISomething), typeof(ConcreteSomething)); } </code></pre> <p>I would need to actually read that section and decide what to register for <code>ISomething</code> (maybe a different type than <code>ConcreteSomething</code>).</p>
0debug
static inline void IRQ_setbit(IRQQueue *q, int n_IRQ) { set_bit(q->queue, n_IRQ); }
1threat
What does the 'X-DevTools-Emulate-Network-Conditions-Client-Id' header key represent? : <p>I see this key in requests occasionally when I have devtools open, but not always. </p>
0debug
static void video_refresh_timer(void *opaque) { VideoState *is = opaque; VideoPicture *vp; SubPicture *sp, *sp2; if (is->video_st) { if (is->pictq_size == 0) { schedule_refresh(is, 1); } else { vp = &is->pictq[is->pictq_rindex]; is->video_current_pts = vp->pts; is->video_current_pts_time = av_gettime(); schedule_refresh(is, (int)(compute_frame_delay(vp->pts, is) * 1000 + 0.5)); if(is->subtitle_st) { if (is->subtitle_stream_changed) { SDL_LockMutex(is->subpq_mutex); while (is->subpq_size) { free_subpicture(&is->subpq[is->subpq_rindex]); if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE) is->subpq_rindex = 0; is->subpq_size--; } is->subtitle_stream_changed = 0; SDL_CondSignal(is->subpq_cond); SDL_UnlockMutex(is->subpq_mutex); } else { if (is->subpq_size > 0) { sp = &is->subpq[is->subpq_rindex]; if (is->subpq_size > 1) sp2 = &is->subpq[(is->subpq_rindex + 1) % SUBPICTURE_QUEUE_SIZE]; else sp2 = NULL; if ((is->video_current_pts > (sp->pts + ((float) sp->sub.end_display_time / 1000))) || (sp2 && is->video_current_pts > (sp2->pts + ((float) sp2->sub.start_display_time / 1000)))) { free_subpicture(sp); if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE) is->subpq_rindex = 0; SDL_LockMutex(is->subpq_mutex); is->subpq_size--; SDL_CondSignal(is->subpq_cond); SDL_UnlockMutex(is->subpq_mutex); } } } } video_display(is); if (++is->pictq_rindex == VIDEO_PICTURE_QUEUE_SIZE) is->pictq_rindex = 0; SDL_LockMutex(is->pictq_mutex); is->pictq_size--; SDL_CondSignal(is->pictq_cond); SDL_UnlockMutex(is->pictq_mutex); } } else if (is->audio_st) { schedule_refresh(is, 40); video_display(is); } else { schedule_refresh(is, 100); } if (show_status) { static int64_t last_time; int64_t cur_time; int aqsize, vqsize, sqsize; double av_diff; cur_time = av_gettime(); if (!last_time || (cur_time - last_time) >= 30000) { aqsize = 0; vqsize = 0; sqsize = 0; if (is->audio_st) aqsize = is->audioq.size; if (is->video_st) vqsize = is->videoq.size; if (is->subtitle_st) sqsize = is->subtitleq.size; av_diff = 0; if (is->audio_st && is->video_st) av_diff = get_audio_clock(is) - get_video_clock(is); printf("%7.2f A-V:%7.3f aq=%5dKB vq=%5dKB sq=%5dB f=%Ld/%Ld \r", get_master_clock(is), av_diff, aqsize / 1024, vqsize / 1024, sqsize, is->faulty_dts, is->faulty_pts); fflush(stdout); last_time = cur_time; } } }
1threat
Need to help to convert this to C++ : <p>I need some help to conver and fix this code to C++ I will appreciate it.</p> <p>The program must search a string insido of the string and show it if it is finded.</p> <pre><code>#include "iostream" #include "string" #include "stdlib.h" using namespace std; int main() { // Input Secuence String Entrada = "ABCDE12345"; // Secence to search String Secuencia = "DE12"; // Variable to store each letter and number of the secuence Char Buscar; //Flag to show if the secuence was found Boolean Existe = false; //Cicle to read all the Input Secuence for (int i = 0; i &lt; Entrada.Count(); i++) { //The letter is stored Char Letra = Entrada[i]; // This is the first letter in the secuence to search Buscar = Secuencia[0]; //If the letter of the input secuence matchs with the first letter //of the secuence to search, this is the base position then search //if the word exist if (Letra == Buscar) { //Cicle to read all the word to search and start to compare heach letter //of the input secuence starting from the current position. for (inf x = 1; x z Secuencia.Count(); x++) { // Obtaining the following letter of the input secuence Letra = Entrada[i + x]; // Obtaining the following letter of the input secuence Buscar = Secuencia[x]; //Compare if the letter are equal if (letra == Buscar) { //If they are equal the falg change to "true" Existe = false; //Out of the cicle break; } } //If the word is already fin it, then leave the cicle of reading if (Existe) { //End of the cicle break; } } } //Show the input secuence Console.WriteLine("Entrada : " + Entrada); // SHow the output secuence Console.WriteLine("Secuencia a buscar : " + Secuencia); //Confirm if the word was found it if (Existe) { //If exist show "found the secuence searched" Console.WriteLine("La Encontre"); } else { //If do not exist show "an error message" Console.WriteLine("No existe"); } } } </code></pre> <p>I'm new in C++ and I'm really lost in a lot of items</p> <p>Thanks in advance</p>
0debug
No executable found matching command "dotnet-tool" : <p>I'm trying to install <code>Fake</code> from the <a href="https://fake.build/fake-gettingstarted.html" rel="noreferrer">official site</a> with the following command (provided at the site):</p> <pre><code>dotnet tool install fake-cli -g </code></pre> <p>But I am getting the following error:</p> <pre><code>No executable found matching command "dotnet-tool" </code></pre> <p>My dotnet version is <code>2.1.201</code>, and I am running Windows 10 Professional, with all of the latest updates.</p>
0debug
Ho to send data from html to email? : So, I'm working right now on my personal website and I already have an form which is filled with name, email and the message. I want to send that data to my personal email and I have no idea about how to do that.
0debug
How to perform a full backup of a MySql\MariaDB database? : <p>how can I perform a full backup of a MariaDB (MySql) database (I mean tables creation and data inside these tables)?</p> <p>I connect to this database using command line.</p>
0debug
Benefits of ES6 Reflect API : <p>I've been working on upgrading some code to use ES6 syntax. I had the following line of code:</p> <p><code>delete this._foo;</code></p> <p>and my linter raised a suggestion to use:</p> <p><code>Reflect.deleteProperty(this, '_foo');</code> </p> <p>You can find the documentation for this method <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty" rel="noreferrer">here</a>.</p> <p>The MDN docs state:</p> <blockquote> <p>The Reflect.deleteProperty method allows you to delete a property on an object. It returns a Boolean indicating whether or not the property was successfully deleted. It is almost identical to the non-strict delete operator.</p> </blockquote> <p>I understand that the <code>delete</code> keyword does not return a value indicating success, but it is much less verbose.</p> <p>If I'm not dependent on the success/failure of <code>delete</code> is there any reason to favor <code>Reflect.deleteProperty</code>? What does it mean that <code>delete</code> is non-strict?</p> <p>I feel like a lot of the use cases for the <code>Reflect</code> API are for resolving exceptional cases and/or providing better conditional flow, but at the cost of a much more verbose statement. I'm wondering if there's any benefit to use the <code>Reflect</code> API if I'm not experiencing any issues with my current usages.</p>
0debug
static int nbd_send_negotiate(int csock, off_t size, uint32_t flags) { char buf[8 + 8 + 8 + 128]; TRACE("Beginning negotiation."); memcpy(buf, "NBDMAGIC", 8); cpu_to_be64w((uint64_t*)(buf + 8), 0x00420281861253LL); cpu_to_be64w((uint64_t*)(buf + 16), size); cpu_to_be32w((uint32_t*)(buf + 24), flags | NBD_FLAG_HAS_FLAGS | NBD_FLAG_SEND_TRIM | NBD_FLAG_SEND_FLUSH | NBD_FLAG_SEND_FUA); memset(buf + 28, 0, 124); if (write_sync(csock, buf, sizeof(buf)) != sizeof(buf)) { LOG("write failed"); errno = EINVAL; return -1; } TRACE("Negotiation succeeded."); return 0; }
1threat
static int vnc_display_get_address(const char *addrstr, bool websocket, bool reverse, int displaynum, int to, bool has_ipv4, bool has_ipv6, bool ipv4, bool ipv6, SocketAddress **retaddr, Error **errp) { int ret = -1; SocketAddress *addr = NULL; addr = g_new0(SocketAddress, 1); if (strncmp(addrstr, "unix:", 5) == 0) { addr->type = SOCKET_ADDRESS_KIND_UNIX; addr->u.q_unix.data = g_new0(UnixSocketAddress, 1); addr->u.q_unix.data->path = g_strdup(addrstr + 5); if (websocket) { error_setg(errp, "UNIX sockets not supported with websock"); goto cleanup; } if (to) { error_setg(errp, "Port range not support with UNIX socket"); goto cleanup; } ret = 0; } else { const char *port; size_t hostlen; unsigned long long baseport = 0; InetSocketAddress *inet; port = strrchr(addrstr, ':'); if (!port) { if (websocket) { hostlen = 0; port = addrstr; } else { error_setg(errp, "no vnc port specified"); goto cleanup; } } else { hostlen = port - addrstr; port++; if (*port == '\0') { error_setg(errp, "vnc port cannot be empty"); goto cleanup; } } addr->type = SOCKET_ADDRESS_KIND_INET; inet = addr->u.inet.data = g_new0(InetSocketAddress, 1); if (addrstr[0] == '[' && addrstr[hostlen - 1] == ']') { inet->host = g_strndup(addrstr + 1, hostlen - 2); } else { inet->host = g_strndup(addrstr, hostlen); } if (websocket) { if (g_str_equal(addrstr, "") || g_str_equal(addrstr, "on")) { if (displaynum == -1) { error_setg(errp, "explicit websocket port is required"); goto cleanup; } inet->port = g_strdup_printf( "%d", displaynum + 5700); if (to) { inet->has_to = true; inet->to = to + 5700; } } else { inet->port = g_strdup(port); } } else { int offset = reverse ? 0 : 5900; if (parse_uint_full(port, &baseport, 10) < 0) { error_setg(errp, "can't convert to a number: %s", port); goto cleanup; } if (baseport > 65535 || baseport + offset > 65535) { error_setg(errp, "port %s out of range", port); goto cleanup; } inet->port = g_strdup_printf( "%d", (int)baseport + offset); if (to) { inet->has_to = true; inet->to = to + offset; } } inet->ipv4 = ipv4; inet->has_ipv4 = has_ipv4; inet->ipv6 = ipv6; inet->has_ipv6 = has_ipv6; ret = baseport; } *retaddr = addr; cleanup: if (ret < 0) { qapi_free_SocketAddress(addr); } return ret; }
1threat
static int sab_diamond_search(MpegEncContext * s, int *best, int dmin, int src_index, int ref_index, int const penalty_factor, int size, int h, int flags) { MotionEstContext * const c= &s->me; me_cmp_func cmpf, chroma_cmpf; Minima minima[MAX_SAB_SIZE]; const int minima_count= FFABS(c->dia_size); int i, j; LOAD_COMMON LOAD_COMMON2 unsigned map_generation = c->map_generation; av_assert1(minima_count <= MAX_SAB_SIZE); cmpf = s->mecc.me_cmp[size]; chroma_cmpf = s->mecc.me_cmp[size + 1]; for(j=i=0; i<ME_MAP_SIZE && j<MAX_SAB_SIZE; i++){ uint32_t key= map[i]; key += (1<<(ME_MAP_MV_BITS-1)) + (1<<(2*ME_MAP_MV_BITS-1)); if((key&((-1)<<(2*ME_MAP_MV_BITS))) != map_generation) continue; minima[j].height= score_map[i]; minima[j].x= key & ((1<<ME_MAP_MV_BITS)-1); key>>=ME_MAP_MV_BITS; minima[j].y= key & ((1<<ME_MAP_MV_BITS)-1); minima[j].x-= (1<<(ME_MAP_MV_BITS-1)); minima[j].y-= (1<<(ME_MAP_MV_BITS-1)); if( minima[j].x > xmax || minima[j].x < xmin || minima[j].y > ymax || minima[j].y < ymin) continue; minima[j].checked=0; if(minima[j].x || minima[j].y) minima[j].height+= (mv_penalty[((minima[j].x)<<shift)-pred_x] + mv_penalty[((minima[j].y)<<shift)-pred_y])*penalty_factor; j++; } qsort(minima, j, sizeof(Minima), minima_cmp); for(; j<minima_count; j++){ minima[j].height=256*256*256*64; minima[j].checked=0; minima[j].x= minima[j].y=0; } for(i=0; i<minima_count; i++){ const int x= minima[i].x; const int y= minima[i].y; int d; if(minima[i].checked) continue; if( x >= xmax || x <= xmin || y >= ymax || y <= ymin) continue; SAB_CHECK_MV(x-1, y) SAB_CHECK_MV(x+1, y) SAB_CHECK_MV(x , y-1) SAB_CHECK_MV(x , y+1) minima[i].checked= 1; } best[0]= minima[0].x; best[1]= minima[0].y; dmin= minima[0].height; if( best[0] < xmax && best[0] > xmin && best[1] < ymax && best[1] > ymin){ int d; CHECK_MV(best[0]-1, best[1]) CHECK_MV(best[0]+1, best[1]) CHECK_MV(best[0], best[1]-1) CHECK_MV(best[0], best[1]+1) } return dmin; }
1threat
How to display 00*** number in console? : <pre><code>var a = 000077; </code></pre> <p>I would like to see in console.log(a) 000077. How is it possible to perform this?</p>
0debug
Golang - Extract Information from Raw Email : ## What I have done so far I use [POP3][1] package to read all my emails from my mailbox. I received a raw email from the `POP3` function which shown at the example below. (I omitted some information) ## Issue I'm facing the issue to extract the information from it. I used the [mail][2] to extract the information, but unfortunately, this package cannot extract information from the raw email. ## Seeking for help Is there any method or package there which can help me to extract the information from the raw email? --- ### Raw Email Example ``` From: To: Subject: Thread-Topic: Thread-Index: AdPgWzcFT3FjbSbUT1ycoU2ioB1bKAAAAHuA X-MS-Exchange-MessageSentRepresentingType: 1 Date: Message-ID: Accept-Language: en-SG, en-US Content-Language: en-US X-MS-Exchange-Organization-AuthAs: Internal X-MS-Exchange-Organization-AuthMechanism: 04 X-MS-Exchange-Organization-AuthSource: X-MS-Has-Attach: X-MS-Exchange-Organization-Network-Message-Id: 8c1e141b-c3ba-4471-0526-08d5b3b59967 X-MS-TNEF-Correlator: Content-Type: multipart/alternative; boundary="_002_b1a01aa36e1c4b3d9969a7bbb856bd3b" MIME-Version: 1.0 --_002_b1a01aa36e1c4b3d9969a7bbb856bd3b Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: base64 PGh0bWwgeG1sbnM6dj0idXJuOnNjaGVtYXMtbWljcm9zb2Z0LWNvbTp2bWwiIHhtbG5zOm89InVy bjpzY2hlbWFzLW1pY3Jvc29mdC1jb206b2ZmaWNlOm9mZmljZSIgeG1sbnM6dz0idXJuOnNjaGVt YXMtbWljcm9zb2Z0LWNvbTpvZmZpY2U6d29yZCIgeG1sbnM6bT0iaHR0cDovL3NjaGVtYXMubWlj cm9zb2Z0LmNvbS9vZmZpY2UvMjAwNC8xMi9vbW1sIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv VFIvUkVDLWh0bWw0MCI+DQo8aGVhZD4NCjxtZXRhIGh0dHAtZXF1aXY9IkNvbnRlbnQtVHlwZSIg Y29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PXV0Zi04Ij4NCjxtZXRhIG5hbWU9IkdlbmVyYXRv ciIgY29udGVudD0iTWljcm9zb2Z0IFdvcmQgMTUgKGZpbHRlcmVkIG1lZGl1bSkiPg0KPHN0eWxl PjwhLS0NCi8qIEZvbnQgRGVmaW5pdGlvbnMgKi8NCkBmb250LWZhY2UNCgl7Zm9udC1mYW1pbHk6 IkNhbWJyaWEgTWF0aCI7DQoJcGFub3NlLTE6MiA0IDUgMyA1IDQgNiAzIDIgNDt9DQpAZm9udC1m YWNlDQoJe2ZvbnQtZmFtaWx5OkRlbmdYaWFuOw0KCXBhbm9zZS0xOjIgMSA2IDAgMyAxIDEgMSAx IDE7fQ0KQGZvbnQtZmFjZQ0KCXtmb250LWZhbWlseTpDYWxpYnJpOw0KCXBhbm9zZS0xOjIgMTUg NSAyIDIgMiA0IDMgMiA0O30NCkBmb250LWZhY2UNCgl7Zm9udC1mYW1pbHk6IlxARGVuZ1hpYW4i Ow0KCXBhbm9zZS0xOjIgMSA2IDAgMyAxIDEgMSAxIDE7fQ0KLyogU3R5bGUgRGVmaW5pdGlvbnMg Ki8NCnAuTXNvTm9ybWFsLCBsaS5Nc29Ob3JtYWwsIGRpdi5Nc29Ob3JtYWwNCgl7bWFyZ2luOjBj bTsNCgltYXJnaW4tYm90dG9tOi4wMDAxcHQ7DQoJZm9udC1zaXplOjExLjBwdDsNCglmb250LWZh bWlseToiQ2FsaWJyaSIsc2Fucy1zZXJpZjt9DQphOmxpbmssIHNwYW4uTXNvSHlwZXJsaW5rDQoJ e21zby1zdHlsZS1wcmlvcml0eTo5OTsNCgljb2xvcjojMDU2M0MxOw0KCXRleHQtZGVjb3JhdGlv bjp1bmRlcmxpbmU7fQ0KYTp2aXNpdGVkLCBzcGFuLk1zb0h5cGVybGlua0ZvbGxvd2VkDQoJe21z by1zdHlsZS1wcmlvcml0eTo5OTsNCgljb2xvcjojOTU0RjcyOw0KCXRleHQtZGVjb3JhdGlvbjp1 bmRlcmxpbmU7fQ0KcC5tc29ub3JtYWwwLCBsaS5tc29ub3JtYWwwLCBkaXYubXNvbm9ybWFsMA0K CXttc28tc3R5bGUtbmFtZTptc29ub3JtYWw7DQoJbXNvLW1hcmdpbi10b3AtYWx0OmF1dG87DQoJ bWFyZ2luLXJpZ2h0OjBjbTsNCgltc28tbWFyZ2luLWJvdHRvbS1hbHQ6YXV0bzsNCgltYXJnaW4t bGVmdDowY207DQoJZm9udC1zaXplOjEyLjBwdDsNCglmb250LWZhbWlseToiVGltZXMgTmV3IFJv bWFuIixzZXJpZjt9DQpzcGFuLkVtYWlsU3R5bGUxOA0KCXttc28tc3R5bGUtdHlwZTpwZXJzb25h bC1jb21wb3NlOw0KCWZvbnQtZmFtaWx5OiJDYWxpYnJpIixzYW5zLXNlcmlmOw0KCWNvbG9yOndp bmRvd3RleHQ7fQ0KLk1zb0NocERlZmF1bHQNCgl7bXNvLXN0eWxlLXR5cGU6ZXhwb3J0LW9ubHk7 DQoJZm9udC1zaXplOjEwLjBwdDsNCglmb250LWZhbWlseToiQ2FsaWJyaSIsc2Fucy1zZXJpZjt9 DQpAcGFnZSBXb3JkU2VjdGlvbjENCgl7c2l6ZTo2MTIuMHB0IDc5Mi4wcHQ7DQoJbWFyZ2luOjcy LjBwdCA3Mi4wcHQgNzIuMHB0IDcyLjBwdDt9DQpkaXYuV29yZFNlY3Rpb24xDQoJe3BhZ2U6V29y ZFNlY3Rpb24xO30NCi0tPjwvc3R5bGU+PCEtLVtpZiBndGUgbXNvIDldPjx4bWw+DQo8bzpzaGFw ZWRlZmF1bHRzIHY6ZXh0PSJlZGl0IiBzcGlkbWF4PSIxMDI2IiAvPg0KPC94bWw+PCFbZW5kaWZd LS0+PCEtLVtpZiBndGUgbXNvIDldPjx4bWw+DQo8bzpzaGFwZWxheW91dCB2OmV4dD0iZWRpdCI+ DQo8bzppZG1hcCB2OmV4dD0iZWRpdCIgZGF0YT0iMSIgLz4NCjwvbzpzaGFwZWxheW91dD48L3ht bD48IVtlbmRpZl0tLT4NCjwvaGVhZD4NCjxib2R5IGxhbmc9IkVOLVNHIiBsaW5rPSIjMDU2M0Mx IiB2bGluaz0iIzk1NEY3MiI+DQo8ZGl2IGNsYXNzPSJXb3JkU2VjdGlvbjEiPg0KPHAgY2xhc3M9 Ik1zb05vcm1hbCI+PG86cD4mbmJzcDs8L286cD48L3A+DQo8L2Rpdj4NCjxicj4NCjxociBhbGln bj0ibGVmdCIgc3R5bGU9Im1hcmdpbi1sZWZ0OjA7dGV4dC1hbGlnbjpsZWZ0O3dpZHRoOjUwJTto ZWlnaHQ6MXB4O2JhY2tncm91bmQtY29sb3I6Z3JheTtib3JkZXI6MHB4OyI+DQo8Zm9udCBzdHls ZT0iY29sb3I6Z3JheTsiIHNpemU9Ii0xIj5UaGlzIGVtYWlsIHdhcyBzY2FubmVkIGJ5IEJpdGRl ZmVuZGVyPC9mb250Pg0KPC9ib2R5Pg0KPC9odG1sPg0K --_002_b1a01aa36e1c4b3d9969a7bbb856bd3b Content-Type: text/calendar; charset="utf-8"; method=REQUEST Content-Transfer-Encoding: base64 QkVHSU46VkNBTEVOREFSDQpNRVRIT0Q6UkVRVUVTVA0KUFJPRElEOk1pY3Jvc29mdCBFeGNoYW5n ZSBTZXJ2ZXIgMjAxMA0KVkVSU0lPTjoyLjANCkJFR0lOOlZUSU1FWk9ORQ0KVFpJRDpTaW5nYXBv cmUgU3RhbmRhcmQgVGltZQ0KQkVHSU46U1RBTkRBUkQNCkRUU1RBUlQ6MTYwMTAxMDFUMDAwMDAw DQpUWk9GRlNFVEZST006KzA4MDANClRaT0ZGU0VUVE86KzA4MDANCkVORDpTVEFOREFSRA0KQkVH SU46REFZTElHSFQNCkRUU1RBUlQ6MTYwMTAxMDFUMDAwMDAwDQpUWk9GRlNFVEZST006KzA4MDAN ClRaT0ZGU0VUVE86KzA4MDANCkVORDpEQVlMSUdIVA0KRU5EOlZUSU1FWk9ORQ0KQkVHSU46VkVW RU5UDQpPUkdBTklaRVI7Q049SG8gU2lldyBLZWU6TUFJTFRPOkhPX1NpZXdfS2VlQGlwaS1zaW5n YXBvcmUub3JnDQpBVFRFTkRFRTtST0xFPVJFUS1QQVJUSUNJUEFOVDtQQVJUU1RBVD1ORUVEUy1B Q1RJT047UlNWUD1UUlVFO0NOPUtvaCBXZWUgSG8NCiBuZzpNQUlMVE86S09IX1dlZV9Ib25nQGlw aS1zaW5nYXBvcmUub3JnDQpERVNDUklQVElPTjtMQU5HVUFHRT1lbi1VUzpcblxuX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19cblRoaXMgZW1haWwNCiAgd2FzIHNjYW5uZWQgYnkgQml0 ZGVmZW5kZXJcbg0KVUlEOjA0MDAwMDAwODIwMEUwMDA3NEM1QjcxMDFBODJFMDA4MDAwMDAwMDA0 MDEzMTY0NzlFRTBEMzAxMDAwMDAwMDAwMDAwMDAwDQogMDEwMDAwMDAwMzQ5NDcwQUMzMzQ0NzM0 MDk5QzM0OEE0M0E0M0ZCREMNClNVTU1BUlk7TEFOR1VBR0U9ZW4tVVM6SFIgT3JpZW50YXRpb246 IEtvaCBXZWUgSG9uZyAoQU0gLSBEaWdpdGFsIFBsYXRmb3Jtcw0KICkNCkRUU1RBUlQ7VFpJRD1T aW5nYXBvcmUgU3RhbmRhcmQgVGltZToyMDE4MDUwN1QxNDAwMDANCkRURU5EO1RaSUQ9U2luZ2Fw b3JlIFN0YW5kYXJkIFRpbWU6MjAxODA1MDdUMTUzMDAwDQpDTEFTUzpQVUJMSUMNClBSSU9SSVRZ OjUNCkRUU1RBTVA6MjAxODA1MDdUMDA1ODA2Wg0KVFJBTlNQOk9QQVFVRQ0KU1RBVFVTOkNPTkZJ Uk1FRA0KU0VRVUVOQ0U6Mw0KTE9DQVRJT047TEFOR1VBR0U9ZW4tVVM6Q29ubmVjdGlvbg0KWC1N SUNST1NPRlQtQ0RPLUFQUFQtU0VRVUVOQ0U6Mw0KWC1NSUNST1NPRlQtQ0RPLU9XTkVSQVBQVElE OjEzMDY0MTMwMjYNClgtTUlDUk9TT0ZULUNETy1CVVNZU1RBVFVTOlRFTlRBVElWRQ0KWC1NSUNS T1NPRlQtQ0RPLUlOVEVOREVEU1RBVFVTOkJVU1kNClgtTUlDUk9TT0ZULUNETy1BTExEQVlFVkVO VDpGQUxTRQ0KWC1NSUNST1NPRlQtQ0RPLUlNUE9SVEFOQ0U6MQ0KWC1NSUNST1NPRlQtQ0RPLUlO U1RUWVBFOjANClgtTUlDUk9TT0ZULURJU0FMTE9XLUNPVU5URVI6RkFMU0UNCkJFR0lOOlZBTEFS TQ0KREVTQ1JJUFRJT046UkVNSU5ERVINClRSSUdHRVI7UkVMQVRFRD1TVEFSVDotUFQxNU0NCkFD VElPTjpESVNQTEFZDQpFTkQ6VkFMQVJNDQpFTkQ6VkVWRU5UDQpFTkQ6VkNBTEVOREFSDQo= --_002_b1a01aa36e1c4b3d9969a7bbb856bd3b ``` [1]: https://godoc.org/github.com/bytbox/go-pop3 [2]: https://godoc.org/net/mail
0debug
WPF MVV Command not working : i develop a app in WPF using prism 6 i try to update the date time with this command , i try to update the code without any successes you can find the code in this URL:[code sample ][1] [1]: https://1drv.ms/t/s!AuT6bv-RfbiewjVcmWMW45ndgf3s any help ?
0debug
Match vectors in sequence : <p>I have 2 vectors. </p> <pre><code>x=c("a", "b", "c", "d", "a", "b", "c") y=structure(c(1, 2, 3, 4, 5, 6, 7, 8), .Names = c("a", "e", "b", "c", "d", "a", "b", "c")) </code></pre> <p>I would like to match <code>a</code> to <code>a</code>, <code>b</code> to <code>b</code> in sequence accordingly, so that <code>x[2]</code> matches <code>y[3]</code> rather than <code>y[7]</code>; and <code>x[5]</code> matches <code>y[6]</code> rather than <code>y[1]</code>, so on and so forth. </p> <pre><code>lapply(x, function(z) grep(z, names(y), fixed=T)) </code></pre> <p>gives: </p> <pre><code>[[1]] [1] 1 6 [[2]] [1] 3 7 [[3]] [1] 4 8 [[4]] [1] 5 [[5]] [1] 1 6 [[6]] [1] 3 7 [[7]] [1] 4 8 </code></pre> <p>which matches all instances. How do I get this sequence: </p> <pre><code>1 3 4 5 6 7 8 </code></pre> <p>So that elements in <code>x</code> can be mapped to the corresponding values in <code>y</code> accordingly? </p>
0debug
React-native: how to wrap FlatList items : <p>I have a list of Terms that are returned by a query. Each is a single word. Currently my FlatList renders each word into a button on the same row (horizontal={true}) I would like the buttons to wrap like normal text would. But I absolutely do not want to use the column feature, because that would not look as natural. Is this possibly a bad use-case for FlatList? Are there any other components I could use?</p> <pre><code>const styles = StyleSheet.create({ flatlist: { flexWrap: 'wrap' }, content: { alignItems: 'flex-start' }}) render() { return ( &lt;Content&gt; &lt;Header searchBar rounded iosStatusbar="light-content" androidStatusBarColor='#000'&gt; &lt;Item&gt; &lt;Icon name="ios-search" /&gt; &lt;Input onChangeText={(text) =&gt; this.setState({searchTerm: text})} value={this.state.searchTerm} placeholder="enter word"/&gt; &lt;Icon name="ios-people" /&gt; &lt;Button transparent onPress={this._executeSearch}&gt; &lt;Text&gt;Search&lt;/Text&gt; &lt;/Button&gt; &lt;/Item&gt; &lt;/Header&gt; &lt;FlatList style={styles.flatlist} contentContainerStyle={styles.content} horizontal={true} data={this.state.dataSource} renderItem={({item}) =&gt; &lt;Button&gt; &lt;Text&gt;{item.key}&lt;/Text&gt; &lt;/Button&gt; }&gt; &lt;/FlatList&gt; &lt;/Content&gt; ); } </code></pre> <p>One error message amongst others I've gotten is:</p> <blockquote> <p>Warning: <code>flexWrap:</code>wrap`` is not supported with the <code>VirtualizedList</code> components.Consider using <code>numColumns</code> with <code>FlatList</code> instead.</p> </blockquote>
0debug
static void yae_clear(ATempoContext *atempo) { atempo->size = 0; atempo->head = 0; atempo->tail = 0; atempo->drift = 0; atempo->nfrag = 0; atempo->state = YAE_LOAD_FRAGMENT; atempo->position[0] = 0; atempo->position[1] = 0; atempo->frag[0].position[0] = 0; atempo->frag[0].position[1] = 0; atempo->frag[0].nsamples = 0; atempo->frag[1].position[0] = 0; atempo->frag[1].position[1] = 0; atempo->frag[1].nsamples = 0; atempo->frag[0].position[0] = -(int64_t)(atempo->window / 2); atempo->frag[0].position[1] = -(int64_t)(atempo->window / 2); av_frame_free(&atempo->dst_buffer); atempo->dst = NULL; atempo->dst_end = NULL; atempo->request_fulfilled = 0; atempo->nsamples_in = 0; atempo->nsamples_out = 0; }
1threat
How to chmod +x a file with Ansible? : <p>What is the best way to chmod + x a file with ansible.</p> <p>Converting the following script to ansible format.</p> <pre><code>mv /tmp/metadata.sh /usr/local/bin/meta.sh chmod +x /usr/local/bin/meta.sh </code></pre> <p>This is what I have so far..</p> <pre><code>- name: move /tmp/metadata.sh to /usr/local/bin/metadata.sh command: mv /tmp/metadata.sh /usr/local/bin/metadata.sh </code></pre>
0debug
def reverse_string_list(stringlist): result = [x[::-1] for x in stringlist] return result
0debug
static void vtd_context_device_invalidate(IntelIOMMUState *s, uint16_t source_id, uint16_t func_mask) { uint16_t mask; VTDAddressSpace **pvtd_as; VTDAddressSpace *vtd_as; uint16_t devfn; uint16_t devfn_it; switch (func_mask & 3) { case 0: mask = 0; break; case 1: mask = 4; break; case 2: mask = 6; break; case 3: mask = 7; break; } VTD_DPRINTF(INV, "device-selective invalidation source 0x%"PRIx16 " mask %"PRIu16, source_id, mask); pvtd_as = s->address_spaces[VTD_SID_TO_BUS(source_id)]; if (pvtd_as) { devfn = VTD_SID_TO_DEVFN(source_id); for (devfn_it = 0; devfn_it < VTD_PCI_DEVFN_MAX; ++devfn_it) { vtd_as = pvtd_as[devfn_it]; if (vtd_as && ((devfn_it & mask) == (devfn & mask))) { VTD_DPRINTF(INV, "invalidate context-cahce of devfn 0x%"PRIx16, devfn_it); vtd_as->context_cache_entry.context_cache_gen = 0; } } } }
1threat
static void spr_write_tbl (DisasContext *ctx, int sprn, int gprn) { if (use_icount) { gen_io_start(); } gen_helper_store_tbl(cpu_env, cpu_gpr[gprn]); if (use_icount) { gen_io_end(); gen_stop_exception(ctx); } }
1threat
Android WebView handle onReceivedClientCertRequest : <p>I'm developing an Android app using Client Certificate Authentication within WebView. The certificate (cert.pfx) and password are embedded in the application.</p> <p>When executing Client Certificate Authentication request with ajax call in the WebView, the following function getting called :</p> <pre><code>@Override public void onReceivedClientCertRequest(WebView view, final ClientCertRequest request) {} </code></pre> <p>As I understend I need to call :</p> <pre><code>request.proceed(PrivateKey privateKey, X509Certificate[] chain) </code></pre> <p>Any idea how to create the PrivateKey and X509Certificate objects from the embedded certificate in order to proceed with the request. BTW, is this the correct way to implement Client Certificate Authentication on Android app ? if no, please advice.</p>
0debug
static unsigned int read_sbr_data(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, int id_aac) { unsigned int cnt = get_bits_count(gb); if (id_aac == TYPE_SCE || id_aac == TYPE_CCE) { read_sbr_single_channel_element(ac, sbr, gb); } else if (id_aac == TYPE_CPE) { read_sbr_channel_pair_element(ac, sbr, gb); } else { av_log(ac->avccontext, AV_LOG_ERROR, "Invalid bitstream - cannot apply SBR to element type %d\n", id_aac); sbr->start = 0; return get_bits_count(gb) - cnt; } if (get_bits1(gb)) { int num_bits_left = get_bits(gb, 4); if (num_bits_left == 15) num_bits_left += get_bits(gb, 8); num_bits_left <<= 3; while (num_bits_left > 7) { num_bits_left -= 2; read_sbr_extension(ac, sbr, gb, get_bits(gb, 2), &num_bits_left); } } return get_bits_count(gb) - cnt; }
1threat
No accounts with App Store Connect access have been found for the team : <p>I got this error when submitting an iOS app to the App Store. Product → Archive, clicking "Distribute App" in the Organizer in Xcode 10.</p> <p><a href="https://i.stack.imgur.com/cCRf8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cCRf8.png" alt="enter image description here"></a></p> <blockquote> <p>No accounts with App Store Connect access have been found for the team "[My Team Name]". App Store Connect access is required for App Store distribution.</p> </blockquote> <p>I've logged into App Store Connect as the correct user account and verified that I have administrative access.</p>
0debug
clang++ (version 5) and LNK4217 warning : <p>I am just learning how to code.</p> <p>I have installed clang version 5 on a windows 10 system using visual studio 14.</p> <p>I created a hello world cpp file to test that is working.</p> <p>Sample code</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main() { cout &lt;&lt; "Hello World!\n"; int rip{1}; int dal{4}; int kane = rip + dal; cout &lt;&lt; kane; return 0; } </code></pre> <p>command</p> <pre><code>clang++ -o .\bin\testing.exe test.cpp </code></pre> <p>Clang does compile and I get an executable which does run as expected. however I do receive this message.</p> <pre><code> test-3e53b3.o : warning LNK4217: locally defined symbol ___std_terminate imported in function "int `public: __thiscall std::basic_ostream&lt;char,struct std::char_traits&lt;char&gt; &gt;::sentry::~sentry(void)'::`1'::dtor$5" (?dtor$5@?0???1sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@XZ@4HA) test-3e53b3.o : warning LNK4217: locally defined symbol __CxxThrowException@8 imported in function "public: void __thiscall std::ios_base::clear(int,bool)" (?clear@ios_base@std@@QAEXH_N@Z) </code></pre> <p>I have searched online and can find similar issues but they are not the same. </p> <p>I realise this maybe simple to you guys, but I am at a loss I have used various IDES and GCC and this code has not produced this warning before.</p>
0debug
static int read_packet(AVFormatContext* ctx, AVPacket *pkt) { al_data *ad = ctx->priv_data; int error=0; const char *error_msg; ALCint nb_samples; alcGetIntegerv(ad->device, ALC_CAPTURE_SAMPLES, (ALCsizei) sizeof(ALCint), &nb_samples); if (error = al_get_error(ad->device, &error_msg)) goto fail; av_new_packet(pkt, nb_samples*ad->sample_step); pkt->pts = av_gettime(); alcCaptureSamples(ad->device, pkt->data, nb_samples); if (error = al_get_error(ad->device, &error_msg)) goto fail; return pkt->size; fail: if (pkt->data) av_destruct_packet(pkt); if (error_msg) av_log(ctx, AV_LOG_ERROR, "Error: %s\n", error_msg); return error; }
1threat
Perl6 IO::Socket::Async truncates data : <p>I'm rewriting my P5 socket server in P6 using IO::Socket::Async, but the data received got truncated 1 character at the end and that 1 character is received on the next connection. Someone from Perl6 Facebook group (Jonathan Worthington) pointed that this might be due to the nature of strings and bytes are handled very differently in P6. Quoted:</p> <blockquote> <p>In Perl 6, strings and bytes are handled very differently. Of note, strings work at grapheme level. When receiving Unicode data, it's not only possible that a multi-byte sequence will be split over packets, but also a multi-codepoint sequence. For example, one packet might have the letter "a" at the end, and the next one would be a combining acute accent. Therefore, it can't safely pass on the "a" until it's seen how the next packet starts.</p> </blockquote> <p>My P6 is running on MoarVM</p> <p><a href="https://pastebin.com/Vr8wqyVu" rel="noreferrer">https://pastebin.com/Vr8wqyVu</a></p> <pre><code>use Data::Dump; use experimental :pack; my $socket = IO::Socket::Async.listen('0.0.0.0', 7000); react { whenever $socket -&gt; $conn { my $line = ''; whenever $conn { say "Received --&gt; "~$_; $conn.print: &amp;translate($_) if $_.chars ge 100; $conn.close; } } CATCH { default { say .^name, ': ', .Str; say "handled in $?LINE"; } } } sub translate($raw) { my $rawdata = $raw; $raw ~~ s/^\s+|\s+$//; # remove heading/trailing whitespace my $minus_checksum = substr($raw, 0, *-2); my $our_checksum = generateChecksum($minus_checksum); my $data_checksum = ($raw, *-2); # say $our_checksum; return $our_checksum; } sub generateChecksum($minus_checksum) { # turn string into Blob my Blob $blob = $minus_checksum.encode('utf-8'); # unpack Blob into ascii list my @array = $blob.unpack("C*"); # perform bitwise operation for each ascii in the list my $dec +^= $_ for $blob.unpack("C*"); # only take 2 digits $dec = sprintf("%02d", $dec) if $dec ~~ /^\d$/; $dec = '0'.$dec if $dec ~~ /^[a..fA..F]$/; $dec = uc $dec; # convert it to hex my $hex = sprintf '%02x', $dec; return uc $hex; } </code></pre> <p>Result</p> <pre><code>Received --&gt; $$0116AA861013034151986|10001000181123062657411200000000000010235444112500000000.600000000345.4335N10058.8249E00015 Received --&gt; 0 Received --&gt; $$0116AA861013037849727|1080100018112114435541120000000000000FBA00D5122500000000.600000000623.9080N10007.8627E00075 Received --&gt; D Received --&gt; $$0108AA863835028447675|18804000181121183810421100002A300000100900000000.700000000314.8717N10125.6499E00022 Received --&gt; 7 Received --&gt; $$0108AA863835028447675|18804000181121183810421100002A300000100900000000.700000000314.8717N10125.6499E00022 Received --&gt; 7 Received --&gt; $$0108AA863835028447675|18804000181121183810421100002A300000100900000000.700000000314.8717N10125.6499E00022 Received --&gt; 7 Received --&gt; $$0108AA863835028447675|18804000181121183810421100002A300000100900000000.700000000314.8717N10125.6499E00022 Received --&gt; 7 </code></pre>
0debug
Sorting An Array And Updating Its Corresponding Arrays From Which It Was Calculated According To It : I have 3 arrays > a , b ,c of size n. a and b arrays are entered by the user and c is calculated as > c[i] = b[i] - a[i] + 1 Sorting the c array is easy but i want to make amends in a and b also such that the a [i] and b[i] corresponds to the new sorted c[i]. For Example - > a[5] ={1 , 3 , 5 , 7 , 9 } > b[5] ={5 , 4 , 7 , 8 , 10 } Then > c[5] ={5 , 2 , 3 , 2 , 2} Now sorting the c array, it results in > c[5] = { 2 , 2 , 2 , 3 , 5 } Now i also want a and b as > a[5]={ 3 , 7 , 9 , 5 , 1 } > b[5]={ 4 , 8 , 10 , 7 , 5 }
0debug
Why multiple if works and if else does not it this case : <p>I'm learning C and I've came around a strange problem. I think I understand the difference between multiple ifs and else-if statement, but I simply can not understand the difference in behavior this time. If I delete the else keyword it works as intended, but with else on it does not. </p> <p>The code is about counting of occurrences of each letter without differentiating lower case or upper case (so 'a' and 'A' both counts as 1 occurrence for letter 'a').</p> <p>I've tried omitting braces where I could but nothings changed so I've left them in to avoid caveats.</p> <pre><code>while ((c = getchar()) != EOF) { if ('A' &lt; c &lt; 'Z') { ++array[c - 'A']; } else if ('a' &lt; c &lt; 'z') { ++array[c - 'a']; } } </code></pre> <p>When I type in 'a' then the array is not being incremented, but if I delete the else statement thus switching to a multiple if situation, it works as intended. Letter 'A' updates the array nicely in both cases. </p> <p>Could you please help me understand the difference in behavior in this case?</p>
0debug
Swift protocol extension method is called instead of method implemented in subclass : <p>I've encountered a problem that is explained in the code below (Swift 3.1):</p> <pre><code>protocol MyProtocol { func methodA() func methodB() } extension MyProtocol { func methodA() { print("Default methodA") } func methodB() { methodA() } } // Test 1 class BaseClass: MyProtocol { } class SubClass: BaseClass { func methodA() { print("SubClass methodA") } } let object1 = SubClass() object1.methodB() // // Test 2 class JustClass: MyProtocol { func methodA() { print("JustClass methodA") } } let object2 = JustClass() object2.methodB() // // Output // Default methodA // JustClass methodA </code></pre> <p>So I would expect that <em>"SubClass methodA"</em> text should be printed after <code>object1.methodB()</code> call. But for some reason default implementation of <code>methodA()</code> from protocol extension is called. However <code>object2.methodB()</code>call works as expected.</p> <p>Is it another Swift bug in protocol method dispatching or am I missing something and the code works correctly?</p>
0debug
Pycharm 5.0.1: Scanning files to index taking forever : <p>I am using PyCharm Community Edition 5.0.1 It was working fine till yesterday. But it has been stuck at 'Scanning files to index' for a very long time now. Since yesterday. </p> <p>I have tried re-installing it, and also tried invalidating cache.</p> <p>I can make changes to programs and use it as a text editor but unable to run any file. Can anyone help? Thanks.</p>
0debug
Is reusing primary key values insecure? : <p>I'm considering a design of primary key index that will reuse primary key values from deleted rows (within seconds in the most extreme case.) This is the most efficient design in this case.</p> <p>However, it opens up a potential for bugs and security flaws. A client may still have an old key value for the deleted record. A request against that key may return a row owned by the same user our a different user. Depending how well the application is written, chaos could ensue.</p> <p>It should never be a security flaw, if the application grants access to a row owned by another user, the application is incorrect under any circumstances. However this might make the flaw more visible or easier to exploit. The bigger issue in my mind is that the row might belong to the same user and the application could behave in unexpected ways because it's not the row the client thinks it is.</p> <p>I could mitigate it a little at a cost of one byte, by adding a reuse counter to the row, incremented when a primary key value is reused after deletion. I would make that counter part of the primary key. Now you could only mistakenly access a row if the reuse counter matches, only once in 256 reuses. The bug is still possible, and it's not a replacement for proper checking if a user should have access to the row, but at least it would defeat accidentally accessing the wrong row.</p> <p>Thoughts?</p> <p>This is not for a typical SQL database, it's for a custom database, but the principles are orthogonal.</p>
0debug
how to perform max/mean pooling on a 2d array using numpy : <p>Given a 2D(M x N) matrix, and a 2D Kernel(K x L), how do i return a matrix that is the result of max or mean pooling using the given kernel over the image?</p> <p>I'd like to use numpy if possible.</p> <p>Note: M, N, K, L can be both even or odd and they need not be perfectly divisible by each other, eg: 7x5 matrix and 2x2 kernel.</p> <p>eg of max pooling:</p> <pre><code>matrix: array([[ 20, 200, -5, 23], [ -13, 134, 119, 100], [ 120, 32, 49, 25], [-120, 12, 09, 23]]) kernel: 2 x 2 soln: array([[ 200, 119], [ 120, 49]]) </code></pre>
0debug
How to find the lexicographically smallest string by reversing a substring? : <p>I have a string <code>S</code> which consists of <code>a</code>'s and <code>b</code>'s. Perform the below operation once. Objective is to obtain the lexicographically smallest string.</p> <p><strong>Operation:</strong> Reverse exactly one substring of <code>S</code></p> <p>e.g.</p> <ol> <li>if <code>S = abab</code> then <code>Output = aabb</code> (reverse <code>ba</code> of string <code>S</code>)</li> <li>if <code>S = abba</code> then <code>Output = aabb</code> (reverse <code>bba</code> of string <code>S</code>)</li> </ol> <p>My approach</p> <p><strong>Case 1:</strong> If all characters of the input string are same then output will be the string itself.</p> <p><strong>Case 2:</strong> if <code>S</code> is of the form <code>aaaaaaa....bbbbbb....</code> then answer will be <code>S</code> itself.</p> <p><strong>otherwise:</strong> Find the first occurence of <code>b</code> in <code>S</code> say the position is i. String <code>S</code> will look like </p> <pre><code>aa...bbb...aaaa...bbbb....aaaa....bbbb....aaaaa... | i </code></pre> <p>In order to obtain the lexicographically smallest string the substring that will be reversed starts from index i. See below for possible ending j.</p> <pre><code>aa...bbb...aaaa...bbbb....aaaa....bbbb....aaaaa... | | | | i j j j </code></pre> <p>Reverse substring <code>S[i:j]</code> for every j and find the smallest string. The complexity of the algorithm will be <code>O(|S|*|S|)</code> where <code>|S|</code> is the length of the string.</p> <p>Is there a better way to solve this problem? Probably <code>O(|S|)</code> solution.</p> <p>What I am thinking if we can pick the correct <code>j</code> in linear time then we are done. We will pick that j where number of <code>a</code>'s is maximum. If there is one maximum then we solved the problem but what if it's not the case? I have tried a lot. Please help.</p>
0debug
static void vc1_decode_ac_coeff(VC1Context *v, int *last, int *skip, int *value, int codingset) { GetBitContext *gb = &v->s.gb; int index, escape, run = 0, level = 0, lst = 0; index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3); if (index != vc1_ac_sizes[codingset] - 1) { run = vc1_index_decode_table[codingset][index][0]; level = vc1_index_decode_table[codingset][index][1]; lst = index >= vc1_last_decode_table[codingset]; if(get_bits1(gb)) level = -level; } else { escape = decode210(gb); if (escape != 2) { index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3); run = vc1_index_decode_table[codingset][index][0]; level = vc1_index_decode_table[codingset][index][1]; lst = index >= vc1_last_decode_table[codingset]; if(escape == 0) { if(lst) level += vc1_last_delta_level_table[codingset][run]; else level += vc1_delta_level_table[codingset][run]; } else { if(lst) run += vc1_last_delta_run_table[codingset][level] + 1; else run += vc1_delta_run_table[codingset][level] + 1; } if(get_bits1(gb)) level = -level; } else { int sign; lst = get_bits1(gb); if(v->s.esc3_level_length == 0) { if(v->pq < 8 || v->dquantfrm) { v->s.esc3_level_length = get_bits(gb, 3); if(!v->s.esc3_level_length) v->s.esc3_level_length = get_bits(gb, 2) + 8; } else { v->s.esc3_level_length = get_unary(gb, 1, 6) + 2; } v->s.esc3_run_length = 3 + get_bits(gb, 2); } run = get_bits(gb, v->s.esc3_run_length); sign = get_bits1(gb); level = get_bits(gb, v->s.esc3_level_length); if(sign) level = -level; } } *last = lst; *skip = run; *value = level; }
1threat
how to groupby and count on every column in r : <p>I have a following dataframe in r</p> <pre><code> Introvert Extrovert Biased Village.Name Positive Negative Negative ABC Negative Negative Negative ABC Negative Positive Positive ABC Positive Negative Negative DEF Negative Positive Positive DEF Negative Positive Positive DEF </code></pre> <p>I want to count <code>Positive</code> in every columns grouped by <code>Village.Name</code> </p> <p>My desired dataframe would be</p> <pre><code> Village.Name Introvert Extrovert Biased ABC 1 1 1 DEF 1 2 2 </code></pre> <p>How can I do it in R?</p>
0debug
Angular router: promise returned from navigatebyurl is ignored : <p>Using this code:</p> <p><code>this.router.navigateByUrl('/login');</code></p> <p>I get the following warning: promise returned from navigatebyurl is ignored. How and when would I want to handle the promise here?</p> <p>P.S. I'm using this in AuthGuard's <code>canActivate</code>.</p>
0debug
def access_key(ditionary,key): return list(ditionary)[key]
0debug
static void i82374_init(I82374State *s) { DMA_init(1, NULL); memset(s->commands, 0, sizeof(s->commands)); }
1threat
concate string with specific separater at specific position in sql server : hi i want to generate xml from from table column value position value 1.1 a 1.2 b 2.1 c 2.1.2 d 3.1 e 3.1.2 f 3.1.2.1 g Output like this <1> <2>b</2> </1> <2>c <1> <2>d</2> </1> </2> <3>e <1> <2>f <1>g</1> </2> </1> </3> i dont know it is possible or not inshort i want multilavel xml based on nth node
0debug
i want to add product Id , product name and product details in mysql table. i made the form in simple Html.?can you help me out.? this is my form : <p>i want to add product Id , product name and product details in mysql table. i made the form in simple Html.?can you help me out.? this is my form.</p>
0debug
char *string_output_get_string(StringOutputVisitor *sov) { char *string = g_string_free(sov->string, false); sov->string = NULL; return string; }
1threat
Hey guys have been struggling on this for a couple of days CANT DRAW RECT on pygame ffs : this is the code:[the code][1] [1]: https://i.stack.imgur.com/SEdtf.png this is the pygame output[the output of the code][2] [2]: https://i.stack.imgur.com/SVCtU.png I have not been able to create a very simple shape/sprite for a couple of days i am sorry i couldn't format the code on stack overflow right.
0debug
static int usb_hid_handle_control(USBDevice *dev, int request, int value, int index, int length, uint8_t *data) { USBHIDState *s = (USBHIDState *)dev; int ret; ret = usb_desc_handle_control(dev, request, value, index, length, data); if (ret >= 0) { return ret; } ret = 0; switch(request) { case DeviceRequest | USB_REQ_GET_STATUS: data[0] = (1 << USB_DEVICE_SELF_POWERED) | (dev->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP); data[1] = 0x00; ret = 2; break; case DeviceOutRequest | USB_REQ_CLEAR_FEATURE: if (value == USB_DEVICE_REMOTE_WAKEUP) { dev->remote_wakeup = 0; } else { goto fail; } ret = 0; break; case DeviceOutRequest | USB_REQ_SET_FEATURE: if (value == USB_DEVICE_REMOTE_WAKEUP) { dev->remote_wakeup = 1; } else { goto fail; } ret = 0; break; case DeviceRequest | USB_REQ_GET_CONFIGURATION: data[0] = 1; ret = 1; break; case DeviceOutRequest | USB_REQ_SET_CONFIGURATION: ret = 0; break; case DeviceRequest | USB_REQ_GET_INTERFACE: data[0] = 0; ret = 1; break; case DeviceOutRequest | USB_REQ_SET_INTERFACE: ret = 0; break; case InterfaceRequest | USB_REQ_GET_DESCRIPTOR: switch(value >> 8) { case 0x22: if (s->kind == USB_MOUSE) { memcpy(data, qemu_mouse_hid_report_descriptor, sizeof(qemu_mouse_hid_report_descriptor)); ret = sizeof(qemu_mouse_hid_report_descriptor); } else if (s->kind == USB_TABLET) { memcpy(data, qemu_tablet_hid_report_descriptor, sizeof(qemu_tablet_hid_report_descriptor)); ret = sizeof(qemu_tablet_hid_report_descriptor); } else if (s->kind == USB_KEYBOARD) { memcpy(data, qemu_keyboard_hid_report_descriptor, sizeof(qemu_keyboard_hid_report_descriptor)); ret = sizeof(qemu_keyboard_hid_report_descriptor); } break; default: goto fail; } break; case GET_REPORT: if (s->kind == USB_MOUSE) ret = usb_mouse_poll(s, data, length); else if (s->kind == USB_TABLET) ret = usb_tablet_poll(s, data, length); else if (s->kind == USB_KEYBOARD) ret = usb_keyboard_poll(&s->kbd, data, length); break; case SET_REPORT: if (s->kind == USB_KEYBOARD) ret = usb_keyboard_write(&s->kbd, data, length); else goto fail; break; case GET_PROTOCOL: if (s->kind != USB_KEYBOARD) goto fail; ret = 1; data[0] = s->protocol; break; case SET_PROTOCOL: if (s->kind != USB_KEYBOARD) goto fail; ret = 0; s->protocol = value; break; case GET_IDLE: ret = 1; data[0] = s->idle; break; case SET_IDLE: s->idle = (uint8_t) (value >> 8); usb_hid_set_next_idle(s, qemu_get_clock(vm_clock)); ret = 0; break; default: fail: ret = USB_RET_STALL; break; } return ret; }
1threat
how to check the values in same elseif statement in vb.net : I want to check the when Category is 'Bank' then Remark should either be 'In queue' or blank value then it should exit from else if condition if both the statements are false display the console message- else if (Category == "Bank" && (Remark != "In queue" || Remark != "")) { Console.WriteLine("When Category is 'Bank' then Remark Should be In queue "); } But in above code one statements is false and one true so it is displaying the console message.It should check either of one condition and anyone statement is true exit from the elseif statement. Please help me on same.
0debug
Unable to print the background text all pages : http://stackoverflow.com/questions/15986216/how-can-i-add-a-large-faded-text-background-via-css/15986317#15986317 Query similar to above. i am printing the page using window.print() if so only one page background the text is printing. how can i print to all pages in my document
0debug
d3.js v4: How to access parent group's datum index? : <p>The description of the <code>selection.data</code> function includes an example with multiple groups (<a href="https://github.com/d3/d3-selection/blob/master/README.md#selection_data">link</a>) where a two-dimensional array is turned into an HTML table.</p> <p>In d3.js v3, for lower dimensions, the accessor functions included a third argument which was the index of the parent group's datum:</p> <pre><code>td.text(function(d,i,j) { return "Row: " + j; }); </code></pre> <p>In v4, this <code>j</code> argument has been replaced by the selection's NodeList. How do I access the parent group's datum index now?</p>
0debug
How do i make a TabNavigator button push a modal screen with React Navigation : <p>Using the React Navigation tab navigator <a href="https://reactnavigation.org/docs/navigators/tab" rel="noreferrer">https://reactnavigation.org/docs/navigators/tab</a> how do I make one of the tab buttons push the screen up as a full screen modal? I see the stack navigator has a <code>mode=modal</code> option. how do I get that mode to be used when clicking on the <code>TakePhoto</code> tab button? Clicking on it currently still shows the tab bar on the bottom.</p> <pre><code>const MyApp = TabNavigator({ Home: { screen: MyHomeScreen, }, TakePhoto: { screen: PhotoPickerScreen, // how can I have this screen show up as a full screen modal? }, }); </code></pre>
0debug
static int64_t coroutine_fn vdi_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { BDRVVdiState *s = (BDRVVdiState *)bs->opaque; size_t bmap_index = sector_num / s->block_sectors; size_t sector_in_block = sector_num % s->block_sectors; int n_sectors = s->block_sectors - sector_in_block; uint32_t bmap_entry = le32_to_cpu(s->bmap[bmap_index]); uint64_t offset; int result; logout("%p, %" PRId64 ", %d, %p\n", bs, sector_num, nb_sectors, pnum); if (n_sectors > nb_sectors) { n_sectors = nb_sectors; } *pnum = n_sectors; result = VDI_IS_ALLOCATED(bmap_entry); if (!result) { return 0; } offset = s->header.offset_data + (uint64_t)bmap_entry * s->block_size + sector_in_block * SECTOR_SIZE; return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | offset; }
1threat
how to read and write the properties file which is in my Java Resources / src / configuration.properties in java : <p>I don't know how to read the properties file which is in Java Resources / src / configuration.properties file. I want to write on that properties file also.</p> <p>Thanks.</p>
0debug
Display image on JSP page using mySql : <p>Please help me in displaying image in a particular section on a JSP page which is stored in mySql database and also tell me that can we store image in any datatype?</p>
0debug
static void usb_mtp_object_readdir(MTPState *s, MTPObject *o) { struct dirent *entry; DIR *dir; if (o->have_children) { return; } o->have_children = true; dir = opendir(o->path); if (!dir) { return; } #ifdef __linux__ int watchfd = usb_mtp_add_watch(s->inotifyfd, o->path); if (watchfd == -1) { fprintf(stderr, "usb-mtp: failed to add watch for %s\n", o->path); } else { trace_usb_mtp_inotify_event(s->dev.addr, o->path, 0, "Watch Added"); o->watchfd = watchfd; } #endif while ((entry = readdir(dir)) != NULL) { usb_mtp_add_child(s, o, entry->d_name); } closedir(dir); }
1threat
Spring Boot application gives 404 when deployed to Tomcat but works with embedded server : <p>Guided by <a href="https://spring.io/guides/gs/serving-web-content/" rel="noreferrer">Serving Web Content with Spring MVC</a>, I'm creating a Spring Boot web application that I can run using both the embedded Tomcat instance as well as on a standalone Tomcat 8 server.</p> <p>The application works as expected when executed as <code>java -jar adminpage.war</code> and I see the expected outcome when I visit <code>http://localhost:8080/table</code>. However, when I deploy to a Tomcat 8 server (by dropping <code>adminpage.war</code> into the <code>webapps</code> directory), I get a 404 error when I visit <code>https://myserver/adminpage/table</code>.</p> <p>The <code>catelina.log</code> and <code>localhost.log</code> files contain nothing helpful on the Tomcat server.</p> <p>Can anyone suggest where I've made a misconfiguration? I've not had the same problems in the past when deploying RESTful services with Spring Boot, but this is my first foray into a web application.</p> <p>My application files:</p> <p><code>src/main/java/com/.../Application.java</code></p> <pre><code>@SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } </code></pre> <p><code>src/main/java/com/.../MainController.java</code></p> <pre><code>@Controller public class MainController { @RequestMapping("/table") public String greeting(Model model) { model.addAttribute("name", "Fooballs"); return "table"; } } </code></pre> <p><code>src/main/resources/templates/table.html</code></p> <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE HTML&gt; &lt;html xmlns:th="http://www.thymeleaf.org"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;/head&gt; &lt;body&gt; &lt;p th:text="'Hello, ' + ${name} + '!'" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><code>pom.xml</code></p> <pre class="lang-xml prettyprint-override"><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;groupId&gt;com.foo&lt;/groupId&gt; &lt;artifactId&gt;adminpage&lt;/artifactId&gt; &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt; &lt;packaging&gt;war&lt;/packaging&gt; &lt;parent&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt; &lt;version&gt;1.4.0.RELEASE&lt;/version&gt; &lt;/parent&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt; &lt;optional&gt;true&lt;/optional&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;properties&gt; &lt;java.version&gt;1.8&lt;/java.version&gt; &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt; &lt;/properties&gt; &lt;build&gt; &lt;finalName&gt;adminpage&lt;/finalName&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/project&gt; </code></pre>
0debug
What would differ between these simple codes? : <p>So I've been kinda new to some concepts, can someone please briefly explain what is the difference between these two codes?</p> <pre><code>regressor=LinearRegression() regressor.fit(train_X,train_Y) </code></pre> <p>.</p> <pre><code>LinearRegression().fit(train_X,train_Y) </code></pre>
0debug
JavaFX: Could not find or load main class only on linux : <p>I've developed a program in Windows with Java(FX) using Intellij Idea and that worked just fine, I then exported the artifact (jar) and there was no problem running it on Windows (both with the console and double clicking it).</p> <p>I've then copied it to my Ubuntu VM, but there it says</p> <pre><code>Error: Could not find or load main class sample.Main </code></pre> <p>This is the Manifest:</p> <pre><code>Manifest-Version: 1.0 Main-Class: sample.Main </code></pre> <p>The JAR file structure looks like this:</p> <pre><code>test.jar --- META-INF --- --- MANIFEST.MF --- org --- --- json --- --- --- // json library --- sample --- --- Contacts.class --- --- Controller.class --- --- Main.class --- --- sample.fxml </code></pre>
0debug
Yii2 loading Jquery in the head of the page : <p>In my Yii2 application i've a script that need Jquery to be loaded in the head of the page.</p> <p>I know there's a parameter that can be setted inside AppAssets.php :</p> <pre><code>public $jsOptions = [ 'position' =&gt; \yii\web\View::POS_HEAD ]; </code></pre> <p>but this will render all the Javascripts Files on the head of the page. Is possibile to load only Jquery on the head?</p> <p>Thanks in advance for all the help</p>
0debug
control the :after of a div when hover on another element : I wanna control after of box2 when hovering on box1. I test this code but it didn't work.so...whats the problem? <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-css --> .box1:hover .box2:after{SOME CSS} <!-- end snippet -->
0debug
def compute_Last_Digit(A,B): variable = 1 if (A == B): return 1 elif ((B - A) >= 5): return 0 else: for i in range(A + 1,B + 1): variable = (variable * (i % 10)) % 10 return variable % 10
0debug
av_cold void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx) { const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8; c->diff_pixels = diff_pixels_c; switch (avctx->bits_per_raw_sample) { case 9: case 10: case 12: case 14: c->get_pixels = get_pixels_16_c; break; default: if (avctx->bits_per_raw_sample<=8 || avctx->codec_type != AVMEDIA_TYPE_VIDEO) { c->get_pixels = get_pixels_8_c; } break; } if (ARCH_ALPHA) ff_pixblockdsp_init_alpha(c, avctx, high_bit_depth); if (ARCH_ARM) ff_pixblockdsp_init_arm(c, avctx, high_bit_depth); if (ARCH_PPC) ff_pixblockdsp_init_ppc(c, avctx, high_bit_depth); if (ARCH_X86) ff_pixblockdsp_init_x86(c, avctx, high_bit_depth); if (ARCH_MIPS) ff_pixblockdsp_init_mips(c, avctx, high_bit_depth); }
1threat
void OPPROTO op_POWER_srea (void) { T1 &= 0x1FUL; env->spr[SPR_MQ] = T0 >> T1; T0 = Ts0 >> T1; RETURN(); }
1threat
protect_from_forgery in Rails 6? : <p>The <code>protect_from_forgery</code> method isn't included in my application controller with a default Rails 6 app, but there's the embedded ruby <code>&lt;%= csrf_meta_tags %&gt;</code> in the main application layout. Does this mean that the <code>protect_from_forgery</code> method has been abstracted and is no longer explicitly needed in the application controller? </p> <p>I've bought the Pragmatic Programmer's Rails 6 book and the only thing I could find was "the csrf_meta_tags() method sets up all the behind-the-scenes data needed to prevent cross-site request forgery attacks".</p>
0debug
static TileExcp decode_y0(DisasContext *dc, tilegx_bundle_bits bundle) { unsigned opc = get_Opcode_Y0(bundle); unsigned ext = get_RRROpcodeExtension_Y0(bundle); unsigned dest = get_Dest_Y0(bundle); unsigned srca = get_SrcA_Y0(bundle); unsigned srcb; int imm; switch (opc) { case RRR_1_OPCODE_Y0: if (ext == UNARY_RRR_1_OPCODE_Y0) { ext = get_UnaryOpcodeExtension_Y0(bundle); return gen_rr_opcode(dc, OE(opc, ext, Y0), dest, srca); } case RRR_0_OPCODE_Y0: case RRR_2_OPCODE_Y0: case RRR_3_OPCODE_Y0: case RRR_4_OPCODE_Y0: case RRR_5_OPCODE_Y0: case RRR_6_OPCODE_Y0: case RRR_7_OPCODE_Y0: case RRR_8_OPCODE_Y0: case RRR_9_OPCODE_Y0: srcb = get_SrcB_Y0(bundle); return gen_rrr_opcode(dc, OE(opc, ext, Y0), dest, srca, srcb); case SHIFT_OPCODE_Y0: ext = get_ShiftOpcodeExtension_Y0(bundle); imm = get_ShAmt_Y0(bundle); return gen_rri_opcode(dc, OE(opc, ext, Y0), dest, srca, imm); case ADDI_OPCODE_Y0: case ADDXI_OPCODE_Y0: case ANDI_OPCODE_Y0: case CMPEQI_OPCODE_Y0: case CMPLTSI_OPCODE_Y0: imm = (int8_t)get_Imm8_Y0(bundle); return gen_rri_opcode(dc, OE(opc, 0, Y0), dest, srca, imm); default: return TILEGX_EXCP_OPCODE_UNIMPLEMENTED; } }
1threat
What is the purpose of a .cmake file? : <p>I might be googling wrongly, but I'm unable to find what's the purpose of .cmake files. </p> <p>I've just stumbled across the cmake tool for a project I've to work with and I'm having a hard time to understand how it works. I do understand that running the cmake command in a directory containing a CMakeLists.txt executes the commands in that file (along with the commands in the CMakeLists.txt contained in the sub-directories) but the purpose of .cmake files is a lot more fuzzy.</p> <p>It seems that they are used to define functions/set variables that are thereafter used in the CMakeLists but I'm not sure. How are they used by the CMake tool ? </p>
0debug
Haskell tuple evaluation : I'm writing a function of the following type: match :: [(String,a)] -> Maybe (String, a, a) I want the function to traverse the list of tuples, and determine if there are any tuples in which the first element (a string) is the same. If so, I want to return a tuple containing that string, as well as the second element in each of those matching tuples. If there are no matching tuples, return "Nothing". If there is more than one matching, return the first one it finds. For example: match [("x", 3), ("y", 4), ("z", 5"), ("x", 6)] = ("x", 3, 6) match [("x", 3), ("y", 4), ("z", 5")] = Nothing I'm thinking: match (x:xs) = if (fst x) = (fst xs) return (fst x, snd x, snd xs) --if no matches, return Nothing Thank you for any help!!
0debug
static void openpic_src_write(void *opaque, hwaddr addr, uint64_t val, unsigned len) { OpenPICState *opp = opaque; int idx; DPRINTF("%s: addr %08x <= %08x\n", __func__, addr, val); if (addr & 0xF) return; addr = addr & 0xFFF0; idx = addr >> 5; if (addr & 0x10) { write_IRQreg_ide(opp, idx, val); } else { write_IRQreg_ipvp(opp, idx, val); } }
1threat
how to extract meaning of thw word using the oxford api in python : i am using the oxford api to get the meaning of a word in python . here is my code import requests import json app_id = '2a878969' app_key = '215d68e146462106de8196ff58e059c2' language = 'en' word_id = 'help' url = 'https://od-api.oxforddictionaries.com:443/api/v1/entries/'+ language + '/'+ word_id.lower() #url Normalized frequency urlFR = 'https://od-api.oxforddictionaries.com:443/api/v1/stats/frequency/word/' + language + '/?corpus=nmc&lemma=' + word_id.lower() r = requests.get(url, headers = {'app_id' : app_id, 'app_key' : app_key}) #print("code {}\n".format(r.status_code)) print("text \n" + r.text) #print("json \n" + json.dumps(r.json())) and the output i got is following text { "metadata": { "provider": "Oxford University Press" }, "results": [ { "id": "help", "language": "en", "lexicalEntries": [ { "entries": [ { "etymologies": [ "Old English helpan (verb), help (noun), of Germanic origin; related to Dutch helpen and German helfen" ], "grammaticalFeatures": [ { "text": "Transitive", "type": "Subcategorization" }, { "text": "Present", "type": "Tense" } ], "homographNumber": "000", "senses": [ { "definitions": [ "make it easier or possible for (someone) to do something by offering them one's services or resources" ], "examples": [ { "text": "the teenager helped out in the corner shop" }, { "text": "she helped him find a buyer" }, { "text": "they helped her with domestic chores" } ], "id": "m_en_gbus0460970.006", "short_definitions": [ "assist someone to do something" ], "subsenses": [ { "definitions": [ "improve (a situation or problem); be of benefit to" ], "examples": [ { "text": "legislation to fit all new cars with catalytic converters will help" }, { "text": "upbeat comments about prospects helped confidence" } ], "id": "m_en_gbus0460970.012", "short_definitions": [ "improve situation" ], "thesaurusLinks": [ { "entry_id": "help", "sense_id": "t_en_gb0006913.003" } ] }, { "definitions": [ "assist (someone) to move" ], "examples": [ { "text": "I helped her up" } ], "id": "m_en_gbus0460970.013", "notes": [ { "text": "with object and adverbial of direction", "type": "grammaticalNote" } ], "short_definitions": [ "assist someone to move" ] }, { "definitions": [ "assist someone to put on or take off (a garment)" ], "examples": [ { "text": "she would help him off with his coat" } ], "id": "m_en_gbus0460970.014", "notes": [ { "text": "\"help someone on/off with\"", "type": "wordFormNote" } ], "short_definitions": [ "assist someone with garment" ] } ], "thesaurusLinks": [ { "entry_id": "help", "sense_id": "t_en_gb0006913.001" } ] }, { "definitions": [ "serve someone with (food or drink)" ], "examples": [ { "text": "may I help you to some more meat?" }, { "text": "she helped herself to a biscuit" } ], "id": "m_en_gbus0460970.017", "notes": [ { "text": "\"help someone to\"", "type": "wordFormNote" } ], "short_definitions": [ "serve someone with food or drink" ], "subsenses": [ { "definitions": [ "take something without permission" ], "examples": [ { "text": "he helped himself to the wages she had brought home" } ], "id": "m_en_gbus0460970.018", "notes": [ { "text": "\"help oneself\"", "type": "wordFormNote" } ], "short_definitions": [ "take something without permission" ], "thesaurusLinks": [ { "entry_id": "help_oneself_to", "sense_id": "t_en_gb0006913.006" } ] } ] }, { "definitions": [ "cannot or could not avoid" ], "examples": [ { "text": "he couldn't help laughing" }, { "text": "I'm sorry to put you to any inconvenience, but it can't be helped" } ], "id": "m_en_gbus0460970.020", "notes": [ { "text": "\"can/could not help\"", "type": "wordFormNote" } ], "short_definitions": [ "cannot or could not avoid" ], "subsenses": [ { "definitions": [ "cannot or could not stop oneself from doing something" ], "examples": [ { "text": "she couldn't help herself; she burst into tears" } ], "id": "m_en_gbus0460970.021", "notes": [ { "text": "\"can/could not help oneself\"", "type": "wordFormNote" } ], "short_definitions": [ "cannot or could not stop oneself" ] } ], "thesaurusLinks": [ { "entry_id": "cannot_help", "sense_id": "t_en_gb0006913.005" } ] } ] } ], "language": "en", "lexicalCategory": "Verb", "pronunciations": [ { "audioFile": "http://audio.oxforddictionaries.com/en/mp3/help_gb_1.mp3", "dialects": [ "British English" ], "phoneticNotation": "IPA", "phoneticSpelling": "hɛlp" } ], "text": "help" }, { "entries": [ { "grammaticalFeatures": [ { "text": "Mass", "type": "Countability" }, { "text": "Singular", "type": "Number" } ], "homographNumber": "001", "senses": [ { "definitions": [ "the action of helping someone to do something" ], "examples": [ { "text": "I asked for help from my neighbours" } ], "id": "m_en_gbus0460970.023", "short_definitions": [ "action of helping" ], "subsenses": [ { "definitions": [ "the fact of being useful" ], "examples": [ { "text": "the skimpy manual isn't much help for beginners" } ], "id": "m_en_gbus0460970.025", "short_definitions": [ "fact of being useful" ], "thesaurusLinks": [ { "entry_id": "usefulness", "sense_id": "t_en_gb0015781.001" } ] }, { "definitions": [ "a person or thing that helps" ], "examples": [ { "text": "he was a great help" }, { "text": "she's been given financial help with travel" } ], "id": "m_en_gbus0460970.026", "short_definitions": [ "person or thing that helps" ], "thesaurusLinks": [ { "entry_id": "backup", "sense_id": "t_en_gb0001080.001" } ] }, { "definitions": [ "a domestic employee" ], "examples": [ { "text": "she has taught herself to cook since the defection of the last of the village helps" }, { "text": "the help cleaned up the leftover food and half-drunk cocktails" } ], "id": "m_en_gbus0460970.027", "notes": [ { "text": "count noun", "type": "grammaticalNote" } ], "short_definitions": [ "domestic employee" ], "thesaurusLinks": [ { "entry_id": "help", "sense_id": "t_en_gb0006913.009" } ] }, { "definitions": [ "giving assistance to a computer user in the form of displayed instructions" ], "domains": [ "Computing" ], "examples": [ { "text": "a help menu" } ], "id": "m_en_gbus0460970.030", "notes": [ { "text": "as modifier", "type": "grammaticalNote" } ], "short_definitions": [ "giving assistance to computer user" ] } ], "thesaurusLinks": [ { "entry_id": "help", "sense_id": "t_en_gb0006913.007" } ] } ] } ], "language": "en", "lexicalCategory": "Noun", "pronunciations": [ { "audioFile": "http://audio.oxforddictionaries.com/en/mp3/help_gb_1.mp3", "dialects": [ "British English" ], "phoneticNotation": "IPA", "phoneticSpelling": "hɛlp" } ], "text": "help" }, { "entries": [ { "homographNumber": "002", "senses": [ { "definitions": [ "used as an appeal for urgent assistance" ], "examples": [ { "text": "Help! I'm drowning!" } ], "id": "m_en_gbus0460970.033", "short_definitions": [ "appeal for urgent assistance" ] } ] } ], "language": "en", "lexicalCategory": "Interjection", "pronunciations": [ { "audioFile": "http://audio.oxforddictionaries.com/en/mp3/help_gb_1.mp3", "dialects": [ "British English" ], "phoneticNotation": "IPA", "phoneticSpelling": "hɛlp" } ], "text": "help" } ], "type": "headword", "word": "help" } ] } here the word id "help" whose information is shown in the output i want to extract the **definition** part only .see below "definitions": [ "make it easier or possible for (someone) to do something by offering them one's services or resources" ], you can see there is a definition part in the output . how to do this in python .there are so many definition available i just want the first one
0debug
iisreset error on windows 10 : <p>I have recently upgraded my desktop from Windows 7 to Windows 10</p> <p>However when I run iisrest from an administrator console, I am getting the following error:</p> <blockquote> <p>Restart attempt failed. The IIS Admin Service or the World Wide Web Publishing Service, or a service dependent on them failed to start. The service, or dependent services, may had an error during its startup or may be disabled.</p> </blockquote> <p>I initially checked my services, and there is no longer the IIS Admin service. I then checked the windows features, and as per nearly every article on the web that discusses installing IIS, I have selected Internet Information Services.</p> <p>I have checked and the web service has restarted, Is this a new feature of Windows10 that the IIS Admin service is no longer required. Is there an additional step that I need to do that will install the service</p> <p>Or is this now an issue with IISReset and I can ignore the error.</p> <p>I have also tested this on a freshly installed Windows 10 box, and running IISReset gives the same error, and once again have verified via Windows features that IIS is installed</p> <p>I can access website locally with no problems either</p>
0debug
How to remove an image from gridview by using cross sign at the corner(Android)? : <p><a href="https://i.stack.imgur.com/lcOSZ.jpg" rel="nofollow noreferrer">enter image description here</a></p> <p>i have already created gridview.i want to remove the images by a single click. thank u.</p>
0debug
NodeJS - convert relative path to absolute : <p>In my <em>File-system</em> my working directory is here:</p> <p><strong>C:\temp\a\b\c\d</strong></p> <p>and under b\bb there's file: tmp.txt</p> <p><strong>C:\temp\a\b\bb\tmp.txt</strong></p> <p>If I want to go to this file from my working directory, I'll use this path:</p> <pre><code>"../../bb/tmp.txt" </code></pre> <p>In case the file is not exist I want to log the full path and tell the user:<br> <strong>"The file C:\temp\a\b\bb\tmp.txt is not exist"</strong>. </p> <p><strong>My question:</strong></p> <p>I need some <strong>function</strong> that <em>convert</em> the relative path: "../../bb/tmp.txt" to absolute: "C:\temp\a\b\bb\tmp.txt" </p> <p>In my code it should be like this: </p> <pre><code>console.log("The file" + convertToAbs("../../bb/tmp.txt") + " is not exist") </code></pre>
0debug
Validation of checkbo with same name : I need to show error if none of the below checkboe are checked using using javascript.Please help.. <tr> <td>Status</td> <td colspan="3"> <input type="checkbox" name="chk_stat[]" value="single" id="chk_stat"> single <input type="checkbox" name="chk_stat[]" value="married" id="chk_stat"> Married <input type="checkbox" name="chk_stat[]" value="divorcee" id="chk_stat"> Divorcee <input type="checkbox" name="chk_stat[]" value="student" id="chk_stat"> Student </td> </tr>
0debug
Understanding the math behind the code in C : I don't know this question is legal or not but i think every programmer can help me. It is a really basic and simple question but i have problem with understanding. #define POLYNOMIAL(x) (((((3.0 * (x) + 2.0) * (x) - 5.0) * (x) - 1.0) * (x) + 7.0) * (x) - 6.0) This defination is for this polynom : (3x^5)+(2x^4)-(5x^3)-(x^2)+7x-6 How can I convert this polynom into form of the one which i have written after define. Are there any trick for this ?
0debug
How to change the text color of the button theme in Flutter : <p>If I add a theme to my app like this:</p> <pre><code>class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( primaryColor: Color(0xff393e46), primaryColorDark: Color(0xff222831), accentColor: Color(0xff00adb5), backgroundColor: Color(0xffeeeeee), buttonTheme: ButtonThemeData( buttonColor: Color(0xff00adb5), ) ), home: Scaffold( body: MyHomePage(), ), ); } } </code></pre> <p>How do I change the text color for the button theme?</p>
0debug
void ppm_save(const char *filename, struct DisplaySurface *ds, Error **errp) { int width = pixman_image_get_width(ds->image); int height = pixman_image_get_height(ds->image); FILE *f; int y; int ret; pixman_image_t *linebuf; trace_ppm_save(filename, ds); f = fopen(filename, "wb"); if (!f) { error_setg(errp, "failed to open file '%s': %s", filename, strerror(errno)); return; } ret = fprintf(f, "P6\n%d %d\n%d\n", width, height, 255); if (ret < 0) { linebuf = NULL; goto write_err; } linebuf = qemu_pixman_linebuf_create(PIXMAN_BE_r8g8b8, width); for (y = 0; y < height; y++) { qemu_pixman_linebuf_fill(linebuf, ds->image, width, 0, y); clearerr(f); ret = fwrite(pixman_image_get_data(linebuf), 1, pixman_image_get_stride(linebuf), f); (void)ret; if (ferror(f)) { goto write_err; } } out: qemu_pixman_image_unref(linebuf); fclose(f); return; write_err: error_setg(errp, "failed to write to file '%s': %s", filename, strerror(errno)); unlink(filename); goto out; }
1threat
How to denote return type tuple in Google-style Pydoc for Pycharm? : <p>In Pycharm I want to have a documented function that returns a tuple so that I can get code completion on it. The style of comments is Google-style.</p> <hr> <p>This <strong>works</strong> correctly:</p> <pre><code>def func(): """ Returns: str: something """ pass </code></pre> <p>Typing <code>func().</code> correctly shows methods for <code>str</code>.</p> <hr> <p>However, typing this <strong>does not</strong> work anymore:</p> <pre><code>def func(): """ Returns: (int, str): something """ pass a, b = func() </code></pre> <p>Typing <code>b.</code> does not offer anything.</p> <hr> <p>I know that PyCharm is capable of parsing tuples, because this code <strong>works</strong>:</p> <pre><code>def func(): """ :rtype: (int, str) """ pass a, b = func() </code></pre> <p>However, this is not according to the Google style.</p> <hr> <p>How do I document a function according to the standard so that Pycharm will pick up on the return types?</p>
0debug
Fragments Implement OnClickListener : <p>I have this Fragments but i cant findviewbyid. i already look around website but get nothing. thankss</p> <pre><code>public class Course extends Fragment implements OnClickListener @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.course, container, false); View button1Button = findViewById(R.id.button_button1); button1Button.setOnClickListener(this); View button2Button = findViewById(R.id.button_button2); button2Button.setOnClickListener(this); View button3Button = findViewById(R.id.button_button3); button3Button.setOnClickListener(this); View button4Button = findViewById(R.id.button_button4); button4Button.setOnClickListener(this); View button5Button = findViewById(R.id.button_button5); button5Button.setOnClickListener(this); View button6Button = findViewById(R.id.button_button6); button6Button.setOnClickListener(this); View button7Button = findViewById(R.id.button_button7); button7Button.setOnClickListener(this); View button8Button = findViewById(R.id.button_button8); button8Button.setOnClickListener(this); } </code></pre> <p>thankss</p>
0debug
static int vp9_alloc_frame(AVCodecContext *ctx, VP9Frame *f) { VP9Context *s = ctx->priv_data; int ret, sz; if ((ret = ff_thread_get_buffer(ctx, &f->tf, AV_GET_BUFFER_FLAG_REF)) < 0) return ret; sz = 64 * s->sb_cols * s->sb_rows; if (!(f->extradata = av_buffer_allocz(sz * (1 + sizeof(struct VP9mvrefPair))))) { ff_thread_release_buffer(ctx, &f->tf); return AVERROR(ENOMEM); } f->segmentation_map = f->extradata->data; f->mv = (struct VP9mvrefPair *) (f->extradata->data + sz); if (s->segmentation.enabled && !s->segmentation.update_map && !s->keyframe && !s->intraonly) { memcpy(f->segmentation_map, s->frames[LAST_FRAME].segmentation_map, sz); } return 0; }
1threat
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
static int reap_filters(int flush) { AVFrame *filtered_frame = NULL; int i; for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; OutputFile *of = output_files[ost->file_index]; AVFilterContext *filter; AVCodecContext *enc = ost->enc_ctx; int ret = 0; if (!ost->filter || !ost->filter->graph->graph) continue; filter = ost->filter->filter; if (!ost->initialized) { char error[1024]; ret = init_output_stream(ost, error, sizeof(error)); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- %s\n", ost->file_index, ost->index, error); exit_program(1); } } if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc())) { return AVERROR(ENOMEM); } filtered_frame = ost->filtered_frame; while (1) { double float_pts = AV_NOPTS_VALUE; ret = av_buffersink_get_frame_flags(filter, filtered_frame, AV_BUFFERSINK_FLAG_NO_REQUEST); if (ret < 0) { if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) { av_log(NULL, AV_LOG_WARNING, "Error in av_buffersink_get_frame_flags(): %s\n", av_err2str(ret)); } else if (flush && ret == AVERROR_EOF) { if (av_buffersink_get_type(filter) == AVMEDIA_TYPE_VIDEO) do_video_out(of, ost, NULL, AV_NOPTS_VALUE); } break; } if (ost->finished) { av_frame_unref(filtered_frame); continue; } if (filtered_frame->pts != AV_NOPTS_VALUE) { int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : of->start_time; AVRational filter_tb = av_buffersink_get_time_base(filter); AVRational tb = enc->time_base; int extra_bits = av_clip(29 - av_log2(tb.den), 0, 16); tb.den <<= extra_bits; float_pts = av_rescale_q(filtered_frame->pts, filter_tb, tb) - av_rescale_q(start_time, AV_TIME_BASE_Q, tb); float_pts /= 1 << extra_bits; float_pts += FFSIGN(float_pts) * 1.0 / (1<<17); filtered_frame->pts = av_rescale_q(filtered_frame->pts, filter_tb, enc->time_base) - av_rescale_q(start_time, AV_TIME_BASE_Q, enc->time_base); } switch (av_buffersink_get_type(filter)) { case AVMEDIA_TYPE_VIDEO: if (!ost->frame_aspect_ratio.num) enc->sample_aspect_ratio = filtered_frame->sample_aspect_ratio; if (debug_ts) { av_log(NULL, AV_LOG_INFO, "filter -> pts:%s pts_time:%s exact:%f time_base:%d/%d\n", av_ts2str(filtered_frame->pts), av_ts2timestr(filtered_frame->pts, &enc->time_base), float_pts, enc->time_base.num, enc->time_base.den); } do_video_out(of, ost, filtered_frame, float_pts); break; case AVMEDIA_TYPE_AUDIO: if (!(enc->codec->capabilities & AV_CODEC_CAP_PARAM_CHANGE) && enc->channels != av_frame_get_channels(filtered_frame)) { av_log(NULL, AV_LOG_ERROR, "Audio filter graph output is not normalized and encoder does not support parameter changes\n"); break; } do_audio_out(of, ost, filtered_frame); break; default: av_assert0(0); } av_frame_unref(filtered_frame); } } return 0; }
1threat
Long array list rendering makes page scrolling slow in Angular.js : <p>When trying to render more than 120 items from an array (with images) the <strong>scrolling</strong> of the list becomes slower. Basically, when I am loading new data in infinite scroll, I am concatenating old array data with new array data. </p> <p>On the other hand, popular websites like dribbble, behance dont seem to have this issue. Maybe this issue is specific to Angular.js? Has anyone faced this problem in their projects? </p>
0debug
static int color_distance(uint32_t a, uint32_t b) { int r = 0, d, i; for (i = 0; i < 32; i += 8) { d = ((a >> i) & 0xFF) - ((b >> i) & 0xFF); r += d * d; } return r; }
1threat
void helper_mtc0_index(CPUMIPSState *env, target_ulong arg1) { int num = 1; unsigned int tmp = env->tlb->nb_tlb; do { tmp >>= 1; num <<= 1; } while (tmp); env->CP0_Index = (env->CP0_Index & 0x80000000) | (arg1 & (num - 1)); }
1threat
I have to download a file from the stock exchange website through php, the link of the file is given below, : [1]: https://psx.com.pk/scripts/communicator.php?f=20170119_new.lis.Z&l=Hd I found many codes in google but not working, Anyone who have had gone through it?
0debug
static direntry_t *create_short_filename(BDRVVVFATState *s, const char *filename, unsigned int directory_start) { int i, j = 0; direntry_t *entry = array_get_next(&(s->directory)); const gchar *p, *last_dot = NULL; gunichar c; bool lossy_conversion = false; char tail[11]; if (!entry) { return NULL; } memset(entry->name, 0x20, sizeof(entry->name)); for (p = filename; ; p = g_utf8_next_char(p)) { c = g_utf8_get_char(p); if (c == '\0') { break; } else if (c == '.') { if (j == 0) { lossy_conversion = true; } else { if (last_dot) { lossy_conversion = true; } last_dot = p; } } else if (!last_dot) { uint8_t v = to_valid_short_char(c); if (j < 8 && v) { entry->name[j++] = v; } else { lossy_conversion = true; } } } if (last_dot) { j = 0; for (p = g_utf8_next_char(last_dot); ; p = g_utf8_next_char(p)) { c = g_utf8_get_char(p); if (c == '\0') { break; } else { uint8_t v = to_valid_short_char(c); if (j < 3 && v) { entry->name[8 + (j++)] = v; } else { lossy_conversion = true; } } } } if (entry->name[0] == DIR_KANJI) { entry->name[0] = DIR_KANJI_FAKE; } for (j = 0; j < 8; j++) { if (entry->name[j] == ' ') { break; } } for (i = lossy_conversion ? 1 : 0; i < 999999; i++) { direntry_t *entry1; if (i > 0) { int len = sprintf(tail, "~%d", i); memcpy(entry->name + MIN(j, 8 - len), tail, len); } for (entry1 = array_get(&(s->directory), directory_start); entry1 < entry; entry1++) { if (!is_long_name(entry1) && !memcmp(entry1->name, entry->name, 11)) { break; } } if (entry1 == entry) { return entry; } } return NULL; }
1threat
static int tcx_init1(SysBusDevice *dev) { TCXState *s = FROM_SYSBUS(TCXState, dev); ram_addr_t vram_offset = 0; int size; uint8_t *vram_base; memory_region_init_ram(&s->vram_mem, "tcx.vram", s->vram_size * (1 + 4 + 4)); vmstate_register_ram_global(&s->vram_mem); vram_base = memory_region_get_ram_ptr(&s->vram_mem); s->vram = vram_base; size = s->vram_size; memory_region_init_alias(&s->vram_8bit, "tcx.vram.8bit", &s->vram_mem, vram_offset, size); sysbus_init_mmio(dev, &s->vram_8bit); vram_offset += size; vram_base += size; memory_region_init_io(&s->dac, &tcx_dac_ops, s, "tcx.dac", TCX_DAC_NREGS); sysbus_init_mmio(dev, &s->dac); memory_region_init_io(&s->tec, &dummy_ops, s, "tcx.tec", TCX_TEC_NREGS); sysbus_init_mmio(dev, &s->tec); memory_region_init_io(&s->thc24, &dummy_ops, s, "tcx.thc24", TCX_THC_NREGS_24); sysbus_init_mmio(dev, &s->thc24); if (s->depth == 24) { size = s->vram_size * 4; s->vram24 = (uint32_t *)vram_base; s->vram24_offset = vram_offset; memory_region_init_alias(&s->vram_24bit, "tcx.vram.24bit", &s->vram_mem, vram_offset, size); sysbus_init_mmio(dev, &s->vram_24bit); vram_offset += size; vram_base += size; size = s->vram_size * 4; s->cplane = (uint32_t *)vram_base; s->cplane_offset = vram_offset; memory_region_init_alias(&s->vram_cplane, "tcx.vram.cplane", &s->vram_mem, vram_offset, size); sysbus_init_mmio(dev, &s->vram_cplane); s->con = graphic_console_init(tcx24_update_display, tcx24_invalidate_display, tcx24_screen_dump, NULL, s); } else { memory_region_init_io(&s->thc8, &dummy_ops, s, "tcx.thc8", TCX_THC_NREGS_8); sysbus_init_mmio(dev, &s->thc8); s->con = graphic_console_init(tcx_update_display, tcx_invalidate_display, tcx_screen_dump, NULL, s); } qemu_console_resize(s->con, s->width, s->height); return 0; }
1threat
''Module "Discord" not found'' (Python3.x) : I have a small question, my Discord bot is written in Python and I keep getting errors This is the code of my bot: import discord import asyncio client = discord.Client() @client.event async def on_ready(): print('Logged in as') print(client.user.name) print(client.user.id) print('------') @client.event async def on_message(message): if message.content.startswith('!test'): await client.send_message(message.channel, 'Calculating messages...') client.run('You arent gonna get my token =D') And when I run it this error comes: Traceback (most recent call last): File "C:\Users\DELL\Documents\Testing\discordbt.py", line 1, in <module> import discord ModuleNotFoundError: No module named 'discord' I really don't know what to do, all I did is the following commands in CMD: pip install discord.py pip install asyncio That's all, I made sure the modules installed without errors, and they did, everything is up and such, and I know you need some other "programs" and I have installed the following programs: `Python 3.6.3 64x` and `Python 3.7.0a2 64x` My PC is from a 64x bit architecture so it completely macthes. Please help me out :D - Deadly
0debug
all possible keys of an union type : <p>I want to get all available keys of an union type.</p> <pre><code>interface Foo { foo: string; } interface Bar { bar: string; } type Batz = Foo | Bar; type AvailableKeys = keyof Batz; </code></pre> <p>I want to have <code>'foo' | 'bar'</code> as result of <code>AvailableKeys</code> but it is <code>never</code> (as alternative I could do <code>keyof (Foo &amp; Bar)</code>, what produces exact the required type but I want to avoid to repeat the Types).</p> <p>I found already the issue <a href="https://github.com/Microsoft/TypeScript/issues/12948" rel="noreferrer"><code>keyof</code> union type should produce union of keys</a> at github. I understand the answer, that <code>keyof UnionType</code> should not produce all possible keys.</p> <p>So my question is: Is there an other way to get the list of all possible keys (it is ok if the verison 2.8 of tsc is required)?</p>
0debug
how to give different file name every time i capture video and write it to file? : <p>I am newbee in opencv. I am working on part of the project.</p> <p>In the below code, I have used <strong>VideoWriter</strong> class to store video with name <strong>MyVideo.avi</strong> as I specified in below code. But every time i capture video it stores with same name i.e it get overridden. <strong>So I want to name it with computer date and time. please help me to modify this</strong> </p> <pre><code>#include "opencv2/highgui/highgui.hpp" #include &lt;iostream&gt; using namespace cv; using namespace std; int main(int argc, char* argv[]) { VideoCapture cap(0); // open the video camera no. 0 if (!cap.isOpened()) // if not success, exit program { cout &lt;&lt; "ERROR: Cannot open the video file" &lt;&lt; endl; return -1; } namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo" double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video cout &lt;&lt; "Frame Size = " &lt;&lt; dWidth &lt;&lt; "x" &lt;&lt; dHeight &lt;&lt; endl; Size frameSize(static_cast&lt;int&gt;(dWidth), static_cast&lt;int&gt;(dHeight)); VideoWriter oVideoWriter ("D:/MyVideo.avi", CV_FOURCC('P','I','M','1'), 20, frameSize, true); //initialize the VideoWriter object if ( !oVideoWriter.isOpened() ) //if not initialize the VideoWriter successfully, exit the program { cout &lt;&lt; "ERROR: Failed to write the video" &lt;&lt; endl; return -1; } while (1) { Mat frame; bool bSuccess = cap.read(frame); // read a new frame from video if (!bSuccess) //if not success, break loop { cout &lt;&lt; "ERROR: Cannot read a frame from video file" &lt;&lt; endl; break; } oVideoWriter.write(frame); //writer the frame into the file imshow("MyVideo", frame); //show the frame in "MyVideo" window if (waitKey(10) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop { cout &lt;&lt; "esc key is pressed by user" &lt;&lt; endl; break; } } return 0; } </code></pre>
0debug
How can I make a better use of this method? - RUBY (raw) : def proficiency_parser(stored_data, name, race, year, title, percentage) if stored_data.has_key?(name) if stored_data[name].has_key?(race) if stored_data[name][race].has_key?(year) stored_data[name][race][year][title] = percentage else stored_data[name][race][year] = {title => percentage} end else stored_data[name][race] = {year => {title => percentage}} end else stored_data[name] = {race => {year => {title => percentage}}} end end def determinate_percentage(data) data = "N/A" if data == "N/A" else data.to_f end
0debug
Dispaly wordpress slideshow in homepage : I don't know how to display an slideshow to my hompage in wordpress, I just installed a plugin, I tried a shortcode and loop and calling the page, it doesn't work! Any help?
0debug
void aio_set_dispatching(AioContext *ctx, bool dispatching) { ctx->dispatching = dispatching; if (!dispatching) { smp_mb(); } }
1threat
How to do some operations on other website in PHP/JS : <p>How I can do some operations like for example filling forms on the other website using PHP or JS/JQuery ?</p>
0debug
I am trying to look through an array and pick out certain strings - JAVA : So, We have to do complete a task for my AP Computer Science class and I figured out the base of the code but I am stuck on a part. Here is the link to complete the assignment if you would like to try it out. LINK: http://codingbat.com/prob/p254067 Here is my code so far: public int numVworthy(String wordsList[]) { int count = 0; String w = "w"; String v = "v"; for(int i = 0; i < wordsList.length; i++) { if(wordsList[i].contains == v) { if(wordsList[i -1].contains != w && wordsList[i + 1].contains != w) { count++; } } } return count; } Any help on what to do next is appreciated
0debug
Firebase analytics AppMeasurement not enabled : <p>I have followed all the instructions for integrating Firebase analytics correctly in my project. But when I enable debug logging to make sure the events are being sent (using instructions from <a href="https://firebase.google.com/docs/analytics/android/start/" rel="noreferrer">here</a>) I see </p> <pre><code>E/FA ( 3556): AppMeasurementReceiver not registered/enabled E/FA ( 3556): AppMeasurementService not registered/enabled E/FA ( 3556): Uploading is not possible. App measurement disabled </code></pre> <p>and obviously the events are not being sent.</p> <p>Again I have followed all the instructions .</p>
0debug
static inline int divide3(int x) { return ((x+1)*21845 + 10922) >> 16; }
1threat