problem
stringlengths
26
131k
labels
class label
2 classes
int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { trace_bdrv_co_readv(bs, sector_num, nb_sectors); return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov, 0); }
1threat
pyinstaller error: OSError: Python library not found: libpython3.4mu.so.1.0, libpython3.4m.so.1.0, libpython3.4.so.1.0 : <p>I'm using Python 3.4.4 on Centos7.</p> <p>I've created a python program on my local machine that makes use of qt modules. The program is running fine on my local machine. I'm now trying to create an executable with pyinstaller. I'm using the command:</p> <pre><code>pyinstaller main.py </code></pre> <p>I'm getting the following output:</p> <pre><code>40 INFO: PyInstaller: 3.2.1 40 INFO: Python: 3.4.4 41 INFO: Platform: Linux-3.10.0-327.36.3.el7.x86_64-x86_64-with-centos-7.3.1611-Core 41 INFO: wrote /home/neilharris/Documents/Python_Projects/transcoder/main.spec 42 INFO: UPX is not available. 44 INFO: Extending PYTHONPATH with paths ['/home/neilharris/Documents/Python_Projects/transcoder', '/home/neilharris/Documents/Python_Projects/transcoder'] 44 INFO: checking Analysis 44 INFO: Building Analysis because out00-Analysis.toc is non existent 44 INFO: Initializing module dependency graph... 45 INFO: Initializing module graph hooks... 47 INFO: Analyzing base_library.zip ... 1869 INFO: Processing pre-find module path hook distutils 3030 INFO: running Analysis out00-Analysis.toc 3039 INFO: Caching module hooks... 3046 INFO: Analyzing /home/neilharris/Documents/Python_Projects/transcoder/main.py 3089 INFO: Loading module hooks... 3089 INFO: Loading module hook "hook-xml.py"... 3353 INFO: Loading module hook "hook-encodings.py"... 3437 INFO: Loading module hook "hook-PyQt4.py"... 3438 INFO: Loading module hook "hook-distutils.py"... 3440 INFO: Loading module hook "hook-PyQt4.QtCore.py"... 3575 INFO: Loading module hook "hook-pydoc.py"... 3576 INFO: Loading module hook "hook-PyQt4.QtGui.py"... 3849 INFO: Looking for ctypes DLLs 3861 INFO: Analyzing run-time hooks ... 3867 INFO: Including run-time hook 'pyi_rth_qt4plugins.py' 3877 INFO: Looking for dynamic libraries ldd: warning: you do not have execution permission for `/usr/local/lib/python3.4/site-packages/PyQt4/QtGui.so' ldd: warning: you do not have execution permission for `/usr/local/lib/python3.4/site-packages/PyQt4/QtCore.so' 5115 INFO: Looking for eggs 5115 INFO: Python library not in binary depedencies. Doing additional searching... Traceback (most recent call last): File "/usr/local/bin/pyinstaller", line 9, in &lt;module&gt; load_entry_point('PyInstaller==3.2.1', 'console_scripts', 'pyinstaller')() File "/usr/local/lib/python3.4/site-packages/PyInstaller/__main__.py", line 90, in run run_build(pyi_config, spec_file, **vars(args)) File "/usr/local/lib/python3.4/site-packages/PyInstaller/__main__.py", line 46, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "/usr/local/lib/python3.4/site-packages/PyInstaller/building/build_main.py", line 788, in main build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build')) File "/usr/local/lib/python3.4/site-packages/PyInstaller/building/build_main.py", line 734, in build exec(text, spec_namespace) File "&lt;string&gt;", line 16, in &lt;module&gt; File "/usr/local/lib/python3.4/site-packages/PyInstaller/building/build_main.py", line 212, in __init__ self.__postinit__() File "/usr/local/lib/python3.4/site-packages/PyInstaller/building/datastruct.py", line 161, in __postinit__ self.assemble() File "/usr/local/lib/python3.4/site-packages/PyInstaller/building/build_main.py", line 543, in assemble self._check_python_library(self.binaries) File "/usr/local/lib/python3.4/site-packages/PyInstaller/building/build_main.py", line 626, in _check_python_library raise IOError(msg) OSError: Python library not found: libpython3.4m.so.1.0, libpython3.4mu.so.1.0, libpython3.4.so.1.0 This would mean your Python installation doesn't come with proper library files. This usually happens by missing development package, or unsuitable build parameters of Python installation. * On Debian/Ubuntu, you would need to install Python development packages * apt-get install python3-dev * apt-get install python-dev * If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin) </code></pre> <p>Does anyone know what the issue could be? Just to say I have python3-devel and python-devel installed (in relation to the suggestion at the end of the printed output.) Thanks</p>
0debug
Standart array to tree array : I have a array like this; [vertical array][1] But i want to set array by using level key like this; [tree view array][2] [1]: https://i.stack.imgur.com/Lv8Cm.png [2]: https://i.stack.imgur.com/G7Z6V.png
0debug
static int decode_block_progressive(MJpegDecodeContext *s, DCTELEM *block, uint8_t *last_nnz, int ac_index, int16_t *quant_matrix, int ss, int se, int Al, int *EOBRUN) { int code, i, j, level, val, run; if(*EOBRUN){ (*EOBRUN)--; return 0; } {OPEN_READER(re, &s->gb) for(i=ss;;i++) { UPDATE_CACHE(re, &s->gb); GET_VLC(code, re, &s->gb, s->vlcs[1][ac_index].table, 9, 2) code -= 16; run = ((unsigned) code) >> 4; code &= 0xF; if(code) { i += run; if(code > MIN_CACHE_BITS - 16){ UPDATE_CACHE(re, &s->gb) } { int cache=GET_CACHE(re,&s->gb); int sign=(~cache)>>31; level = (NEG_USR32(sign ^ cache,code) ^ sign) - sign; } LAST_SKIP_BITS(re, &s->gb, code) if (i >= se) { if(i == se){ j = s->scantable.permutated[se]; block[j] = level * quant_matrix[j] << Al; break; } av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i); return -1; } j = s->scantable.permutated[i]; block[j] = level * quant_matrix[j] << Al; }else{ if(run == 0xF){ i += 15; }else{ val = (1 << run); if(run){ UPDATE_CACHE(re, &s->gb); val += NEG_USR32(GET_CACHE(re, &s->gb), run); LAST_SKIP_BITS(re, &s->gb, run); } *EOBRUN = val - 1; break; } } } CLOSE_READER(re, &s->gb)} if(i > *last_nnz) *last_nnz = i; return 0; }
1threat
Why is my JavaScript code refusing to run on my website? : <p>The following is what my HTML document looks like:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="scripts/homepage-script.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="how-it-works"&gt; &lt;p&gt;How It Works&lt;/p&gt; &lt;img src="some-imageurl"&gt; &lt;div id="steps"&gt; &lt;p&gt;Step 1&lt;/p&gt; &lt;p&gt;Step 2&lt;/p&gt; &lt;p&gt;Step 3&lt;/p&gt; &lt;/div&gt; </code></pre> <p></p> <p>And here is my script:</p> <pre><code>$('#steps &gt; p').on('click' , function(){ $('steps &gt; p').css('background', 'yellow'); });​ </code></pre> <p>Why is my script not running on my website?</p>
0debug
static int xen_pt_msgdata_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, uint16_t *val, uint16_t dev_value, uint16_t valid_mask) { XenPTRegInfo *reg = cfg_entry->reg; XenPTMSI *msi = s->msi; uint16_t writable_mask = 0; uint16_t old_data = cfg_entry->data; uint32_t offset = reg->offset; if (!xen_pt_msi_check_type(offset, msi->flags, DATA)) { XEN_PT_ERR(&s->dev, "the offset does not match the 32/64 bit type!\n"); return -1; } writable_mask = reg->emu_mask & ~reg->ro_mask & valid_mask; cfg_entry->data = XEN_PT_MERGE_VALUE(*val, cfg_entry->data, writable_mask); msi->data = cfg_entry->data; *val = XEN_PT_MERGE_VALUE(*val, dev_value, 0); if (cfg_entry->data != old_data) { if (msi->mapped) { xen_pt_msi_update(s); } } return 0; }
1threat
int vnc_display_password(DisplayState *ds, const char *password) { VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display; if (!vs) { return -EINVAL; } if (!password) { return vnc_display_disable_login(ds); } if (vs->password) { g_free(vs->password); vs->password = NULL; } vs->password = g_strdup(password); if (vs->auth == VNC_AUTH_NONE) { vs->auth = VNC_AUTH_VNC; } return 0; }
1threat
How to connect my image uploader with MySQL database? : <p>I'm trying to make a profile page where the users can upload and update their profile pictures. I already have a functional image uploader but it's not connected with my database. So whenever I upload &amp; refresh, the image resets. I want to know how I can connect my database and store the uploaded image (or it's destination) in my database.</p> <p><strong>HTML Form:</strong></p> <pre><code> &lt;div class="pic"&gt;&lt;div id="imgContainer"&gt; &lt;form enctype="multipart/form-data" action="image_upload_demo_submit.php" method="post" name="image_upload_form" id="image_upload_form"&gt; &lt;div id="imgArea"&gt;&lt;img src="./img/default.jpg"&gt; &lt;div class="progressBar"&gt; &lt;div class="bar"&gt;&lt;/div&gt; &lt;div class="percent"&gt;0%&lt;/div&gt; &lt;/div&gt; &lt;div id="imgChange"&gt;&lt;span&gt;Change Photo&lt;/span&gt; &lt;input type="file" accept="image/*" name="image_upload_file" id="image_upload_file"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt;&lt;/div&gt; </code></pre> <p><strong>Submit.php:</strong></p> <pre><code>&lt;?php include('./functions.php'); /*defined settings - start*/ ini_set("memory_limit", "99M"); ini_set('post_max_size', '20M'); ini_set('max_execution_time', 600); define('IMAGE_SMALL_DIR', './uploades/small/'); define('IMAGE_SMALL_SIZE', 50); define('IMAGE_MEDIUM_DIR', './uploades/medium/'); define('IMAGE_MEDIUM_SIZE', 250); /*defined settings - end*/ if(isset($_FILES['image_upload_file'])){ $output['status']=FALSE; set_time_limit(0); $allowedImageType = array("image/gif", "image/jpeg", "image/pjpeg", "image/png", "image/x-png" ); if ($_FILES['image_upload_file']["error"] &gt; 0) { $output['error']= "Error in File"; } elseif (!in_array($_FILES['image_upload_file']["type"], $allowedImageType)) { $output['error']= "You can only upload JPG, PNG and GIF file"; } elseif (round($_FILES['image_upload_file']["size"] / 1024) &gt; 4096) { $output['error']= "You can upload file size up to 4 MB"; } else { /*create directory with 777 permission if not exist - start*/ createDir(IMAGE_SMALL_DIR); createDir(IMAGE_MEDIUM_DIR); /*create directory with 777 permission if not exist - end*/ $path[0] = $_FILES['image_upload_file']['tmp_name']; $file = pathinfo($_FILES['image_upload_file']['name']); $fileType = $file["extension"]; $desiredExt='jpg'; $fileNameNew = rand(333, 999) . time() . ".$desiredExt"; $path[1] = IMAGE_MEDIUM_DIR . $fileNameNew; $path[2] = IMAGE_SMALL_DIR . $fileNameNew; if (createThumb($path[0], $path[1], $fileType, IMAGE_MEDIUM_SIZE, IMAGE_MEDIUM_SIZE,IMAGE_MEDIUM_SIZE)) { if (createThumb($path[1], $path[2],"$desiredExt", IMAGE_SMALL_SIZE, IMAGE_SMALL_SIZE,IMAGE_SMALL_SIZE)) { $output['status']=TRUE; $output['image_medium']= $path[1]; $output['image_small']= $path[2]; } } } echo json_encode($output); } ?&gt; </code></pre> <p><strong>Functions.php:</strong></p> <pre><code>&lt;?php function createDir($path){ if (!file_exists($path)) { $old_mask = umask(0); mkdir($path, 0777, TRUE); umask($old_mask); } } function createThumb($path1, $path2, $file_type, $new_w, $new_h, $squareSize = ''){ /* read the source image */ $source_image = FALSE; if (preg_match("/jpg|JPG|jpeg|JPEG/", $file_type)) { $source_image = imagecreatefromjpeg($path1); } elseif (preg_match("/png|PNG/", $file_type)) { if (!$source_image = @imagecreatefrompng($path1)) { $source_image = imagecreatefromjpeg($path1); } } elseif (preg_match("/gif|GIF/", $file_type)) { $source_image = imagecreatefromgif($path1); } if ($source_image == FALSE) { $source_image = imagecreatefromjpeg($path1); } $orig_w = imageSX($source_image); $orig_h = imageSY($source_image); if ($orig_w &lt; $new_w &amp;&amp; $orig_h &lt; $new_h) { $desired_width = $orig_w; $desired_height = $orig_h; } else { $scale = min($new_w / $orig_w, $new_h / $orig_h); $desired_width = ceil($scale * $orig_w); $desired_height = ceil($scale * $orig_h); } if ($squareSize != '') { $desired_width = $desired_height = $squareSize; } /* create a new, "virtual" image */ $virtual_image = imagecreatetruecolor($desired_width, $desired_height); // for PNG background white-----------&gt; $kek = imagecolorallocate($virtual_image, 255, 255, 255); imagefill($virtual_image, 0, 0, $kek); if ($squareSize == '') { /* copy source image at a resized size */ imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $orig_w, $orig_h); } else { $wm = $orig_w / $squareSize; $hm = $orig_h / $squareSize; $h_height = $squareSize / 2; $w_height = $squareSize / 2; if ($orig_w &gt; $orig_h) { $adjusted_width = $orig_w / $hm; $half_width = $adjusted_width / 2; $int_width = $half_width - $w_height; imagecopyresampled($virtual_image, $source_image, -$int_width, 0, 0, 0, $adjusted_width, $squareSize, $orig_w, $orig_h); } elseif (($orig_w &lt;= $orig_h)) { $adjusted_height = $orig_h / $wm; $half_height = $adjusted_height / 2; imagecopyresampled($virtual_image, $source_image, 0,0, 0, 0, $squareSize, $adjusted_height, $orig_w, $orig_h); } else { imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $squareSize, $squareSize, $orig_w, $orig_h); } } if (@imagejpeg($virtual_image, $path2, 90)) { imagedestroy($virtual_image); imagedestroy($source_image); return TRUE; } else { return FALSE; } } ?&gt; </code></pre> <p>How do I connect &amp; store the uploaded images for each user. And do I need to create a separate PHP file? Help is really appreciated..</p>
0debug
What is the recommended way to break long if statement? (W504 line break after binary operator) : <p>What is currently the recommended way to break long line of if statement with "and" and "or" operators? </p> <p><strong>1st option</strong> </p> <p>With the style below <a href="https://www.python.org/dev/peps/pep-0008/#maximum-line-length" rel="noreferrer">(which is from PEP8)</a> with flake8 I'm getting warnings: W504 line break after binary operator:</p> <pre><code>if (this_is_one_thing and that_is_another_thing): do_something() </code></pre> <p><strong>2nd option</strong> </p> <pre><code>if (this_is_one_thing and that_is_another_thing): do_something() </code></pre> <p>Now I'm getting the warning W503 line break before binary operator. The second seems to be in line with <a href="https://www.python.org/dev/peps/pep-0008/#should-a-line-break-before-or-after-a-binary-operator" rel="noreferrer">this recommendation from PEP8</a></p> <p>I tried to find answer but I'm still unsure. I think maybe using 2nd option and disabling W503 warning will be a way to deal with this problem?</p>
0debug
react-native .toLocaleString() not working on android : <p>I'm using <code>.toLocaleString()</code> on react-native for my number output. All work on IOS but seems not working on Android. This is normal or? Do I need to use a function for the decimal?</p> <p><a href="https://i.stack.imgur.com/sdA8f.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/sdA8f.jpg" alt="enter image description here"></a></p>
0debug
How can i get rid of Duplacates in this java code? : **How can i make this Code not have any repeating numbers in it?** All i would like to do is make it so that it doesn't output any duplicates in this little block. int[] arr = {5,10,44,2, 44,44,5,10,44,2, 44,44}; int startScan; int index; int minindex; int minValue; for (startScan=0;startScan<(arr.length-1);startScan++){ minindex=startScan; minValue =arr[startScan]; for (index=startScan+1; index<arr.length;index++){ if (arr[index]<minValue){ minValue=arr[index]; minindex=index; } } arr[minindex]=arr[startScan]; arr[startScan]=minValue; } for(int x=0; x<arr.length;x++){ System.out.println(arr[x]);
0debug
Issue With Setting Things Equal to Nullptr : So I'm working on a text-based RPG to keep up my programming knowledge over the summer (I've taken 2 trimesters of C++ so far). Anyways, I've been working on the character's inventory system, and I've run into an issue. So, the inventory is an array of type Item (which I've already made). The default constructor for Item sets it to be an Item "Plain Rock;" but I just want the inventory to be completely empty when it's created. So I thought of a work-around, by, when creating the inventory, setting the address of every spot in the inventory to equal nullptr: Inventory::Inventory() { currentBPSize = 5; backpack = new Item[MAX_BACKPACK_SIZE]; for(int i = 0; i < MAX_BACKPACK_SIZE; i++){ &backpack[i] = nullptr; } } Whenever I run this, however, I get the error "lvalue required as the left operand of the assignment." What am I doing wrong, or is there something I should be doing completely differently? Thanks!
0debug
static int blk_mig_save_bulked_block(Monitor *mon, QEMUFile *f) { int64_t completed_sector_sum = 0; BlkMigDevState *bmds; int progress; int ret = 0; QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) { if (bmds->bulk_completed == 0) { if (mig_save_device_bulk(mon, f, bmds) == 1) { bmds->bulk_completed = 1; } completed_sector_sum += bmds->completed_sectors; ret = 1; break; } else { completed_sector_sum += bmds->completed_sectors; } } progress = completed_sector_sum * 100 / block_mig_state.total_sector_sum; if (progress != block_mig_state.prev_progress) { block_mig_state.prev_progress = progress; qemu_put_be64(f, (progress << BDRV_SECTOR_BITS) | BLK_MIG_FLAG_PROGRESS); monitor_printf(mon, "Completed %d %%\r", progress); monitor_flush(mon); } return ret; }
1threat
PPC_OP(srw) { if (T1 & 0x20) { T0 = 0; } else { T0 = T0 >> T1; } RETURN(); }
1threat
def insert_element(list,element): list = [v for elt in list for v in (element, elt)] return list
0debug
How does Eric Niebler's implementation of std::is_function work? : <p>Last week Eric Niebler <a href="https://twitter.com/ericniebler/status/852192542653329408" rel="noreferrer">tweeted</a> a very compact implementation for the <a href="http://en.cppreference.com/w/cpp/types/is_function" rel="noreferrer"><code>std::is_function</code></a> traits class:</p> <pre><code>#include &lt;type_traits&gt; template&lt;int I&gt; struct priority_tag : priority_tag&lt;I - 1&gt; {}; template&lt;&gt; struct priority_tag&lt;0&gt; {}; // Function types here: template&lt;typename T&gt; char(&amp;is_function_impl_(priority_tag&lt;0&gt;))[1]; // Array types here: template&lt;typename T, typename = decltype((*(T*)0)[0])&gt; char(&amp;is_function_impl_(priority_tag&lt;1&gt;))[2]; // Anything that can be returned from a function here (including // void and reference types): template&lt;typename T, typename = T(*)()&gt; char(&amp;is_function_impl_(priority_tag&lt;2&gt;))[3]; // Classes and unions (including abstract types) here: template&lt;typename T, typename = int T::*&gt; char(&amp;is_function_impl_(priority_tag&lt;3&gt;))[4]; template &lt;typename T&gt; struct is_function : std::integral_constant&lt;bool, sizeof(is_function_impl_&lt;T&gt;(priority_tag&lt;3&gt;{})) == 1&gt; {}; </code></pre> <p>But how does it work?</p>
0debug
static int kvm_get_dirty_pages_log_range(MemoryRegionSection *section, unsigned long *bitmap) { unsigned int i, j; unsigned long page_number, c; hwaddr addr, addr1; unsigned int len = ((section->size / TARGET_PAGE_SIZE) + HOST_LONG_BITS - 1) / HOST_LONG_BITS; unsigned long hpratio = getpagesize() / TARGET_PAGE_SIZE; for (i = 0; i < len; i++) { if (bitmap[i] != 0) { c = leul_to_cpu(bitmap[i]); do { j = ffsl(c) - 1; c &= ~(1ul << j); page_number = (i * HOST_LONG_BITS + j) * hpratio; addr1 = page_number * TARGET_PAGE_SIZE; addr = section->offset_within_region + addr1; memory_region_set_dirty(section->mr, addr, TARGET_PAGE_SIZE * hpratio); } while (c != 0); } } return 0; }
1threat
sql: syntax error sql query : How to fix this issue: SQL Error: ------- `Unknown column 'exdays_relation.exercise_id' in 'on clause'` SQL query: --------- SELECT * FROM `user_days` LEFT JOIN `menu` ON `menu`.`id` = `exdays_relation`.`exercise_id` JOIN `exdays_relation` ON `exdays_relation`.`day_id` = `user_days`.`day_id` WHERE `user_days`.`for_date` LIKE '2016-12-12' ***query relation:*** menu ------- id int(11) PK AUTO_INCREMENT exdays_relation ------------------- exdaysrel_id int(11) PK AUTO_INCREMENT exercise_id int(11) FK from id(menu) day_id int(11) FK from day_id(user_days) user_days ----------------- day_id int(11) PK for_date date
0debug
Why does it take ages to install Pandas on Alpine Linux : <p>I've noticed that installing Pandas and Numpy (it's dependency) in a Docker container using the base OS Alpine vs. CentOS or Debian takes much longer. I created a little test below to demonstrate the time difference. Aside from the few seconds Alpine takes to update and download the build dependencies to install Pandas and Numpy, why does the setup.py take around 70x more time than on Debian install?</p> <p>Is there any way to speed up the install using Alpine as the base image or is there another base image of comparable size to Alpine that is better to use for packages like Pandas and Numpy?</p> <p><strong>Dockerfile.debian</strong></p> <pre><code>FROM python:3.6.4-slim-jessie RUN pip install pandas </code></pre> <p><strong>Build Debian image with Pandas &amp; Numpy:</strong></p> <pre><code>[PandasDockerTest] time docker build -t debian-pandas -f Dockerfile.debian . --no-cache Sending build context to Docker daemon 3.072kB Step 1/2 : FROM python:3.6.4-slim-jessie ---&gt; 43431c5410f3 Step 2/2 : RUN pip install pandas ---&gt; Running in 2e4c030f8051 Collecting pandas Downloading pandas-0.22.0-cp36-cp36m-manylinux1_x86_64.whl (26.2MB) Collecting numpy&gt;=1.9.0 (from pandas) Downloading numpy-1.14.1-cp36-cp36m-manylinux1_x86_64.whl (12.2MB) Collecting pytz&gt;=2011k (from pandas) Downloading pytz-2018.3-py2.py3-none-any.whl (509kB) Collecting python-dateutil&gt;=2 (from pandas) Downloading python_dateutil-2.6.1-py2.py3-none-any.whl (194kB) Collecting six&gt;=1.5 (from python-dateutil&gt;=2-&gt;pandas) Downloading six-1.11.0-py2.py3-none-any.whl Installing collected packages: numpy, pytz, six, python-dateutil, pandas Successfully installed numpy-1.14.1 pandas-0.22.0 python-dateutil-2.6.1 pytz-2018.3 six-1.11.0 Removing intermediate container 2e4c030f8051 ---&gt; a71e1c314897 Successfully built a71e1c314897 Successfully tagged debian-pandas:latest docker build -t debian-pandas -f Dockerfile.debian . --no-cache 0.07s user 0.06s system 0% cpu 13.605 total </code></pre> <p><strong>Dockerfile.alpine</strong></p> <pre><code>FROM python:3.6.4-alpine3.7 RUN apk --update add --no-cache g++ RUN pip install pandas </code></pre> <p><strong>Build Alpine image with Pandas &amp; Numpy:</strong></p> <pre><code>[PandasDockerTest] time docker build -t alpine-pandas -f Dockerfile.alpine . --no-cache Sending build context to Docker daemon 16.9kB Step 1/3 : FROM python:3.6.4-alpine3.7 ---&gt; 4b00a94b6f26 Step 2/3 : RUN apk --update add --no-cache g++ ---&gt; Running in 4b0c32551e3f fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz (1/17) Upgrading musl (1.1.18-r2 -&gt; 1.1.18-r3) (2/17) Installing libgcc (6.4.0-r5) (3/17) Installing libstdc++ (6.4.0-r5) (4/17) Installing binutils-libs (2.28-r3) (5/17) Installing binutils (2.28-r3) (6/17) Installing gmp (6.1.2-r1) (7/17) Installing isl (0.18-r0) (8/17) Installing libgomp (6.4.0-r5) (9/17) Installing libatomic (6.4.0-r5) (10/17) Installing pkgconf (1.3.10-r0) (11/17) Installing mpfr3 (3.1.5-r1) (12/17) Installing mpc1 (1.0.3-r1) (13/17) Installing gcc (6.4.0-r5) (14/17) Installing musl-dev (1.1.18-r3) (15/17) Installing libc-dev (0.7.1-r0) (16/17) Installing g++ (6.4.0-r5) (17/17) Upgrading musl-utils (1.1.18-r2 -&gt; 1.1.18-r3) Executing busybox-1.27.2-r7.trigger OK: 184 MiB in 50 packages Removing intermediate container 4b0c32551e3f ---&gt; be26c3bf4e42 Step 3/3 : RUN pip install pandas ---&gt; Running in 36f6024e5e2d Collecting pandas Downloading pandas-0.22.0.tar.gz (11.3MB) Collecting python-dateutil&gt;=2 (from pandas) Downloading python_dateutil-2.6.1-py2.py3-none-any.whl (194kB) Collecting pytz&gt;=2011k (from pandas) Downloading pytz-2018.3-py2.py3-none-any.whl (509kB) Collecting numpy&gt;=1.9.0 (from pandas) Downloading numpy-1.14.1.zip (4.9MB) Collecting six&gt;=1.5 (from python-dateutil&gt;=2-&gt;pandas) Downloading six-1.11.0-py2.py3-none-any.whl Building wheels for collected packages: pandas, numpy Running setup.py bdist_wheel for pandas: started Running setup.py bdist_wheel for pandas: still running... Running setup.py bdist_wheel for pandas: still running... Running setup.py bdist_wheel for pandas: still running... Running setup.py bdist_wheel for pandas: still running... Running setup.py bdist_wheel for pandas: still running... Running setup.py bdist_wheel for pandas: still running... Running setup.py bdist_wheel for pandas: finished with status 'done' Stored in directory: /root/.cache/pip/wheels/e8/ed/46/0596b51014f3cc49259e52dff9824e1c6fe352048a2656fc92 Running setup.py bdist_wheel for numpy: started Running setup.py bdist_wheel for numpy: still running... Running setup.py bdist_wheel for numpy: still running... Running setup.py bdist_wheel for numpy: still running... Running setup.py bdist_wheel for numpy: finished with status 'done' Stored in directory: /root/.cache/pip/wheels/9d/cd/e1/4d418b16ea662e512349ef193ed9d9ff473af715110798c984 Successfully built pandas numpy Installing collected packages: six, python-dateutil, pytz, numpy, pandas Successfully installed numpy-1.14.1 pandas-0.22.0 python-dateutil-2.6.1 pytz-2018.3 six-1.11.0 Removing intermediate container 36f6024e5e2d ---&gt; a93c59e6a106 Successfully built a93c59e6a106 Successfully tagged alpine-pandas:latest docker build -t alpine-pandas -f Dockerfile.alpine . --no-cache 0.54s user 0.33s system 0% cpu 16:08.47 total </code></pre>
0debug
static void v9fs_clunk(void *opaque) { int err; int32_t fid; size_t offset = 7; V9fsFidState *fidp; V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; pdu_unmarshal(pdu, offset, "d", &fid); fidp = clunk_fid(s, fid); if (fidp == NULL) { err = -ENOENT; goto out_nofid; } fidp->ref++; err = offset; put_fid(pdu, fidp); out_nofid: complete_pdu(s, pdu, err); }
1threat
I need to redirect a page when time become 00.00 : <p>I need to wish a birthday to my friend and so I plan to tell my friend to open a webpage @ 11.55 and when time becomes 12.00 I need to automatically redirect my friend's page to my greeting page and help me to do the task </p>
0debug
def surfacearea_cube(l): surfacearea= 6*l*l return surfacearea
0debug
How to call print() with colorful text to android studio console in flutter : <p>I need a debug output with colorful string. like node.js chalk.</p> <p>I tried to find the packages, but there is no proper package.</p> <p>Thank you.</p>
0debug
static uint64_t pic_ioport_read(void *opaque, target_phys_addr_t addr, unsigned size) { PICCommonState *s = opaque; int ret; if (s->poll) { ret = pic_get_irq(s); if (ret >= 0) { pic_intack(s, ret); ret |= 0x80; } else { ret = 0; } s->poll = 0; } else { if (addr == 0) { if (s->read_reg_select) { ret = s->isr; } else { ret = s->irr; } } else { ret = s->imr; } } DPRINTF("read: addr=0x%02x val=0x%02x\n", addr, ret); return ret; }
1threat
float64 int64_to_float64( int64 a STATUS_PARAM ) { flag zSign; if ( a == 0 ) return 0; if ( a == (sbits64) LIT64( 0x8000000000000000 ) ) { return packFloat64( 1, 0x43E, 0 ); } zSign = ( a < 0 ); return normalizeRoundAndPackFloat64( zSign, 0x43C, zSign ? - a : a STATUS_VAR ); }
1threat
How to define and iterate over map in Jenkinsfile : <p>My knowledge of groovy doesn't go very far beyond what little I know about Jenkinsfiles. I'm trying to figure out if it's possible to have a map defined in a Jenkinsfile that can then be applied in a "for loop" fashion. </p> <p>I have these variables:</p> <pre><code>mymap = { "k1": "v1" "k2": "v2" "k3": "v3" } </code></pre> <p>I have a <code>stage</code> in my Jenkinsfile that looks like this:</p> <pre><code>stage('Build Image') { withCredentials([[&lt;the credentials&gt;]) { sh "make build KEY={k1,k2,k3} VALUE='{v1,v2,v3}'" } </code></pre> <p>Is there a way to make a <code>Build Image</code> stage for each of the pairings in <code>mymap</code>? I haven't had any luck with what I've tried.</p>
0debug
how to get value of an input field with same id in agular4 : This is my form <button (click)="M_add()">Add</button> <tbody id="_tbody"> </tbody> when the add button clicks,it will create input feild var tbody = document.getElementById("_tbody"); var row = document.createElement("tr"); var col = document.createElement("td"); var col_index = document.createElement("input"); col_index.setAttribute("class", "index"); col_index.setAttribute("id", "index"); row.appendChild(col_index); tbody.appendChild(row); i need to retrieve value from each input feild,how to get it ?
0debug
Golang, importing packages from Github requests me to remember the Github URL? : <p>I'm very new to Golang. I see that in Golang you can import packages directly from Github like:</p> <pre><code>import "github.com/MakeNowJust/heredoc" </code></pre> <p>Does that mean I have to remember this URL in order to use this package? IMHO this is not cool. What if later the author of the package removed it or changed the URL? Any ideas?</p>
0debug
sql exeption was not handled by user code : if (Page.IsValid) { DataSet.UsersDataTable oUserDataTable = new DataSet.UsersDataTable(); DataSetTableAdapters.UsersTableAdapter oUserTableAdapter = new DataSetTableAdapters.UsersTableAdapter(); oUserTableAdapter.FillUserByUserName(oUserDataTable, txtUserName.Text); if (oUserDataTable.Count!=1) { string strErrorMessage = "UserName Or Password Is Not Correct ! Please Try Again . . . "; DisplayErrorMessage(strErrorMessage); return; } DataSet.UsersRow oUserRow = oUserDataTable[0]; if (string.Compare(oUserRow.Password.Trim(),txtPassword.Text.Trim(),false)!=0) { string strErrorMessage = "UserName Or Password Is Not Correct ! Please Try Again . . . "; DisplayErrorMessage(strErrorMessage); return; } if (oUserRow.IsUserActive==false) { string strInformationMessage = string.Format("Dear {0} You Should Not Login At This Time , Please Contact Support",txtUserName.Text); DisplayInformationMessage(strInformationMessage); return; } Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
0debug
Content not from webpack is served from /foo : <p>I just can't start this server, I read the <a href="https://webpack.js.org/configuration/dev-server/#devserver" rel="noreferrer">webpack-dev-server docs</a>.</p> <pre><code>devServer: { contentBase: path.join(__dirname, "dist"), compress: true, port: 9000 } </code></pre> <p>The sample code looks simple,but I just can't start this server successfully,no matter what I tried,different folder,it just can't get the <strong>content</strong>!!!Am I missing something? </p> <p>Any help would be great appreciate.</p> <p>Output:</p> <pre><code>Project is running at http://0.0.0.0:8080/ webpack output is served from /assets/ Content not from webpack is served from ~/WebstormProjects/react_back/assets/ </code></pre> <p>My project structure:</p> <pre><code>β”œβ”€β”€ [drwxr-xr-x ] src β”‚Β Β  └── [-rw-r--r-- ] index.js β”œβ”€β”€ [drwxr-xr-x ] public β”‚Β Β  β”œβ”€β”€ [-rw-r--r-- ] index.html β”‚Β Β  β”œβ”€β”€ [drwxr-xr-x ] assets β”‚Β Β  β”‚Β Β  └── [-rw-r--r-- ] bundle.js β”‚Β Β  └── [-rw-r--r-- ] favicon.ico β”œβ”€β”€ [-rw-r--r-- ] package.json β”œβ”€β”€ [-rw-r--r-- ] npm-debug.log β”œβ”€β”€ [-rw-r--r-- ] webpack.config.js </code></pre> <p><strong>package.json</strong></p> <pre><code> "scripts": { "build": "webpack", "dev": "webpack-dev-server --devtool eval" }, </code></pre> <p><strong>webpack.config.js</strong></p> <pre><code>module.exports = { entry: __dirname + "/src/index.js", output: { path: __dirname + "/public", publicPath: "/assets/", filename: "assets/bundle.js", chunkFilename: '[name].js' }, devServer: { contentBase: __dirname + "/assets/", inline: true, host: '0.0.0.0', port: 8080, }, module: { loaders: [ { test: /\.(jpg|jpeg|gif|png|ico)$/, exclude: /node_modules/, loader: 'file-loader?name=[name].[ext]' }, { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader', query: { presets: ["es2016", "react", "env", "stage-2"] } } ] } }; </code></pre> <p><strong>Version:</strong></p> <pre><code>➜ node -v v7.6.0 ➜ webpack-dev-server -v webpack-dev-server 2.4.1 webpack 2.2.1 </code></pre>
0debug
how to reset index pandas dataframe after dropna() pandas dataframe : <p>I"m not sure how to reset index after dropna() </p> <pre><code>df_all = df_all.dropna() df_all.reset_index(drop=True) </code></pre> <p>but after drop row index would skip for example jump from 0,1,2,4 ..</p>
0debug
Define is not defined (ESLint) : <p>I keep getting an ESLint error <code>'define' is not defined. (no-undef)</code>. I believe, I could just define <code>define</code> globally, but shouldn't this be supported natively? </p> <p>A code example using define:</p> <pre><code>define([], function () { // Error here! 'use strict'; .... </code></pre> <p>This is my eslintrc.json:</p> <pre><code>{ "env": { "shared-node-browser": true, "commonjs": true }, "plugins": ["requirejs"], "extends": ["eslint:recommended"], "rules": { "indent": [ "error", "tab" ], "linebreak-style": [ "error", "windows" ], "quotes": [ "error", "single" ], "semi": [ "error", "always" ], "requirejs/no-invalid-define": 2, "requirejs/no-multiple-define": 2, "requirejs/no-named-define": 2, "requirejs/no-commonjs-wrapper": 2, "requirejs/no-object-define": 1 } } </code></pre>
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
Selecting pandas dataframe column by list : <p>in one of my scripts I'm selecting several columns of a dataframe, by a list of the column names. The following code works:</p> <pre><code>data = df[lst] </code></pre> <p>It works fine as long as all elements of the list are included in the dataframe. If that's not the case, it will return the error "'....' not in index".</p> <p>Is there a possibility to still select all columns which column name is included in that list, even if not all elements of the list are included in the dataframe? </p>
0debug
static int mov_write_udta_tag(ByteIOContext *pb, MOVMuxContext *mov, AVFormatContext *s) { ByteIOContext *pb_buf; int i, ret, size; uint8_t *buf; for (i = 0; i < s->nb_streams; i++) if (mov->tracks[i].enc->flags & CODEC_FLAG_BITEXACT) { return 0; } ret = url_open_dyn_buf(&pb_buf); if(ret < 0) return ret; if (mov->mode & MODE_3GP) { mov_write_3gp_udta_tag(pb_buf, s, "perf", "artist"); mov_write_3gp_udta_tag(pb_buf, s, "titl", "title"); mov_write_3gp_udta_tag(pb_buf, s, "auth", "author"); mov_write_3gp_udta_tag(pb_buf, s, "gnre", "genre"); mov_write_3gp_udta_tag(pb_buf, s, "dscp", "comment"); mov_write_3gp_udta_tag(pb_buf, s, "albm", "album"); mov_write_3gp_udta_tag(pb_buf, s, "cprt", "copyright"); mov_write_3gp_udta_tag(pb_buf, s, "yrrc", "date"); } else if (mov->mode == MODE_MOV) { mov_write_string_metadata(s, pb_buf, "\251nam", "title" , 0); mov_write_string_metadata(s, pb_buf, "\251aut", "author" , 0); mov_write_string_metadata(s, pb_buf, "\251alb", "album" , 0); mov_write_string_metadata(s, pb_buf, "\251day", "date" , 0); mov_write_string_tag(pb_buf, "\251enc", LIBAVFORMAT_IDENT, 0, 0); mov_write_string_metadata(s, pb_buf, "\251des", "comment" , 0); mov_write_string_metadata(s, pb_buf, "\251gen", "genre" , 0); mov_write_string_metadata(s, pb_buf, "\251cpy", "copyright" , 0); } else { mov_write_meta_tag(pb_buf, mov, s); } if (s->nb_chapters) mov_write_chpl_tag(pb_buf, s); if ((size = url_close_dyn_buf(pb_buf, &buf)) > 0) { put_be32(pb, size+8); put_tag(pb, "udta"); put_buffer(pb, buf, size); av_free(buf); } return 0; }
1threat
What the difference between virtualbox-guest-dkms and virtualbox-guest-dkms-hwe? : <p>I'm using Ubuntu 18.04 in VirtualBox, after installing guest additions I have a choise between virtualbox-guest-dkms and virtualbox-guest-dkms-hwe. What is the difference between them?</p> <p><img src="https://i.imgur.com/YuxIvUa.png" alt="Ubuntu update manager"></p>
0debug
void cpu_loop (CPUState *env) { int trapnr; target_siginfo_t info; while (1) { trapnr = cpu_alpha_exec (env); switch (trapnr) { case EXCP_RESET: fprintf(stderr, "Reset requested. Exit\n"); exit(1); break; case EXCP_MCHK: fprintf(stderr, "Machine check exception. Exit\n"); exit(1); break; case EXCP_ARITH: fprintf(stderr, "Arithmetic trap.\n"); exit(1); break; case EXCP_HW_INTERRUPT: fprintf(stderr, "External interrupt. Exit\n"); exit(1); break; case EXCP_DFAULT: fprintf(stderr, "MMU data fault\n"); exit(1); break; case EXCP_DTB_MISS_PAL: fprintf(stderr, "MMU data TLB miss in PALcode\n"); exit(1); break; case EXCP_ITB_MISS: fprintf(stderr, "MMU instruction TLB miss\n"); exit(1); break; case EXCP_ITB_ACV: fprintf(stderr, "MMU instruction access violation\n"); exit(1); break; case EXCP_DTB_MISS_NATIVE: fprintf(stderr, "MMU data TLB miss\n"); exit(1); break; case EXCP_UNALIGN: fprintf(stderr, "Unaligned access\n"); exit(1); break; case EXCP_OPCDEC: fprintf(stderr, "Invalid instruction\n"); exit(1); break; case EXCP_FEN: fprintf(stderr, "Floating-point not allowed\n"); exit(1); break; case EXCP_CALL_PAL ... (EXCP_CALL_PALP - 1): call_pal(env, (trapnr >> 6) | 0x80); break; case EXCP_CALL_PALP ... (EXCP_CALL_PALE - 1): fprintf(stderr, "Privileged call to PALcode\n"); exit(1); break; case EXCP_DEBUG: { int sig; sig = gdb_handlesig (env, TARGET_SIGTRAP); if (sig) { info.si_signo = sig; info.si_errno = 0; info.si_code = TARGET_TRAP_BRKPT; queue_signal(env, info.si_signo, &info); } } break; default: printf ("Unhandled trap: 0x%x\n", trapnr); cpu_dump_state(env, stderr, fprintf, 0); exit (1); } process_pending_signals (env); } }
1threat
static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel) { const char *rn = "invalid"; if (sel != 0) check_insn(env, ctx, ISA_MIPS32); switch (reg) { case 0: switch (sel) { case 0: gen_op_mfc0_index(); rn = "Index"; break; case 1: check_mips_mt(env, ctx); gen_op_mfc0_mvpcontrol(); rn = "MVPControl"; break; case 2: check_mips_mt(env, ctx); gen_op_mfc0_mvpconf0(); rn = "MVPConf0"; break; case 3: check_mips_mt(env, ctx); gen_op_mfc0_mvpconf1(); rn = "MVPConf1"; break; default: goto die; } break; case 1: switch (sel) { case 0: gen_op_mfc0_random(); rn = "Random"; break; case 1: check_mips_mt(env, ctx); gen_op_mfc0_vpecontrol(); rn = "VPEControl"; break; case 2: check_mips_mt(env, ctx); gen_op_mfc0_vpeconf0(); rn = "VPEConf0"; break; case 3: check_mips_mt(env, ctx); gen_op_mfc0_vpeconf1(); rn = "VPEConf1"; break; case 4: check_mips_mt(env, ctx); gen_op_mfc0_yqmask(); rn = "YQMask"; break; case 5: check_mips_mt(env, ctx); gen_op_mfc0_vpeschedule(); rn = "VPESchedule"; break; case 6: check_mips_mt(env, ctx); gen_op_mfc0_vpeschefback(); rn = "VPEScheFBack"; break; case 7: check_mips_mt(env, ctx); gen_op_mfc0_vpeopt(); rn = "VPEOpt"; break; default: goto die; } break; case 2: switch (sel) { case 0: gen_op_mfc0_entrylo0(); rn = "EntryLo0"; break; case 1: check_mips_mt(env, ctx); gen_op_mfc0_tcstatus(); rn = "TCStatus"; break; case 2: check_mips_mt(env, ctx); gen_op_mfc0_tcbind(); rn = "TCBind"; break; case 3: check_mips_mt(env, ctx); gen_op_mfc0_tcrestart(); rn = "TCRestart"; break; case 4: check_mips_mt(env, ctx); gen_op_mfc0_tchalt(); rn = "TCHalt"; break; case 5: check_mips_mt(env, ctx); gen_op_mfc0_tccontext(); rn = "TCContext"; break; case 6: check_mips_mt(env, ctx); gen_op_mfc0_tcschedule(); rn = "TCSchedule"; break; case 7: check_mips_mt(env, ctx); gen_op_mfc0_tcschefback(); rn = "TCScheFBack"; break; default: goto die; } break; case 3: switch (sel) { case 0: gen_op_mfc0_entrylo1(); rn = "EntryLo1"; break; default: goto die; } break; case 4: switch (sel) { case 0: gen_op_mfc0_context(); rn = "Context"; break; case 1: rn = "ContextConfig"; default: goto die; } break; case 5: switch (sel) { case 0: gen_op_mfc0_pagemask(); rn = "PageMask"; break; case 1: check_insn(env, ctx, ISA_MIPS32R2); gen_op_mfc0_pagegrain(); rn = "PageGrain"; break; default: goto die; } break; case 6: switch (sel) { case 0: gen_op_mfc0_wired(); rn = "Wired"; break; case 1: check_insn(env, ctx, ISA_MIPS32R2); gen_op_mfc0_srsconf0(); rn = "SRSConf0"; break; case 2: check_insn(env, ctx, ISA_MIPS32R2); gen_op_mfc0_srsconf1(); rn = "SRSConf1"; break; case 3: check_insn(env, ctx, ISA_MIPS32R2); gen_op_mfc0_srsconf2(); rn = "SRSConf2"; break; case 4: check_insn(env, ctx, ISA_MIPS32R2); gen_op_mfc0_srsconf3(); rn = "SRSConf3"; break; case 5: check_insn(env, ctx, ISA_MIPS32R2); gen_op_mfc0_srsconf4(); rn = "SRSConf4"; break; default: goto die; } break; case 7: switch (sel) { case 0: check_insn(env, ctx, ISA_MIPS32R2); gen_op_mfc0_hwrena(); rn = "HWREna"; break; default: goto die; } break; case 8: switch (sel) { case 0: gen_op_mfc0_badvaddr(); rn = "BadVaddr"; break; default: goto die; } break; case 9: switch (sel) { case 0: gen_op_mfc0_count(); rn = "Count"; break; default: goto die; } break; case 10: switch (sel) { case 0: gen_op_mfc0_entryhi(); rn = "EntryHi"; break; default: goto die; } break; case 11: switch (sel) { case 0: gen_op_mfc0_compare(); rn = "Compare"; break; default: goto die; } break; case 12: switch (sel) { case 0: gen_op_mfc0_status(); rn = "Status"; break; case 1: check_insn(env, ctx, ISA_MIPS32R2); gen_op_mfc0_intctl(); rn = "IntCtl"; break; case 2: check_insn(env, ctx, ISA_MIPS32R2); gen_op_mfc0_srsctl(); rn = "SRSCtl"; break; case 3: check_insn(env, ctx, ISA_MIPS32R2); gen_op_mfc0_srsmap(); rn = "SRSMap"; break; default: goto die; } break; case 13: switch (sel) { case 0: gen_op_mfc0_cause(); rn = "Cause"; break; default: goto die; } break; case 14: switch (sel) { case 0: gen_op_mfc0_epc(); rn = "EPC"; break; default: goto die; } break; case 15: switch (sel) { case 0: gen_op_mfc0_prid(); rn = "PRid"; break; case 1: check_insn(env, ctx, ISA_MIPS32R2); gen_op_mfc0_ebase(); rn = "EBase"; break; default: goto die; } break; case 16: switch (sel) { case 0: gen_op_mfc0_config0(); rn = "Config"; break; case 1: gen_op_mfc0_config1(); rn = "Config1"; break; case 2: gen_op_mfc0_config2(); rn = "Config2"; break; case 3: gen_op_mfc0_config3(); rn = "Config3"; break; case 6: gen_op_mfc0_config6(); rn = "Config6"; break; case 7: gen_op_mfc0_config7(); rn = "Config7"; break; default: goto die; } break; case 17: switch (sel) { case 0: gen_op_mfc0_lladdr(); rn = "LLAddr"; break; default: goto die; } break; case 18: switch (sel) { case 0 ... 7: gen_op_mfc0_watchlo(sel); rn = "WatchLo"; break; default: goto die; } break; case 19: switch (sel) { case 0 ...7: gen_op_mfc0_watchhi(sel); rn = "WatchHi"; break; default: goto die; } break; case 20: switch (sel) { case 0: #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64) check_insn(env, ctx, ISA_MIPS3); gen_op_mfc0_xcontext(); rn = "XContext"; break; #endif default: goto die; } break; case 21: switch (sel) { case 0: gen_op_mfc0_framemask(); rn = "Framemask"; break; default: goto die; } break; case 22: rn = "'Diagnostic"; break; case 23: switch (sel) { case 0: gen_op_mfc0_debug(); rn = "Debug"; break; case 1: rn = "TraceControl"; case 2: rn = "TraceControl2"; case 3: rn = "UserTraceData"; case 4: rn = "TraceBPC"; default: goto die; } break; case 24: switch (sel) { case 0: gen_op_mfc0_depc(); rn = "DEPC"; break; default: goto die; } break; case 25: switch (sel) { case 0: gen_op_mfc0_performance0(); rn = "Performance0"; break; case 1: rn = "Performance1"; case 2: rn = "Performance2"; case 3: rn = "Performance3"; case 4: rn = "Performance4"; case 5: rn = "Performance5"; case 6: rn = "Performance6"; case 7: rn = "Performance7"; default: goto die; } break; case 26: rn = "ECC"; break; case 27: switch (sel) { case 0 ... 3: rn = "CacheErr"; break; default: goto die; } break; case 28: switch (sel) { case 0: case 2: case 4: case 6: gen_op_mfc0_taglo(); rn = "TagLo"; break; case 1: case 3: case 5: case 7: gen_op_mfc0_datalo(); rn = "DataLo"; break; default: goto die; } break; case 29: switch (sel) { case 0: case 2: case 4: case 6: gen_op_mfc0_taghi(); rn = "TagHi"; break; case 1: case 3: case 5: case 7: gen_op_mfc0_datahi(); rn = "DataHi"; break; default: goto die; } break; case 30: switch (sel) { case 0: gen_op_mfc0_errorepc(); rn = "ErrorEPC"; break; default: goto die; } break; case 31: switch (sel) { case 0: gen_op_mfc0_desave(); rn = "DESAVE"; break; default: goto die; } break; default: goto die; } #if defined MIPS_DEBUG_DISAS if (loglevel & CPU_LOG_TB_IN_ASM) { fprintf(logfile, "mfc0 %s (reg %d sel %d)\n", rn, reg, sel); } #endif return; die: #if defined MIPS_DEBUG_DISAS if (loglevel & CPU_LOG_TB_IN_ASM) { fprintf(logfile, "mfc0 %s (reg %d sel %d)\n", rn, reg, sel); } #endif generate_exception(ctx, EXCP_RI); }
1threat
undefined method `toggle!' for #:ActiveRecord_AssociationRelation: : I've just got this problem in my controller ,and I don't understand what's going on. It returns me undefined method `toggle!' for Like::ActiveRecord_AssociationRelation: Or for my create action every thing works but not with the update action. This is a basic like controller to like and unlike an event,someone and so one. class LikesController < ApplicationController before_action :authenticate_user! def create @project=Project.find(params[:project_id]) @like= @project.likes.where(user:current_user).first_or_initialize( name:current_user.first_name) @like.toggle(:heart) @like.save Notification.create(user:current_user, user_name: current_user.first_name, action:'like', recipient:@project.subject) redirect_to project_path(@project) end def update @project=Project.find(params[:project_id]) @like= @project.likes.where(user:current_user) @like.toggle(:heart) @like.save Notification.create(user:current_user, user_name: current_user.first_name, action:'Unlike', recipient:@project.subject) redirect_to project_path(@project) end end
0debug
Swift Decodable json heterogenous array : I have gone through a couple of questions and answers here on SO, and even though they look similar to my question they dont quiet address my issue, as I have tried a buch of them and yet it is not working. here is my json and the method I have tried and I keep getting an error of "The data couldn’t be read because it isn’t in the correct format." { "status": 1, "errorMsg": "success", "data": [ { "id": null, "subMenuId": null, "type": "Coming Feat", "data": { "link": "/google.com", "title": "Google", "shortDescription": "This is fun", "imageUrl": "", "openInNewWindow": false }, "datas": null, "component": null }, { "id": "wdub208t2ghf0b", "subMenuId": "39g3hvb83hb98hv", "type": "GoingEvent", "data": { "eventId": "983gv83hv8hv38", "sessionId": null, "title": "Fest", "iconMarker": "http://google.com/sites.png", "isPaid": false, "startDT": "2018-07-18T16:00:00Z", "endDT": "2018-10-31T22:00:00Z", "subTitle": null, "startDate": "Oct, 2018", "endDate": "Oct, 2018", "openTime": "04:00 PM", "closeTime": "10:00 PM", "thumbnail": "https://static.visit.com/estival23.jpg", "verticalFeaturedImageUrl": "", "horizontalImageUrl": "", "categoryTitle": "Celebration", "eventCategories": [ "394bf3w9fbv93v8", "dhvbwuehv80" ], "locations": [ { "uniqueName": "fest", "title": "Got if", "area": "", "region": "Put it", "latitude": 67.14517, "longitude": 78.797733, "distance": "N/A", "startDate": "2018-07-18T16:00:00", "endDate": "2018-07-27T22:00:00", "distancevalue": 0, "duration": "N/A", "durationValue": 0, "valid": true, "hasSet": false } ], "prices": null }, "datas": null, "component": null } ] } class FeatureData: Decodable { var link: String? var title: String? var shortDescription: String? var imageUrl: String? enum CodingKeys: String, CodingKey { case link case title case shortDescription case imageUrl } required init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) link = try container.decode(String.self, forKey: .link) title = try container.decode(String.self, forKey: .title) shortDescription = try container.decode(String.self, forKey: .shortDescription) imageUrl = try container.decode(String.self, forKey: .imageUrl) } init() { } } class FeedFeature: Decodable { var id: String? var subMenuId: String? var type: String? var data = HomeFeedFeatureData() enum Codingkeys: String, CodingKey { case id case subMenuId case type case data } required init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: Codingkeys.self) id = try container.decode(String.self, forKey: .id) subMenuId = try container.decode(String.self, forKey: .subMenuId) type = try container.decode(String.self, forKey: .type) data = try container.decode(HomeFeedFeatureData.self, forKey: .data) } init() { } } class EventCalendar: Decodable { // MARK: Properties var eventId: String = "" var sessionId: String = "" var title: String = "" var iconMarker: String? var isPaid: Bool = false var startDT: String = "" var endDT: String = "" var subTitle: String = "" var startDate: String = "" var endDate: String = "" var openTime: String = "" var closeTime: String = "" var thumbnail: String = "" var locations: [EventLocation] = [] var prices: [Price]? var categoryTitle: String = "" var isLoadingCell: Bool = false var isSelected: Bool = false enum CodingKeys: String, CodingKey { case eventId = "eventId" case sessionId = "sessionId" case title = "title" case iconMarker = "iconMarker" case isPaid = "isPaid" case startDT = "startDT" case endDT = "endDT" case subTitle = "subTitle" case startDate = "startDate" case endDate = "endDate" case openTime = "openTime" case closeTime = "closeTime" case thumbnail = "thumbnail" case locations = "locations" case prices = "prices" case categoryTitle = "categoryTitle" } init() {} // MARK: Methods required init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) eventId = try container.decode(String.self, forKey: .eventId) sessionId = try container.decodeIfPresent(String.self, forKey: .sessionId) ?? "" title = try container.decodeIfPresent(String.self, forKey: .title) ?? "" iconMarker = try container.decodeIfPresent(String.self, forKey: .iconMarker) ?? "" isPaid = try container.decodeIfPresent(Bool.self, forKey: .isPaid) ?? false startDT = try container.decodeIfPresent(String.self, forKey: .startDT) ?? "" endDT = try container.decodeIfPresent(String.self, forKey: .endDT) ?? "" subTitle = try container.decodeIfPresent(String.self, forKey: .subTitle) ?? "" startDate = try container.decodeIfPresent(String.self, forKey: .startDate) ?? "" endDate = try container.decodeIfPresent(String.self, forKey: .endDate) ?? "" openTime = try container.decodeIfPresent(String.self, forKey: .openTime) ?? "" closeTime = try container.decodeIfPresent(String.self, forKey: .closeTime) ?? "" thumbnail = try container.decodeIfPresent(String.self, forKey: .thumbnail) ?? "" locations = try container.decodeIfPresent([EventLocation].self, forKey: .locations) ?? [] categoryTitle = try container.decodeIfPresent(String.self, forKey: .categoryTitle) ?? "" if let tempPrice = try container.decode([Price]?.self, forKey: .prices) { var uniquePrices: [Price] = [] for price in tempPrice { if !uniquePrices.contains(where: { (checkPrice) -> Bool in checkPrice.priceInfo == price.priceInfo && checkPrice.value == price.value && checkPrice.currencyCode == price.currencyCode }), price.priceInfo.count > 0 && price.value.count > 0 && price.currencyCode.count > 0 && price.bookingUrl.count > 0 { // Filter for 0 value prices if let priceValue = Double(price.value), priceValue > 0 { uniquePrices.append(price) } } } prices = uniquePrices } isSelected = BookMarkManager.shared.isFavoriteItem(by: eventId) } }
0debug
An item with the same key has already been added - dictionary call value c# : <p>i've this error when i call the value from dictionary, but i don't see the error. my target is get index with value from dictionary.</p> <p>any solution ?</p> <p>my error: </p> <blockquote> <p>An item with the same key has already been added.</p> </blockquote> <p>my dictionaryclass</p> <pre><code>public static class DictionaryParamiters { public static Dictionary&lt;int, String&gt; languagesDictionary = new Dictionary&lt;int, String&gt; { { 0, "ITA" }, { 1, "ENG" }, { 2, "FRA" }, { 3, "SPA" }, { 4, "DEU" } }; public static Dictionary&lt;int, String&gt; modelDictionary = new Dictionary&lt;int, String&gt; { { 0, "IMX BT" }, { 1, "IMX B" }, { 2, "MMX BT" }, { 3, "MMX B" }, { 4, "IMX BT (no logo)" }, { 5, "IMX B (no logo)" } }; public static Dictionary&lt;int, String&gt; batteryDictionary = new Dictionary&lt;int, String&gt; { { 0, "GEL" }, { 1, "WET" }, { 2, "XFC" }, { 3, "GEL1" }, { 4, "WET1" } }; public static Dictionary&lt;int, String&gt; batteryMMGDictionary = new Dictionary&lt;int, String&gt; { { 0, "PB" }, { 1, "GEL" }, { 2, "XFC" }, { 3, "PB1" }, { 4, "GEL1" }, { 5, "CUSTOM" } }; public static Dictionary&lt;int, String&gt; partialHurmeterdisplayDictionary = new Dictionary&lt;int, String&gt; { { 0, "KEY" }, { 1, "TR" }, { 2, "BR" }, { 3, "VAC" } }; public static Dictionary&lt;int, String&gt; resetPartialHourmeterDictionary = new Dictionary&lt;int, String&gt; { { 0, "NO" }, { 1, "KEY" }, { 2, "TR" }, { 3, "BR" }, { 3, "VAC" }, { 3, "ALL" } }; public static Dictionary&lt;int, String&gt; resetMainHourmeterDictionary = new Dictionary&lt;int, String&gt; { { 0, "NO" }, { 1, "KEY" }, { 2, "TR" }, { 3, "BR" }, { 3, "VAC" }, { 3, "ALL" } }; public static Dictionary&lt;int, String&gt; serviceWarningCountDictionary = new Dictionary&lt;int, String&gt; { { 0, "KEY" }, { 1, "TR" }, { 2, "WORK" } }; public static Dictionary&lt;int, String&gt; noyesDictionary = new Dictionary&lt;int, String&gt; { { 0, "NO" }, { 1, "YES" } }; public static Dictionary&lt;int, String&gt; displayCntDictionary = new Dictionary&lt;int, String&gt; { { 0, "KEY" }, { 1, "TRACTION" } }; public static Dictionary&lt;int, String&gt; zerooneDictionary = new Dictionary&lt;int, String&gt; { { 0, "0" }, { 1, "1" } }; public static Dictionary&lt;int, String&gt; baseversionDictionary = new Dictionary&lt;int, String&gt; { { 0, "RULLO" }, { 1, "DISCO" }, { 2, "ORBITALE" } }; public static Dictionary&lt;int, String&gt; modelMMGOPLUSDictionary = new Dictionary&lt;int, String&gt; { { 0, "MMG" }, { 1, "PLUS" } }; } </code></pre> <p>when i call</p> <pre><code>if (tmp.PMC_UM == "") { string valore = String.Empty; //devo prendere la x ed estrarla dal dizionario per stampare le stringhe #region VERIFICO LE STRINGHE E LE PRELEVO DAI DICTIONARY if (tmp.PMC_Descrizione == "Language") { valore = DictionaryParamiters.languagesDictionary[(int)x]; } if (tmp.PMC_Descrizione == "Model" &amp;&amp; DataFile.instance.PMC_SUB_Tipo_Click == null) { valore = DictionaryParamiters.modelDictionary[(int)x]; } //if (tmp.PMC_Descrizione == "Model" &amp;&amp; DataFile.instance.PMC_SUB_Tipo_Click != null) //{ // valore = DictionaryParamiters.modelMMGOPLUSDictionary[(int)x]; //} if (tmp.PMC_Descrizione == "Rst Cnthr"/* || tmp.PMC_Descrizione == "Rst Main Cnthr" || tmp.PMC_Descrizione == "Side brush" || tmp.PMC_Descrizione == "Daylight Enable" || tmp.PMC_Descrizione == "Daylight Enable" || tmp.PMC_Descrizione == "Worklight Enable " || tmp.PMC_Descrizione == "Dosing system" || tmp.PMC_Descrizione == "Recycle" || tmp.PMC_Descrizione == "Anticollision" || tmp.PMC_Descrizione == "Rear camera" || tmp.PMC_Descrizione == "Manual Op. Enable" || tmp.PMC_Descrizione == "Zone Op. Enable" || tmp.PMC_Descrizione == "Password Enable: User" || tmp.PMC_Descrizione == "Password Enable: PIN"*/) { valore = DictionaryParamiters.noyesDictionary[(int)x]; } if (tmp.PMC_Descrizione == "Battery") { valore = DictionaryParamiters.batteryDictionary[(int)x]; } if (tmp.PMC_Descrizione == "Battery Type") { valore = DictionaryParamiters.batteryMMGDictionary[(int)x]; } if (tmp.PMC_Descrizione == "Display Cnt") { valore = DictionaryParamiters.displayCntDictionary[(int)x]; } if (tmp.PMC_Descrizione == "Base version") { valore = DictionaryParamiters.baseversionDictionary[(int)x]; } if (tmp.PMC_Descrizione == "Partial Hurmeter display") { valore = DictionaryParamiters.partialHurmeterdisplayDictionary[(int)x]; } if (tmp.PMC_Descrizione == "Reset Partial Hourmeter") { valore = DictionaryParamiters.resetPartialHourmeterDictionary[(int)x]; } if (tmp.PMC_Descrizione == "Reset Main Hourmeter") { valore = DictionaryParamiters.resetMainHourmeterDictionary[(int)x]; } if (tmp.PMC_Descrizione == "Service Warning Count") { valore = DictionaryParamiters.serviceWarningCountDictionary[(int)x]; } #endregion par.ValoreSettatoOra = valore; } </code></pre> <p>i'dont find duplicate value... :(</p>
0debug
UIContentSizeCategoryDidChangeNotification not working on simulator iOS 9.3, does work on device : <p>I have an observer for UIContentSizeCategoryDidChangeNotification that gets triggerd when a user changes the font-size under settings -> accessibility.</p> <pre><code> NSNotificationCenter.defaultCenter().addObserver(self, selector: "preferredContentSizeChanged:", name: UIContentSizeCategoryDidChangeNotification, object: nil) </code></pre> <p>I've never experienced any problems with this before, but now i am having problems with it on the iphone simulator iOS 9.3. It works however on a real device with iOS 9.3.</p> <p>The simulator returns </p> <pre><code>bogus value for UIPreferredContentSizeCategoryName: (null) </code></pre> <p>Has anyone else experienced the same problem? </p>
0debug
Why SKlearn outperform WEKA in predicting using a RandomForest model? : I have this [dataset][1], and I'm using SKlearn to generate a random forest model as follows: from sklearn.ensemble import RandomForestClassifier as RandomForest from sklearn.cross_validation import cross_val_score, cross_val_predict import pandas as pd import numpy as np df = pd.read_csv('trainingSetExample.csv') X_train = df.iloc[:, df.columns != 'label'] y_train = df.ix[:]['label'] clf = RandomForest() print np.mean(cross_val_score(clf, X_train, y_train, cv=10)) print 'precision', np.mean(cross_val_score(clf, X_train, y_train, cv=10, scoring='precision_macro')) Accuracy and precision are both 0.99, but when I use WEKA randomforest, accuracy and precision are both 0.95. It looks like the default values of the parameters for both is the same, in addition, I tried WEKA with 10000 iterations instead of 100 and it didn't improve. Why are the results that much different? [1]: https://drive.google.com/file/d/1tS7BGQmRkbw3XREZGWET9XMJPfpxLIXW/view?usp=sharing
0debug
angular 6 warning for using formControlName and ngModel : <p>I recently upgraded the angular version to 6-rc. I got following warning </p> <blockquote> <p>It looks like you're using ngModel on the same form field as formControlName. Support for using the ngModel input property and ngModelChange event with reactive form directives has been deprecated in Angular v6 and will be removed in Angular v7</p> <p>For more information on this, see our API docs here: <a href="https://angular.io/api/forms/FormControlName#use-with-ngmodel" rel="noreferrer">https://angular.io/api/forms/FormControlName#use-with-ngmodel</a></p> </blockquote> <p>What does it say exactly? the link does not have any fragment for <code>#use-with-ngmodel</code></p> <p>I guess I need to remove <code>ngModel</code> and use formGroup as my data binding object. </p>
0debug
int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, int64_t pos_min, int64_t pos_max, int64_t pos_limit, int64_t ts_min, int64_t ts_max, int flags, int64_t *ts_ret, int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )) { int64_t pos, ts; int64_t start_pos, filesize; int no_change; av_dlog(s, "gen_seek: %d %s\n", stream_index, av_ts2str(target_ts)); if(ts_min == AV_NOPTS_VALUE){ pos_min = s->data_offset; ts_min = ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp); if (ts_min == AV_NOPTS_VALUE) return -1; } if(ts_min >= target_ts){ *ts_ret= ts_min; return pos_min; } if(ts_max == AV_NOPTS_VALUE){ int step= 1024; filesize = avio_size(s->pb); pos_max = filesize - 1; do{ pos_max = FFMAX(0, pos_max - step); ts_max = ff_read_timestamp(s, stream_index, &pos_max, pos_max + step, read_timestamp); step += step; }while(ts_max == AV_NOPTS_VALUE && pos_max > 0); if (ts_max == AV_NOPTS_VALUE) return -1; for(;;){ int64_t tmp_pos= pos_max + 1; int64_t tmp_ts= ff_read_timestamp(s, stream_index, &tmp_pos, INT64_MAX, read_timestamp); if(tmp_ts == AV_NOPTS_VALUE) break; ts_max= tmp_ts; pos_max= tmp_pos; if(tmp_pos >= filesize) break; } pos_limit= pos_max; } if(ts_max <= target_ts){ *ts_ret= ts_max; return pos_max; } if(ts_min > ts_max){ return -1; }else if(ts_min == ts_max){ pos_limit= pos_min; } no_change=0; while (pos_min < pos_limit) { av_dlog(s, "pos_min=0x%"PRIx64" pos_max=0x%"PRIx64" dts_min=%s dts_max=%s\n", pos_min, pos_max, av_ts2str(ts_min), av_ts2str(ts_max)); assert(pos_limit <= pos_max); if(no_change==0){ int64_t approximate_keyframe_distance= pos_max - pos_limit; pos = av_rescale(target_ts - ts_min, pos_max - pos_min, ts_max - ts_min) + pos_min - approximate_keyframe_distance; }else if(no_change==1){ pos = (pos_min + pos_limit)>>1; }else{ pos=pos_min; } if(pos <= pos_min) pos= pos_min + 1; else if(pos > pos_limit) pos= pos_limit; start_pos= pos; ts = ff_read_timestamp(s, stream_index, &pos, INT64_MAX, read_timestamp); if(pos == pos_max) no_change++; else no_change=0; av_dlog(s, "%"PRId64" %"PRId64" %"PRId64" / %s %s %s target:%s limit:%"PRId64" start:%"PRId64" noc:%d\n", pos_min, pos, pos_max, av_ts2str(ts_min), av_ts2str(ts), av_ts2str(ts_max), av_ts2str(target_ts), pos_limit, start_pos, no_change); if(ts == AV_NOPTS_VALUE){ av_log(s, AV_LOG_ERROR, "read_timestamp() failed in the middle\n"); return -1; } assert(ts != AV_NOPTS_VALUE); if (target_ts <= ts) { pos_limit = start_pos - 1; pos_max = pos; ts_max = ts; } if (target_ts >= ts) { pos_min = pos; ts_min = ts; } } pos = (flags & AVSEEK_FLAG_BACKWARD) ? pos_min : pos_max; ts = (flags & AVSEEK_FLAG_BACKWARD) ? ts_min : ts_max; #if 0 pos_min = pos; ts_min = ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp); pos_min++; ts_max = ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp); av_dlog(s, "pos=0x%"PRIx64" %s<=%s<=%s\n", pos, av_ts2str(ts_min), av_ts2str(target_ts), av_ts2str(ts_max)); #endif *ts_ret= ts; return pos; }
1threat
VBA: loop through data in column A if exists then paste new row over existing, if it does not exist then paste at bottom of rows : Sheet 1 holds data columns A:L and needs existing rows updated and new rows added at bottom. Sheet 2 gets updates of only new data or changed data and is formatted the same as sheet 1. it gets cleared after sheet 1 is updated. In column A is a work order number. I need a code to run in sheet 2, that updates sheet a 1 based on the following criteria. Loop though sheet 1 column A, if value in column A already exists update that row with new data, if value in column A does not exist paste row at bottom of sheet 1
0debug
Imgur delete anonymous upload (Greenshot) : <p>Need your help... thanks to Greenshot a missclick is sufficient to post a picture online to Imgur. (I did...and now I want to delete it) the picture has been posted using anonymous mode.</p> <p>Because I didn't post it manually I do not have the delete link, but I have the deleteHash (15 alphanum-character).</p> <p>I know there is formular to ask to delete the picture. But I would like to delete it myself.</p> <p>In the plugin history I found a delete button which tell me the picture has been deleted from Imgur but the picture is still there.</p> <p>I tried this : <a href="http://imgur.com/delete/ABCDEFghi01abcd" rel="noreferrer">http://imgur.com/delete/ABCDEFghi01abcd</a> but its tells me "This isn't a valid image link! Go on, get out of here!"</p> <p>I tried this :</p> <pre><code> &lt;form action="https://api.imgur.com/3/image/ABCDEFghi01abcd" method="DELETE &lt;p&gt;&lt;input type="submit" value="OK"&gt;&lt;/p&gt; &lt;/form&gt; </code></pre> <p>but I got this : </p> <pre><code>{"data":{"error":"Authentication required","request":"\/3\/image\/ABCDEFghi01abcd","method":"GET"},"success":false,"status":401} </code></pre> <p>(BTW how do we send a DELETE method ? it seems ignored and sent a GET instead...)</p> <p>maybe the deleteHash code given by Greenshot is wrong ? </p> <p>Any idea ? </p>
0debug
static inline void scale_mv(AVSContext *h, int *d_x, int *d_y, cavs_vector *src, int distp) { int den = h->scale_den[FFMAX(src->ref, 0)]; *d_x = (src->x * distp * den + 256 + FF_SIGNBIT(src->x)) >> 9; *d_y = (src->y * distp * den + 256 + FF_SIGNBIT(src->y)) >> 9; }
1threat
static int v9fs_synth_utimensat(FsContext *fs_ctx, V9fsPath *path, const struct timespec *buf) { errno = EPERM; return 0; }
1threat
Error:NullPointerException when put button.setOnclickListener in onResponse method : <p>When i click my button in my activity, it will stop and show an error like this :</p> <pre><code>Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference </code></pre> <p>In my activity, i put button.setOnclickListener in onResponse() method from Response.Listener. I do this because i want to get the data from JSONObject and use that data when i click my button.</p> <p>Sorry, I'm not too fluent in English :)</p> <p>My activity code:</p> <pre><code>public class MenuDaftarNilai2 extends AppCompatActivity { TextView tvMatkulDN, tvKlpDN, tvMhsDN; Button bUasDN; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_menu_daftar_nilai2); tvMatkulDN = (TextView) findViewById(R.id.tvMatkulDN) ; tvKlpDN = (TextView) findViewById(R.id.tvKlpDN) ; tvMhsDN = (TextView) findViewById(R.id.tvMhsDN) ; bUasDN = (Button) findViewById(R.id.bUasDN) ; Intent intent = getIntent(); final String nama_matkul = intent.getStringExtra("nama_matkul"); final String nama_klp = intent.getStringExtra("nama_klp"); final String nama_mhs = intent.getStringExtra("nama_mhs"); tvMatkulDN.setText(nama_matkul); tvKlpDN.setText(nama_klp); tvMhsDN.setText(nama_mhs); Response.Listener responseListener1 = new Response.Listener&lt;String&gt;() { @Override public void onResponse(String response) { try { JSONObject jsonResponse = new JSONObject(response); final String nilai_uas = jsonResponse.getString("nilai_uas"); final String id_uas = jsonResponse.getString("id_uas"); bUasDN.setText("Nilai Uas : " + nilai_uas); bUasDN.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(MenuDaftarNilai2.this, EditUas.class); intent.putExtra("nilai_uas", nilai_uas); intent.putExtra("nama_matkul", nama_matkul); intent.putExtra("nama_klp", nama_klp); intent.putExtra("nama_mhs", nama_mhs); intent.putExtra("id_uas", id_uas); MenuDaftarNilai2.this.startActivity(intent); finish(); } }); }catch (JSONException e) { e.printStackTrace(); } } }; ResponUas resUas = new ResponUas(nama_klp,nama_mhs, responseListener1); RequestQueue queue1 = Volley.newRequestQueue(MenuDaftarNilai2.this); queue1.add(resUas); </code></pre> <p>My XML code:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".LoginAsis.MenuAsisten.MenuDaftarNilai.MenuDaftarNilai2" android:background="#ad4f4f"&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Nama Mata Kuliah" android:id="@+id/textView54" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:textColor="#ffffff" /&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Nama Kelompok" android:id="@+id/textView58" android:layout_alignParentStart="true" android:layout_below="@+id/textView54" android:layout_alignParentLeft="true" android:textColor="#ffffff" /&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Nama Mahasiswa" android:id="@+id/textView59" android:layout_alignParentStart="true" android:layout_below="@+id/textView58" android:layout_alignParentLeft="true" android:textColor="#ffffff" /&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=":" android:id="@+id/textView60" android:textColor="#ffffff" android:layout_alignParentTop="true" android:layout_alignLeft="@+id/textView61" android:layout_alignStart="@+id/textView61" /&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=":" android:id="@+id/textView61" android:textColor="#ffffff" android:layout_below="@+id/textView60" android:layout_alignLeft="@+id/textView62" android:layout_alignStart="@+id/textView62" /&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=":" android:id="@+id/textView62" android:textColor="#ffffff" android:layout_marginLeft="68dp" android:layout_marginStart="40dp" android:layout_below="@+id/textView61" android:layout_toRightOf="@+id/textView54" android:layout_toEndOf="@+id/textView54" /&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Medium Text" android:id="@+id/tvMatkulDN" android:layout_alignTop="@+id/textView60" android:layout_toRightOf="@+id/textView60" android:textColor="#ffffff" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" /&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Medium Text" android:id="@+id/tvKlpDN" android:layout_below="@+id/tvMatkulDN" android:layout_toRightOf="@+id/textView60" android:textColor="#ffffff" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" /&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Medium Text" android:id="@+id/tvMhsDN" android:layout_below="@+id/tvKlpDN" android:layout_toRightOf="@+id/textView61" android:textColor="#ffffff" android:layout_alignRight="@+id/tvKlpDN" android:layout_alignEnd="@+id/tvKlpDN" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Belum ada nilai uas" android:id="@+id/bUasDN" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:layout_below="@id/textView59" android:gravity="left|center_vertical" android:drawableRight="@drawable/ic_create_black_24dp"/&gt; &lt;/RelativeLayout&gt; </code></pre>
0debug
UNIX script to check if httpd service is on or off and if off send a email : <p>Script to check if httpd is on or no</p> <p>How do I make this script run in background so that it keeps checking if httpd service is on or off and emails a message if it goes off !! ( PS-: I DON'T WANT TO MAKE THE SCRIPT AS A CRONJOB) just like a daemon process which runs in background!! Please Help</p>
0debug
void bdrv_attach_aio_context(BlockDriverState *bs, AioContext *new_context) { BdrvAioNotifier *ban; if (!bs->drv) { return; } bs->aio_context = new_context; if (bs->backing) { bdrv_attach_aio_context(bs->backing->bs, new_context); } if (bs->file) { bdrv_attach_aio_context(bs->file->bs, new_context); } if (bs->drv->bdrv_attach_aio_context) { bs->drv->bdrv_attach_aio_context(bs, new_context); } if (bs->io_limits_enabled) { throttle_timers_attach_aio_context(&bs->throttle_timers, new_context); } QLIST_FOREACH(ban, &bs->aio_notifiers, list) { ban->attached_aio_context(new_context, ban->opaque); } }
1threat
static inline void dxt5_block_internal(uint8_t *dst, ptrdiff_t stride, const uint8_t *block) { int x, y; uint32_t colors[4]; uint8_t alpha_indices[16]; uint16_t color0 = AV_RL16(block + 8); uint16_t color1 = AV_RL16(block + 10); uint32_t code = AV_RL32(block + 12); uint8_t alpha0 = *(block); uint8_t alpha1 = *(block + 1); decompress_indices(alpha_indices, block + 2); extract_color(colors, color0, color1, 1, 0); for (y = 0; y < 4; y++) { for (x = 0; x < 4; x++) { int alpha_code = alpha_indices[x + y * 4]; uint32_t pixel; uint8_t alpha; if (alpha_code == 0) { alpha = alpha0; } else if (alpha_code == 1) { alpha = alpha1; } else { if (alpha0 > alpha1) { alpha = (uint8_t) (((8 - alpha_code) * alpha0 + (alpha_code - 1) * alpha1) / 7); } else { if (alpha_code == 6) { alpha = 0; } else if (alpha_code == 7) { alpha = 255; } else { alpha = (uint8_t) (((6 - alpha_code) * alpha0 + (alpha_code - 1) * alpha1) / 5); } } } pixel = colors[code & 3] | (alpha << 24); code >>= 2; AV_WL32(dst + x * 4, pixel); } dst += stride; } }
1threat
If CancellationToken is a struct and is passed by Value, how is it updated? : <p>I see that CancellationToken is a struct <a href="https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken?view=netframework-4.7.1" rel="noreferrer">https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken?view=netframework-4.7.1</a></p> <p>If I pass a struct to a new function by value, it shouldn't be modified in the caller. So if i'm passing a CancellationTokenSource (by value), then I call cts.cancel(), how does the method that has a <strong>copy</strong> of that token is notified that it has been canceled? Shouldn't it work only if we pass by reference? </p> <p>For example:</p> <pre><code>public static void Main() { var cts = new CancellationTokenSource(); SomeCancellableOperation(cts.Token); cts.cancel(); } public void SomeCancellableOperation(CancellationToken token) { ... token.ThrowIfCancellationRequested(); ... } </code></pre>
0debug
static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id, int buf_size) { int i; int skip = 0; int len, toks, pos; TM2Codes codes; GetByteContext gb; if (buf_size < 4) { av_log(ctx->avctx, AV_LOG_ERROR, "not enough space for len left\n"); return AVERROR_INVALIDDATA; } bytestream2_init(&gb, buf, buf_size); len = bytestream2_get_be32(&gb); skip = len * 4 + 4; if(len == 0) return 4; if (len >= INT_MAX/4-1 || len < 0 || skip > buf_size) { av_log(ctx->avctx, AV_LOG_ERROR, "invalid stream size\n"); return AVERROR_INVALIDDATA; } toks = bytestream2_get_be32(&gb); if(toks & 1) { len = bytestream2_get_be32(&gb); if(len == TM2_ESCAPE) { len = bytestream2_get_be32(&gb); } if(len > 0) { pos = bytestream2_tell(&gb); if (skip <= pos) return AVERROR_INVALIDDATA; init_get_bits(&ctx->gb, buf + pos, (skip - pos) * 8); if(tm2_read_deltas(ctx, stream_id) == -1) return AVERROR_INVALIDDATA; bytestream2_skip(&gb, ((get_bits_count(&ctx->gb) + 31) >> 5) << 2); } } len = bytestream2_get_be32(&gb); if(len == TM2_ESCAPE) { bytestream2_skip(&gb, 8); } else { bytestream2_skip(&gb, 4); } pos = bytestream2_tell(&gb); if (skip <= pos) return AVERROR_INVALIDDATA; init_get_bits(&ctx->gb, buf + pos, (skip - pos) * 8); if(tm2_build_huff_table(ctx, &codes) == -1) return AVERROR_INVALIDDATA; bytestream2_skip(&gb, ((get_bits_count(&ctx->gb) + 31) >> 5) << 2); toks >>= 1; if((toks < 0) || (toks > 0xFFFFFF)){ av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of tokens: %i\n", toks); tm2_free_codes(&codes); return AVERROR_INVALIDDATA; } ctx->tokens[stream_id] = av_realloc(ctx->tokens[stream_id], toks * sizeof(int)); ctx->tok_lens[stream_id] = toks; len = bytestream2_get_be32(&gb); if(len > 0) { pos = bytestream2_tell(&gb); if (skip <= pos) return AVERROR_INVALIDDATA; init_get_bits(&ctx->gb, buf + pos, (skip - pos) * 8); for(i = 0; i < toks; i++) { if (get_bits_left(&ctx->gb) <= 0) { av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of tokens: %i\n", toks); return AVERROR_INVALIDDATA; } ctx->tokens[stream_id][i] = tm2_get_token(&ctx->gb, &codes); if (stream_id <= TM2_MOT && ctx->tokens[stream_id][i] >= TM2_DELTAS) { av_log(ctx->avctx, AV_LOG_ERROR, "Invalid delta token index %d for type %d, n=%d\n", ctx->tokens[stream_id][i], stream_id, i); return AVERROR_INVALIDDATA; } } } else { for(i = 0; i < toks; i++) { ctx->tokens[stream_id][i] = codes.recode[0]; if (stream_id <= TM2_MOT && ctx->tokens[stream_id][i] >= TM2_DELTAS) { av_log(ctx->avctx, AV_LOG_ERROR, "Invalid delta token index %d for type %d, n=%d\n", ctx->tokens[stream_id][i], stream_id, i); return AVERROR_INVALIDDATA; } } } tm2_free_codes(&codes); return skip; }
1threat
static int raw_create(const char *filename, QEMUOptionParameter *options) { int fd; int64_t total_size = 0; while (options && options->name) { if (!strcmp(options->name, BLOCK_OPT_SIZE)) { total_size = options->value.n / 512; } options++; } fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); if (fd < 0) return -EIO; ftruncate(fd, total_size * 512); close(fd); return 0; }
1threat
Handling multiple event dependency in event-driven architecture : <p>What would be best practice if you have an event-driven architecture and a service subscribing to events has to wait for multiple event (of the same kind) before proceeding with creating the next event in the chain?</p> <p>An example would be a book order handling service that has to wait for each book in the order to have been handled by the warehouse before creating the event that the order has been picked so that the shipping service (or something similar) picks up the order and starts preparing for shipping.</p>
0debug
Ignore "cannot find module" error on typescript : <p>Can the Typescript compiler ignore the <code>cannot find module 'x'</code> error on import expressions such as:</p> <pre><code>//How to tell the compiler that this module does exists import sql = require('sql'); </code></pre> <p>There are multiple npm libraries such as <a href="https://github.com/brianc/node-sql">node sql</a> that doesn't have existing typings</p> <p>Is there a way to tell the compiler to ignore this error other than creating a new definition file with the <code>declare module x ...</code> ?</p>
0debug
static void framebuffer_update_request(VncState *vs, int incremental, int x_position, int y_position, int w, int h) { if (x_position > ds_get_width(vs->ds)) x_position = ds_get_width(vs->ds); if (y_position > ds_get_height(vs->ds)) y_position = ds_get_height(vs->ds); if (x_position + w >= ds_get_width(vs->ds)) w = ds_get_width(vs->ds) - x_position; if (y_position + h >= ds_get_height(vs->ds)) h = ds_get_height(vs->ds) - y_position; int i; vs->need_update = 1; if (!incremental) { char *old_row = vs->old_data + y_position * ds_get_linesize(vs->ds); for (i = 0; i < h; i++) { vnc_set_bits(vs->dirty_row[y_position + i], (ds_get_width(vs->ds) / 16), VNC_DIRTY_WORDS); memset(old_row, 42, ds_get_width(vs->ds) * vs->depth); old_row += ds_get_linesize(vs->ds); } } }
1threat
static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms, int w, int h) { FlipContext *flip = link->dst->priv; int i; AVFilterBufferRef *picref = avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h); for (i = 0; i < 4; i ++) { int vsub = i == 1 || i == 2 ? flip->vsub : 0; if (picref->data[i]) { picref->data[i] += ((h >> vsub)-1) * picref->linesize[i]; picref->linesize[i] = -picref->linesize[i]; } } return picref; }
1threat
Angular2 innerHtml removes styling : <p>I am using innerHtml and set the html in my cms the response seems okay and if I print it like this<code>: {{ poi.content }}</code></p> <p>it gives me the right content back : `</p> <pre><code>&lt;table border="0" cellpadding="5" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td style="vertical-align: top;"&gt;Tes11t&lt;/td&gt; &lt;td style="width: 2px;"&gt;&amp;nbsp;&lt;/td&gt; &lt;td style="width: 1px;"&gt;&lt;img alt="midgetgolf-sport-faciliteiten-vakantiepark-2.jpg" src="http://beeksebergen.dev/app_dev.php/media/cache/resolve/full_size/midgetgolf-sport-faciliteiten-vakantiepark-2.jpg" style="height: 67px; width: 100px;" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>`</p> <p>But when I use <code>[innerHtml]="poi.content"</code> it gives me this html back:</p> <pre><code>&lt;table border="0" cellpadding="5" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;Tes11t&lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&lt;img alt="midgetgolf-sport-faciliteiten-vakantiepark-2.jpg" src="http://beeksebergen.dev/app_dev.php/media/cache/resolve/full_size/midgetgolf-sport-faciliteiten-vakantiepark-2.jpg"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>Does anybody know why it is stripping my styling when I use <code>[innerHtml]</code></p>
0debug
Cannot resolve method Observable.from in rxjava 2 : <p>There is a from method in the Observable class in rxjava 1 but not found in rxjava 2. How can I replace the from method in rxjava 2 in the following code:</p> <pre><code> List&lt;Integer&gt; ints = new ArrayList&lt;&gt;(); for (int i=1; i&lt;10; i++) { ints.add(new Integer(i)); } Observable.just(ints) .flatMap(new Function&lt;List&lt;Integer&gt;, Observable&lt;Integer&gt;&gt;() { @Override public Observable&lt;Integer&gt; apply(List&lt;Integer&gt; ints) { return Observable.from(ints); } }) </code></pre>
0debug
static target_phys_addr_t intel_hda_addr(uint32_t lbase, uint32_t ubase) { target_phys_addr_t addr; addr = ((uint64_t)ubase << 32) | lbase; return addr; }
1threat
def min_Num(arr,n): odd = 0 for i in range(n): if (arr[i] % 2): odd += 1 if (odd % 2): return 1 return 2
0debug
How to get to know about developer code blame in android studio : <p>I am working on project which is shared by few developers, how to get to know about developer blame in android studio?? any shortcuts or any idea? which will help us to know about code blame.</p>
0debug
static void virtio_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(dev); Error *err = NULL; assert(!vdc->vmsd || !vdc->load); if (vdc->realize != NULL) { vdc->realize(dev, &err); if (err != NULL) { error_propagate(errp, err); return; } } virtio_bus_device_plugged(vdev, &err); if (err != NULL) { error_propagate(errp, err); return; } vdev->listener.commit = virtio_memory_listener_commit; memory_listener_register(&vdev->listener, vdev->dma_as); }
1threat
uint64_t float64_to_uint64_round_to_zero (float64 a STATUS_PARAM) { int64_t v; v = int64_to_float64(INT64_MIN STATUS_VAR); v = float64_to_int64_round_to_zero((a + v) STATUS_VAR); return v - INT64_MIN; }
1threat
rfc3986_parse_port(URI *uri, const char **str) { const char *cur = *str; if (ISA_DIGIT(cur)) { if (uri != NULL) uri->port = 0; while (ISA_DIGIT(cur)) { if (uri != NULL) uri->port = uri->port * 10 + (*cur - '0'); cur++; } *str = cur; return(0); } return(1); }
1threat
Ionic build error : You have not accepted the license agreements of the following SDK components: [Android SDK Platform 24] : <p>I'm trying to run the command <code>ionic build android --release</code> to build the apk but i am getting this error </p> <blockquote> <p>Total time: 1.767 secs Error: cmd: Command failed with exit code 1 Error output: FAILURE: Build failed with an exception.</p> <ul> <li><p>What went wrong: A problem occurred configuring root project 'android'.</p> <blockquote> <p>You have not accepted the license agreements of the following SDK components: [Android SDK Platform 24]. Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager. Alternatively, to learn how to transfer the license agreements from one workstation to another, go to <a href="http://d.android.com/r/studio-ui/export-licenses.html">http://d.android.com/r/studio-ui/export-licenses.html</a></p> </blockquote></li> <li><p>Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Picked up _JAVA_OPTIONS: -Xmx512M</p></li> </ul> </blockquote>
0debug
Request header does not include HTTP_X_CSRF_TOKEN when using AWS JS SDK : <p>I have a Rails application where I can post answers to questions via ajax, it works fine, however, I have added the <code>aws-js-sdk</code> script to be able to upload images in my answer from the browser, the image will be uploaded to s3 which sends back the url of the newly uploaded image in a callback, then I save the answer.</p> <p>I included the library like this : </p> <pre><code> &lt;%= javascript_include_tag "//sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js" %&gt; </code></pre> <p><strong>Expected behaviour</strong> : when I submit an answer with an image, the request header should include <code>HTTP_X_CSRF_TOKEN</code> to verify the form is submitted from within my website. </p> <p><strong>Problem</strong> : request header does not include <code>HTTP_X_CSRF_TOKEN</code>, which is leading to the error <code>ActionController::InvalidAuthenticityToken</code></p>
0debug
int64_t swr_next_pts(struct SwrContext *s, int64_t pts){ if(pts == INT64_MIN) return s->outpts; if(s->min_compensation >= FLT_MAX) { return (s->outpts = pts - swr_get_delay(s, s->in_sample_rate * (int64_t)s->out_sample_rate)); } else { int64_t delta = pts - swr_get_delay(s, s->in_sample_rate * (int64_t)s->out_sample_rate) - s->outpts; double fdelta = delta /(double)(s->in_sample_rate * (int64_t)s->out_sample_rate); if(fabs(fdelta) > s->min_compensation) { if(!s->outpts || fabs(fdelta) > s->min_hard_compensation){ int ret; if(delta > 0) ret = swr_inject_silence(s, delta / s->out_sample_rate); else ret = swr_drop_output (s, -delta / s-> in_sample_rate); if(ret<0){ av_log(s, AV_LOG_ERROR, "Failed to compensate for timestamp delta of %f\n", fdelta); } } else if(s->soft_compensation_duration && s->max_soft_compensation) { int duration = s->out_sample_rate * s->soft_compensation_duration; double max_soft_compensation = s->max_soft_compensation / (s->max_soft_compensation < 0 ? -s->in_sample_rate : 1); int comp = av_clipf(fdelta, -max_soft_compensation, max_soft_compensation) * duration ; av_log(s, AV_LOG_VERBOSE, "compensating audio timestamp drift:%f compensation:%d in:%d\n", fdelta, comp, duration); swr_set_compensation(s, comp, duration); } } return s->outpts; } }
1threat
C++ Class Object as a Parameter : i have this problem with getting class to pass as a parameter for another class constructor. Basically the code is like this: class A { public: int ID; A(int getID) { ID = getID; } } and i want to use that class A as a member of class B like this: class B { public: A someA; A someB; int number; B(A ObjectA, A ObjectB, int getNumber) { someA = ObjectA; someB = ObjectB; number = getNumber; } }; The errors are basically saying that there is no matching function to call B::B(). I dont know whats wrong with it. I have done similar things with vectors of object, so I thought why cant this thing works. Any inputs/correction is appreciated, thank you! Sidenotes: I have tried adding a default constructor for B as suggested in another thread, but it ended up saying invalid use of B::B.
0debug
android permission API in > 23 (without run-time request) : how permissions request for API > 23 (without run-time request) [show Image][1] [1]: https://i.stack.imgur.com/EkTx5.jpg
0debug
static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, AVFilterInOut *in) { AVFilterContext *last_filter; const AVFilter *buffer_filt = avfilter_get_by_name("buffer"); InputStream *ist = ifilter->ist; InputFile *f = input_files[ist->file_index]; AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) : ist->st->time_base; AVRational fr = ist->framerate; AVRational sar; AVBPrint args; char name[255]; int ret, pad_idx = 0; int64_t tsoffset = 0; AVBufferSrcParameters *par = av_buffersrc_parameters_alloc(); if (!par) return AVERROR(ENOMEM); memset(par, 0, sizeof(*par)); par->format = AV_PIX_FMT_NONE; if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) { av_log(NULL, AV_LOG_ERROR, "Cannot connect video filter to audio input\n"); return AVERROR(EINVAL); } if (!fr.num) fr = av_guess_frame_rate(input_files[ist->file_index]->ctx, ist->st, NULL); if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE) { ret = sub2video_prepare(ist); if (ret < 0) return ret; } sar = ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio : ist->dec_ctx->sample_aspect_ratio; if(!sar.den) sar = (AVRational){0,1}; av_bprint_init(&args, 0, 1); av_bprintf(&args, "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:" "pixel_aspect=%d/%d:sws_param=flags=%d", ist->resample_width, ist->resample_height, ist->hwaccel_retrieve_data ? ist->hwaccel_retrieved_pix_fmt : ist->resample_pix_fmt, tb.num, tb.den, sar.num, sar.den, SWS_BILINEAR + ((ist->dec_ctx->flags&AV_CODEC_FLAG_BITEXACT) ? SWS_BITEXACT:0)); if (fr.num && fr.den) av_bprintf(&args, ":frame_rate=%d/%d", fr.num, fr.den); snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index, ist->file_index, ist->st->index); if ((ret = avfilter_graph_create_filter(&ifilter->filter, buffer_filt, name, args.str, NULL, fg->graph)) < 0) return ret; par->hw_frames_ctx = ist->hw_frames_ctx; ret = av_buffersrc_parameters_set(ifilter->filter, par); if (ret < 0) return ret; av_freep(&par); last_filter = ifilter->filter; if (ist->autorotate) { double theta = get_rotation(ist->st); if (fabs(theta - 90) < 1.0) { ret = insert_filter(&last_filter, &pad_idx, "transpose", "clock"); } else if (fabs(theta - 180) < 1.0) { ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL); if (ret < 0) return ret; ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL); } else if (fabs(theta - 270) < 1.0) { ret = insert_filter(&last_filter, &pad_idx, "transpose", "cclock"); } else if (fabs(theta) > 1.0) { char rotate_buf[64]; snprintf(rotate_buf, sizeof(rotate_buf), "%f*PI/180", theta); ret = insert_filter(&last_filter, &pad_idx, "rotate", rotate_buf); } if (ret < 0) return ret; } if (ist->framerate.num) { AVFilterContext *setpts; snprintf(name, sizeof(name), "force CFR for input from stream %d:%d", ist->file_index, ist->st->index); if ((ret = avfilter_graph_create_filter(&setpts, avfilter_get_by_name("setpts"), name, "N", NULL, fg->graph)) < 0) return ret; if ((ret = avfilter_link(last_filter, 0, setpts, 0)) < 0) return ret; last_filter = setpts; } if (do_deinterlace) { AVFilterContext *yadif; snprintf(name, sizeof(name), "deinterlace input from stream %d:%d", ist->file_index, ist->st->index); if ((ret = avfilter_graph_create_filter(&yadif, avfilter_get_by_name("yadif"), name, "", NULL, fg->graph)) < 0) return ret; if ((ret = avfilter_link(last_filter, 0, yadif, 0)) < 0) return ret; last_filter = yadif; } snprintf(name, sizeof(name), "trim for input stream %d:%d", ist->file_index, ist->st->index); if (copy_ts) { tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time; if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE) tsoffset += f->ctx->start_time; } ret = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ? AV_NOPTS_VALUE : tsoffset, f->recording_time, &last_filter, &pad_idx, name); if (ret < 0) return ret; if ((ret = avfilter_link(last_filter, 0, in->filter_ctx, in->pad_idx)) < 0) return ret; return 0; }
1threat
alert('Hello ' + user_input);
1threat
Android Studio. How export Live Template to file? : <p>Android Studio 2.3.2. I want to export <strong>Live Templates-->AndroidLog</strong> to file. <a href="https://i.stack.imgur.com/ePGLT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ePGLT.png" alt="enter image description here"></a></p> <p>How I can do this? Thanks.</p>
0debug
taking File as a input in command line argument in python : <p>I need to take Files as inputs from command line arguments. I am providing the path of the file but it is taking the path as filename ? What i can add to make it right . This is my code : I am using openpyxl to get names:</p> <pre><code>wk1 = openpyxl.load_workbook (sys.argv[1]) wk2 = openpyxl.load_workbook (sys.argv[2]) </code></pre> <p>Please help out . </p>
0debug
int ff_lzf_uncompress(GetByteContext *gb, uint8_t **buf, int64_t *size) { int ret = 0; uint8_t *p = *buf; int64_t len = 0; while (bytestream2_get_bytes_left(gb) > 2) { uint8_t s = bytestream2_get_byte(gb); if (s < LZF_LITERAL_MAX) { s++; if (s > *size - len) { *size += *size /2; ret = av_reallocp(buf, *size); if (ret < 0) return ret; } bytestream2_get_buffer(gb, p, s); p += s; len += s; } else { int l = 2 + (s >> 5); int off = ((s & 0x1f) << 8) + 1; if (l == LZF_LONG_BACKREF) l += bytestream2_get_byte(gb); off += bytestream2_get_byte(gb); if (off > len) return AVERROR_INVALIDDATA; if (l > *size - len) { *size += *size / 2; ret = av_reallocp(buf, *size); if (ret < 0) return ret; } av_memcpy_backptr(p, off, l); p += l; len += l; } } *size = len; return 0; }
1threat
static int alac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { AlacEncodeContext *s = avctx->priv_data; int out_bytes, max_frame_size, ret; s->frame_size = frame->nb_samples; if (frame->nb_samples < DEFAULT_FRAME_SIZE) max_frame_size = get_max_frame_size(s->frame_size, avctx->channels, avctx->bits_per_raw_sample); else max_frame_size = s->max_coded_frame_size; if ((ret = ff_alloc_packet2(avctx, avpkt, 2 * max_frame_size))) return ret; if (s->compression_level) { s->verbatim = 0; s->extra_bits = avctx->bits_per_raw_sample - 16; } else { s->verbatim = 1; s->extra_bits = 0; } out_bytes = write_frame(s, avpkt, frame->extended_data); if (out_bytes > max_frame_size) { s->verbatim = 1; s->extra_bits = 0; out_bytes = write_frame(s, avpkt, frame->extended_data); } avpkt->size = out_bytes; *got_packet_ptr = 1; return 0; }
1threat
Is binary equality comparison of floats correct? : <p>I'm working on different memory block manipulation functions and during benchmarks I noticed, that my implementation of the <code>IsEqualRange(double* begin1, double* end1, double* begin2, double* end2)</code> is much faster then the <code>std::equals(...)</code> on MSVC and GCC as well. Further investigation showed, that doubles and floats are not block compared by <code>memcmp</code>, but in a for loop one by one. </p> <p>In what situation does binary comparison of floats lead to incorrect result? When is it ok to binary compare (equality) array of floats/doubles? Are there other fundamental types where I shouldn't use <code>memcmp</code>?</p>
0debug
static void megasas_mmio_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) { MegasasState *s = opaque; PCIDevice *pci_dev = PCI_DEVICE(s); uint64_t frame_addr; uint32_t frame_count; int i; switch (addr) { case MFI_IDB: trace_megasas_mmio_writel("MFI_IDB", val); if (val & MFI_FWINIT_ABORT) { for (i = 0; i < s->fw_cmds; i++) { megasas_abort_command(&s->frames[i]); } } if (val & MFI_FWINIT_READY) { megasas_soft_reset(s); } if (val & MFI_FWINIT_MFIMODE) { } if (val & MFI_FWINIT_STOP_ADP) { s->fw_state = MFI_FWSTATE_FAULT; } break; case MFI_OMSK: trace_megasas_mmio_writel("MFI_OMSK", val); s->intr_mask = val; if (!megasas_intr_enabled(s) && !msi_enabled(pci_dev) && !msix_enabled(pci_dev)) { trace_megasas_irq_lower(); pci_irq_deassert(pci_dev); } if (megasas_intr_enabled(s)) { if (msix_enabled(pci_dev)) { trace_megasas_msix_enabled(0); } else if (msi_enabled(pci_dev)) { trace_megasas_msi_enabled(0); } else { trace_megasas_intr_enabled(); } } else { trace_megasas_intr_disabled(); megasas_soft_reset(s); } break; case MFI_ODCR0: trace_megasas_mmio_writel("MFI_ODCR0", val); s->doorbell = 0; if (megasas_intr_enabled(s)) { if (!msix_enabled(pci_dev) && !msi_enabled(pci_dev)) { trace_megasas_irq_lower(); pci_irq_deassert(pci_dev); } } break; case MFI_IQPH: trace_megasas_mmio_writel("MFI_IQPH", val); s->frame_hi = val; break; case MFI_IQPL: trace_megasas_mmio_writel("MFI_IQPL", val); case MFI_IQP: if (addr == MFI_IQP) { trace_megasas_mmio_writel("MFI_IQP", val); s->frame_hi = 0; } frame_addr = (val & ~0x1F); frame_addr |= ((uint64_t)s->frame_hi << 32); s->frame_hi = 0; frame_count = (val >> 1) & 0xF; megasas_handle_frame(s, frame_addr, frame_count); break; case MFI_SEQ: trace_megasas_mmio_writel("MFI_SEQ", val); if (adp_reset_seq[s->adp_reset] == val) { s->adp_reset++; } else { s->adp_reset = 0; s->diag = 0; } if (s->adp_reset == 6) { s->diag = MFI_DIAG_WRITE_ENABLE; } break; case MFI_DIAG: trace_megasas_mmio_writel("MFI_DIAG", val); if ((s->diag & MFI_DIAG_WRITE_ENABLE) && (val & MFI_DIAG_RESET_ADP)) { s->diag |= MFI_DIAG_RESET_ADP; megasas_soft_reset(s); s->adp_reset = 0; s->diag = 0; } break; default: trace_megasas_mmio_invalid_writel(addr, val); break; } }
1threat
static av_cold int vtenc_init(AVCodecContext *avctx) { CFMutableDictionaryRef enc_info; CFMutableDictionaryRef pixel_buffer_info; CMVideoCodecType codec_type; VTEncContext *vtctx = avctx->priv_data; CFStringRef profile_level; CFBooleanRef has_b_frames_cfbool; CFNumberRef gamma_level = NULL; int status; codec_type = get_cm_codec_type(avctx->codec_id); if (!codec_type) { av_log(avctx, AV_LOG_ERROR, "Error: no mapping for AVCodecID %d\n", avctx->codec_id); return AVERROR(EINVAL); } vtctx->has_b_frames = avctx->max_b_frames > 0; if(vtctx->has_b_frames && vtctx->profile == H264_PROF_BASELINE){ av_log(avctx, AV_LOG_WARNING, "Cannot use B-frames with baseline profile. Output will not contain B-frames.\n"); vtctx->has_b_frames = false; } if (vtctx->entropy == VT_CABAC && vtctx->profile == H264_PROF_BASELINE) { av_log(avctx, AV_LOG_WARNING, "CABAC entropy requires 'main' or 'high' profile, but baseline was requested. Encode will not use CABAC entropy.\n"); vtctx->entropy = VT_ENTROPY_NOT_SET; } if (!get_vt_profile_level(avctx, &profile_level)) return AVERROR(EINVAL); vtctx->session = NULL; enc_info = CFDictionaryCreateMutable( kCFAllocatorDefault, 20, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks ); if (!enc_info) return AVERROR(ENOMEM); #if !TARGET_OS_IPHONE if (!vtctx->allow_sw) { CFDictionarySetValue(enc_info, kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder, kCFBooleanTrue); } else { CFDictionarySetValue(enc_info, kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder, kCFBooleanTrue); } #endif if (avctx->pix_fmt != AV_PIX_FMT_VIDEOTOOLBOX) { status = create_cv_pixel_buffer_info(avctx, &pixel_buffer_info); if (status) goto init_cleanup; } else { pixel_buffer_info = NULL; } pthread_mutex_init(&vtctx->lock, NULL); pthread_cond_init(&vtctx->cv_sample_sent, NULL); vtctx->dts_delta = vtctx->has_b_frames ? -1 : 0; get_cv_transfer_function(avctx, &vtctx->transfer_function, &gamma_level); get_cv_ycbcr_matrix(avctx, &vtctx->ycbcr_matrix); get_cv_color_primaries(avctx, &vtctx->color_primaries); if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { status = vtenc_populate_extradata(avctx, codec_type, profile_level, gamma_level, enc_info, pixel_buffer_info); if (status) goto init_cleanup; } status = vtenc_create_encoder(avctx, codec_type, profile_level, gamma_level, enc_info, pixel_buffer_info, &vtctx->session); if (status < 0) goto init_cleanup; status = VTSessionCopyProperty(vtctx->session, kVTCompressionPropertyKey_AllowFrameReordering, kCFAllocatorDefault, &has_b_frames_cfbool); if (!status) { vtctx->has_b_frames = CFBooleanGetValue(has_b_frames_cfbool); CFRelease(has_b_frames_cfbool); } avctx->has_b_frames = vtctx->has_b_frames; init_cleanup: if (gamma_level) CFRelease(gamma_level); if (pixel_buffer_info) CFRelease(pixel_buffer_info); CFRelease(enc_info); return status; }
1threat
CSS background color does not display when duplicating template to development : <p>I acquired a template that includes a html css tag to set the background color of the page to #ececec. I have compared the original template against my recreation, and in my recreation, the background is white. Screenshot below:</p> <p><a href="https://i.stack.imgur.com/1ravm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1ravm.png" alt="enter image description here"></a></p> <p>Can anyone explain to me why even though the css is there and in its proper location in the css hierarchy, that the backgrounds are different?</p> <p>thank you.</p>
0debug
Where are Run configurations stored? : <p>Run Liclipse 2.5.3 on Mac OS. I renamed my project. I lost all my run configurations. When i recreate one, it says the file exists. However there are no run configurations present. </p> <p>Where are the run configs stored</p>
0debug
iscsi_process_write(void *arg) { IscsiLun *iscsilun = arg; struct iscsi_context *iscsi = iscsilun->iscsi; aio_context_acquire(iscsilun->aio_context); iscsi_service(iscsi, POLLOUT); iscsi_set_events(iscsilun); aio_context_release(iscsilun->aio_context); }
1threat
number even or odd : <p>How can I call a function in javascripf where find number even or odd.</p>
0debug
Regexp for all words and symbols inside ~{asdax.com123} : input: `~{RegExr1234124124.} was ~{created by gskinner.com}, and is ~{proudly hosted} by Media Temple.` output: `was, and is by Media Template`
0debug
Regarding Palindrome algorithm. Finding the shortest possible string : Hello guys, The task is the following: "Write a JavaScript program to find the shortest possible string which can create a string to make it a palindrome by adding characters to the end of it." This is a code: "function build_Palindrome(new_str) { var flag; for (var i = new_str.length;; i++) { flag = true; for (var j = 0; j < i - j - 1; j++) { if (i - j - 1 < new_str.length && new_str[j] != new_str[i - j - 1]) { flag = false; break; } } if (flag) { for (var j = new_str.length; j < i; j++) { new_str += new_str[i - j - 1]; } return new_str; } } }" Test: console.log(build_Palindrome("abcddc")) Output: abcddcba My question: At first it starts with j=0. If in the for loop, flag=false, then how it proceeds? Is i=7 (i++?) and is j=0 or j=1?
0debug
How to fetch data and show in Tgrid in delphi : <p>I'm working on an application where i want to fetch data from database and show it in <code>Tgrid.</code> Since it doesn't have a <code>DataSource</code> Property, i can't figure out a way how to add item in Tgrid.</p>
0debug
static void kvm_virtio_pci_vq_vector_release(VirtIOPCIProxy *proxy, unsigned int queue_no, unsigned int vector) { VirtQueue *vq = virtio_get_queue(proxy->vdev, queue_no); EventNotifier *n = virtio_queue_get_guest_notifier(vq); VirtIOIRQFD *irqfd = &proxy->vector_irqfd[vector]; int ret; ret = kvm_irqchip_remove_irq_notifier(kvm_state, n, irqfd->virq); assert(ret == 0); if (--irqfd->users == 0) { kvm_irqchip_release_virq(kvm_state, irqfd->virq); } virtio_queue_set_guest_notifier_fd_handler(vq, true, false); }
1threat
How to get the test result status from TestNG/Selenium in @AfterMethod? : <p>For a research I'm doing, I'm in need of capturing the result status (Passed/Failed) after running the test method (@Test), from @AfterMethod.</p> <p>I have been using the import org.testng.ITestResult; as an out come of my research to get my work easier after going the several online blogs, but It seems like it didn't success my expectation as always the result outputs as passed, <strong>even though an assertion failed</strong>.</p> <p>My Code is as follows : </p> <pre><code>public class SampleTestForTestProject { ITestResult result; @Test(priority = 1) public void testcase(){ // intentionally failing the assertion to make the test method fail boolean actual = true; boolean expected = false; Assert.assertEquals(actual, expected); } @AfterMethod public void afterMethod() { result = Reporter.getCurrentTestResult(); switch (result.getStatus()) { case ITestResult.SUCCESS: System.out.println("======PASS====="); // my expected functionality here when passed break; case ITestResult.FAILURE: System.out.println("======FAIL====="); // my expected functionality here when passed break; case ITestResult.SKIP: System.out.println("======SKIP BLOCKED====="); // my expected functionality here when passed break; default: throw new RuntimeException("Invalid status"); } } } </code></pre> <p>Result in the Console : </p> <pre><code>[TestNG] Running: C:\Users\USER\AppData\Local\Temp\testng-eclipse--988445809\testng-customsuite.xml ======PASS===== FAILED: testcaseFail java.lang.AssertionError: expected [false] but found [true] </code></pre> <p>My expectation is to get the test result to a variable to get through the switch, as given in the above code snippet, and get printed "======FAIL=====" when the test method fail.</p> <p>Will someone be able assist me kindly to catch the execution test result for each test method (@Test). If the method I have approached is wrong, please assist me with a code snippet to the correct approach, kindly.</p> <p>Thank you in advance</p>
0debug
How to override static method in subclass in JAVA? : 1) for what version of JAVA it is planed to implement possibility to override static methods? 2) for what year it would be? 3) How to achieve similar thing in JAVA8? 4) Is there some hack of oracle JVM? 5) Are there some other virtual machines or compilers, able to override static methods? Thanks for every good direction Čuz Honza
0debug
remove match word from file |LINUX| : **HOW DO I REMOVE THE WORD FROM A FILE IF MATCH IS FOUND IN THE FILE** The Data in the File1.txt is Raj cmd Rahul cmd Pooja cmd Vilas cmd Vikram cmd I want the Output to be Printed like this below Raj Rahul Pooja Vilas Vikram **The Word I want to remove is "cmd"**
0debug
Change geom_text's default "a" legend to label string itself : <p>Similarly to <a href="https://stackoverflow.com/questions/18337653/remove-a-from-legend-when-using-aesthetics-and-geom-text">this question</a>, I want to change the default "a" in the legend, but rather than removing it completely, I want to replace it with the labels themselves. That is, the first line of the legend should have a colored icon labeled "se" with the full name "setosa" on the right. </p> <pre><code>iris$abbrev = substr( iris$Species, 1, 2 ) ggplot(data = iris, aes(x = Sepal.Length, y=Sepal.Width, shape = Species, colour = Species)) + geom_text(aes(label = abbrev)) </code></pre> <p><a href="https://i.stack.imgur.com/4Jgde.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4Jgde.png" alt="enter image description here"></a></p>
0debug
static int config_input(AVFilterLink *inlink) { HQDN3DContext *s = inlink->dst->priv; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); int i; s->hsub = desc->log2_chroma_w; s->vsub = desc->log2_chroma_h; s->depth = desc->comp[0].depth_minus1+1; s->line = av_malloc(inlink->w * sizeof(*s->line)); if (!s->line) return AVERROR(ENOMEM); for (i = 0; i < 4; i++) { s->coefs[i] = precalc_coefs(s->strength[i], s->depth); if (!s->coefs[i]) return AVERROR(ENOMEM); } if (ARCH_X86) ff_hqdn3d_init_x86(s); return 0; }
1threat
How to pass array "by reference" in C? : <p>This is what I'm trying to do but my code is either not compiling or giving me an unexpected output "BC" instead of just "B".</p> <pre><code>#include &lt;stdio.h&gt; void removeFirstAndLastChar(char** string) { *string += 1; // Removes the first character int i = 0; for (; *string[i] != '\0'; i++); *string[i - 1] = '\0'; } int main(void) { char* title = "ABC"; removeFirstAndLastChar(&amp;title); printf("%s", title); // Expected output: B return 0; } </code></pre> <p>I looked through a lot of answers here related to passing pointers by reference but none of them seemed to contain the operations that I want to do in my removeFirstAndLastChar() function.</p>
0debug
React Router Pass Param to Component : <pre><code>const rootEl = document.getElementById('root'); ReactDOM.render( &lt;BrowserRouter&gt; &lt;Switch&gt; &lt;Route exact path="/"&gt; &lt;MasterPage /&gt; &lt;/Route&gt; &lt;Route exact path="/details/:id" &gt; &lt;DetailsPage /&gt; &lt;/Route&gt; &lt;/Switch&gt; &lt;/BrowserRouter&gt;, rootEl ); </code></pre> <p>I am trying access the <b>id</b> in the DetailsPage component but it is not being accessible. I tried </p> <pre><code>&lt;DetailsPage foo={this.props}/&gt; </code></pre> <p>to pass parameters to the DetailsPage, but in vain. </p> <pre><code>export default class DetailsPage extends Component { constructor(props) { super(props); } render() { return ( &lt;div className="page"&gt; &lt;Header /&gt; &lt;div id="mainContentContainer" &gt; &lt;/div&gt; &lt;/div&gt; ); } } </code></pre> <p>So any idea how to pass the ID on to the DetailsPage ?</p>
0debug
AI for trading card game : <p>I'm making a trading card game such as Yu-gi-oh using c++ and qt. I finished the basic functions of the game such as : drawing , attacking , summoning etc.. .However I'm really stumped in the AI part since its my first time making one and i need some advice to get started.</p> <p>I've already done some research on the subject but the amount of results is so confusing that i don't know what to use for my problem. </p> <p>Is there any algorithms i should know of , or some techniques concerning AI in general ? </p>
0debug
matroska_add_stream (MatroskaDemuxContext *matroska) { int res = 0; uint32_t id; MatroskaTrack *track; av_log(matroska->ctx, AV_LOG_DEBUG, "parsing track, adding stream..,\n"); track = av_mallocz(MAX_TRACK_SIZE); matroska->num_tracks++; strcpy(track->language, "eng"); if ((res = ebml_read_master(matroska, &id)) < 0) return res; while (res == 0) { if (!(id = ebml_peek_id(matroska, &matroska->level_up))) { res = AVERROR(EIO); break; } else if (matroska->level_up > 0) { matroska->level_up--; break; } switch (id) { case MATROSKA_ID_TRACKNUMBER: { uint64_t num; if ((res = ebml_read_uint(matroska, &id, &num)) < 0) break; track->num = num; break; } case MATROSKA_ID_TRACKUID: { uint64_t num; if ((res = ebml_read_uint(matroska, &id, &num)) < 0) break; track->uid = num; break; } case MATROSKA_ID_TRACKTYPE: { uint64_t num; if ((res = ebml_read_uint(matroska, &id, &num)) < 0) break; if (track->type && track->type != num) { av_log(matroska->ctx, AV_LOG_INFO, "More than one tracktype in an entry - skip\n"); break; } track->type = num; switch (track->type) { case MATROSKA_TRACK_TYPE_VIDEO: case MATROSKA_TRACK_TYPE_AUDIO: case MATROSKA_TRACK_TYPE_SUBTITLE: break; case MATROSKA_TRACK_TYPE_COMPLEX: case MATROSKA_TRACK_TYPE_LOGO: case MATROSKA_TRACK_TYPE_CONTROL: default: av_log(matroska->ctx, AV_LOG_INFO, "Unknown or unsupported track type 0x%x\n", track->type); track->type = MATROSKA_TRACK_TYPE_NONE; break; } matroska->tracks[matroska->num_tracks - 1] = track; break; } case MATROSKA_ID_TRACKVIDEO: { MatroskaVideoTrack *videotrack; if (!track->type) track->type = MATROSKA_TRACK_TYPE_VIDEO; if (track->type != MATROSKA_TRACK_TYPE_VIDEO) { av_log(matroska->ctx, AV_LOG_INFO, "video data in non-video track - ignoring\n"); res = AVERROR_INVALIDDATA; break; } else if ((res = ebml_read_master(matroska, &id)) < 0) break; videotrack = (MatroskaVideoTrack *)track; while (res == 0) { if (!(id = ebml_peek_id(matroska, &matroska->level_up))) { res = AVERROR(EIO); break; } else if (matroska->level_up > 0) { matroska->level_up--; break; } switch (id) { case MATROSKA_ID_TRACKDEFAULTDURATION: { uint64_t num; if ((res = ebml_read_uint (matroska, &id, &num)) < 0) break; track->default_duration = num; break; } case MATROSKA_ID_VIDEOFRAMERATE: { double num; if ((res = ebml_read_float(matroska, &id, &num)) < 0) break; if (!track->default_duration) track->default_duration = 1000000000/num; break; } case MATROSKA_ID_VIDEODISPLAYWIDTH: { uint64_t num; if ((res = ebml_read_uint(matroska, &id, &num)) < 0) break; videotrack->display_width = num; break; } case MATROSKA_ID_VIDEODISPLAYHEIGHT: { uint64_t num; if ((res = ebml_read_uint(matroska, &id, &num)) < 0) break; videotrack->display_height = num; break; } case MATROSKA_ID_VIDEOPIXELWIDTH: { uint64_t num; if ((res = ebml_read_uint(matroska, &id, &num)) < 0) break; videotrack->pixel_width = num; break; } case MATROSKA_ID_VIDEOPIXELHEIGHT: { uint64_t num; if ((res = ebml_read_uint(matroska, &id, &num)) < 0) break; videotrack->pixel_height = num; break; } case MATROSKA_ID_VIDEOFLAGINTERLACED: { uint64_t num; if ((res = ebml_read_uint(matroska, &id, &num)) < 0) break; if (num) track->flags |= MATROSKA_VIDEOTRACK_INTERLACED; else track->flags &= ~MATROSKA_VIDEOTRACK_INTERLACED; break; } case MATROSKA_ID_VIDEOSTEREOMODE: { uint64_t num; if ((res = ebml_read_uint(matroska, &id, &num)) < 0) break; if (num != MATROSKA_EYE_MODE_MONO && num != MATROSKA_EYE_MODE_LEFT && num != MATROSKA_EYE_MODE_RIGHT && num != MATROSKA_EYE_MODE_BOTH) { av_log(matroska->ctx, AV_LOG_INFO, "Ignoring unknown eye mode 0x%x\n", (uint32_t) num); break; } videotrack->eye_mode = num; break; } case MATROSKA_ID_VIDEOASPECTRATIO: { uint64_t num; if ((res = ebml_read_uint(matroska, &id, &num)) < 0) break; if (num != MATROSKA_ASPECT_RATIO_MODE_FREE && num != MATROSKA_ASPECT_RATIO_MODE_KEEP && num != MATROSKA_ASPECT_RATIO_MODE_FIXED) { av_log(matroska->ctx, AV_LOG_INFO, "Ignoring unknown aspect ratio 0x%x\n", (uint32_t) num); break; } videotrack->ar_mode = num; break; } case MATROSKA_ID_VIDEOCOLORSPACE: { uint64_t num; if ((res = ebml_read_uint(matroska, &id, &num)) < 0) break; videotrack->fourcc = num; break; } default: av_log(matroska->ctx, AV_LOG_INFO, "Unknown video track header entry " "0x%x - ignoring\n", id); case EBML_ID_VOID: res = ebml_read_skip(matroska); break; } if (matroska->level_up) { matroska->level_up--; break; } } break; } case MATROSKA_ID_TRACKAUDIO: { MatroskaAudioTrack *audiotrack; if (!track->type) track->type = MATROSKA_TRACK_TYPE_AUDIO; if (track->type != MATROSKA_TRACK_TYPE_AUDIO) { av_log(matroska->ctx, AV_LOG_INFO, "audio data in non-audio track - ignoring\n"); res = AVERROR_INVALIDDATA; break; } else if ((res = ebml_read_master(matroska, &id)) < 0) break; audiotrack = (MatroskaAudioTrack *)track; audiotrack->channels = 1; audiotrack->samplerate = 8000; while (res == 0) { if (!(id = ebml_peek_id(matroska, &matroska->level_up))) { res = AVERROR(EIO); break; } else if (matroska->level_up > 0) { matroska->level_up--; break; } switch (id) { case MATROSKA_ID_AUDIOSAMPLINGFREQ: { double num; if ((res = ebml_read_float(matroska, &id, &num)) < 0) break; audiotrack->internal_samplerate = audiotrack->samplerate = num; break; } case MATROSKA_ID_AUDIOOUTSAMPLINGFREQ: { double num; if ((res = ebml_read_float(matroska, &id, &num)) < 0) break; audiotrack->samplerate = num; break; } case MATROSKA_ID_AUDIOBITDEPTH: { uint64_t num; if ((res = ebml_read_uint(matroska, &id, &num)) < 0) break; audiotrack->bitdepth = num; break; } case MATROSKA_ID_AUDIOCHANNELS: { uint64_t num; if ((res = ebml_read_uint(matroska, &id, &num)) < 0) break; audiotrack->channels = num; break; } default: av_log(matroska->ctx, AV_LOG_INFO, "Unknown audio track header entry " "0x%x - ignoring\n", id); case EBML_ID_VOID: res = ebml_read_skip(matroska); break; } if (matroska->level_up) { matroska->level_up--; break; } } break; } case MATROSKA_ID_CODECID: { char *text; if ((res = ebml_read_ascii(matroska, &id, &text)) < 0) break; track->codec_id = text; break; } case MATROSKA_ID_CODECPRIVATE: { uint8_t *data; int size; if ((res = ebml_read_binary(matroska, &id, &data, &size) < 0)) break; track->codec_priv = data; track->codec_priv_size = size; break; } case MATROSKA_ID_CODECNAME: { char *text; if ((res = ebml_read_utf8(matroska, &id, &text)) < 0) break; track->codec_name = text; break; } case MATROSKA_ID_TRACKNAME: { char *text; if ((res = ebml_read_utf8(matroska, &id, &text)) < 0) break; track->name = text; break; } case MATROSKA_ID_TRACKLANGUAGE: { char *text, *end; if ((res = ebml_read_utf8(matroska, &id, &text)) < 0) break; if ((end = strchr(text, '-'))) *end = '\0'; if (strlen(text) == 3) strcpy(track->language, text); av_free(text); break; } case MATROSKA_ID_TRACKFLAGENABLED: { uint64_t num; if ((res = ebml_read_uint(matroska, &id, &num)) < 0) break; if (num) track->flags |= MATROSKA_TRACK_ENABLED; else track->flags &= ~MATROSKA_TRACK_ENABLED; break; } case MATROSKA_ID_TRACKFLAGDEFAULT: { uint64_t num; if ((res = ebml_read_uint(matroska, &id, &num)) < 0) break; if (num) track->flags |= MATROSKA_TRACK_DEFAULT; else track->flags &= ~MATROSKA_TRACK_DEFAULT; break; } case MATROSKA_ID_TRACKFLAGLACING: { uint64_t num; if ((res = ebml_read_uint(matroska, &id, &num)) < 0) break; if (num) track->flags |= MATROSKA_TRACK_LACING; else track->flags &= ~MATROSKA_TRACK_LACING; break; } case MATROSKA_ID_TRACKDEFAULTDURATION: { uint64_t num; if ((res = ebml_read_uint(matroska, &id, &num)) < 0) break; track->default_duration = num; break; } case MATROSKA_ID_TRACKCONTENTENCODINGS: { if ((res = ebml_read_master(matroska, &id)) < 0) break; while (res == 0) { if (!(id = ebml_peek_id(matroska, &matroska->level_up))) { res = AVERROR(EIO); break; } else if (matroska->level_up > 0) { matroska->level_up--; break; } switch (id) { case MATROSKA_ID_TRACKCONTENTENCODING: { int encoding_scope = 1; if ((res = ebml_read_master(matroska, &id)) < 0) break; while (res == 0) { if (!(id = ebml_peek_id(matroska, &matroska->level_up))) { res = AVERROR(EIO); break; } else if (matroska->level_up > 0) { matroska->level_up--; break; } switch (id) { case MATROSKA_ID_ENCODINGSCOPE: { uint64_t num; if ((res = ebml_read_uint(matroska, &id, &num)) < 0) break; encoding_scope = num; break; } case MATROSKA_ID_ENCODINGTYPE: { uint64_t num; if ((res = ebml_read_uint(matroska, &id, &num)) < 0) break; if (num) av_log(matroska->ctx, AV_LOG_ERROR, "Unsupported encoding type"); break; } case MATROSKA_ID_ENCODINGCOMPRESSION: { if ((res = ebml_read_master(matroska, &id)) < 0) break; while (res == 0) { if (!(id = ebml_peek_id(matroska, &matroska->level_up))) { res = AVERROR(EIO); break; } else if (matroska->level_up > 0) { matroska->level_up--; break; } switch (id) { case MATROSKA_ID_ENCODINGCOMPALGO: { uint64_t num; if ((res = ebml_read_uint(matroska, &id, &num)) < 0) break; if (num != MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP && #ifdef CONFIG_ZLIB num != MATROSKA_TRACK_ENCODING_COMP_ZLIB && #endif #ifdef CONFIG_BZLIB num != MATROSKA_TRACK_ENCODING_COMP_BZLIB && #endif num != MATROSKA_TRACK_ENCODING_COMP_LZO) av_log(matroska->ctx, AV_LOG_ERROR, "Unsupported compression algo\n"); track->encoding_algo = num; break; } case MATROSKA_ID_ENCODINGCOMPSETTINGS: { uint8_t *data; int size; if ((res = ebml_read_binary(matroska, &id, &data, &size) < 0)) break; track->encoding_settings = data; track->encoding_settings_len = size; break; } default: av_log(matroska->ctx, AV_LOG_INFO, "Unknown compression header entry " "0x%x - ignoring\n", id); case EBML_ID_VOID: res = ebml_read_skip(matroska); break; } if (matroska->level_up) { matroska->level_up--; break; } } break; } default: av_log(matroska->ctx, AV_LOG_INFO, "Unknown content encoding header entry " "0x%x - ignoring\n", id); case EBML_ID_VOID: res = ebml_read_skip(matroska); break; } if (matroska->level_up) { matroska->level_up--; break; } } track->encoding_scope = encoding_scope; break; } default: av_log(matroska->ctx, AV_LOG_INFO, "Unknown content encodings header entry " "0x%x - ignoring\n", id); case EBML_ID_VOID: res = ebml_read_skip(matroska); break; } if (matroska->level_up) { matroska->level_up--; break; } } break; } case MATROSKA_ID_TRACKTIMECODESCALE: { double num; if ((res = ebml_read_float(matroska, &id, &num)) < 0) break; track->time_scale = num; break; } default: av_log(matroska->ctx, AV_LOG_INFO, "Unknown track header entry 0x%x - ignoring\n", id); case EBML_ID_VOID: case MATROSKA_ID_TRACKFLAGFORCED: case MATROSKA_ID_CODECDECODEALL: case MATROSKA_ID_CODECINFOURL: case MATROSKA_ID_CODECDOWNLOADURL: case MATROSKA_ID_TRACKMINCACHE: case MATROSKA_ID_TRACKMAXCACHE: res = ebml_read_skip(matroska); break; } if (matroska->level_up) { matroska->level_up--; break; } } return res; }
1threat
Delete rows in data.table which only contains NA value : <p>i have a question relating to deleting rows in data.table How can i delete rows in data.table which only contain NA values? There are some solutions here but it only works when it contains only numeric value. But my data also contains characteristic value so i can not use something like sumRows. Thanks for your help</p>
0debug