problem
stringlengths
26
131k
labels
class label
2 classes
php mysql coding error : plz tell me that where is error..... i am in tention due to this,.. **Fatal error:** Uncaught Error: Call to undefined function mysql_connect() in C:\xampp\htdocs\kalooo1\includes\db.php:2 Stack trace: #0 C:\xampp\htdocs\kalooo1\index.php(21): include() #1 {main} thrown in C:\xampp\htdocs\kalooo1\includes\db.php on line 2 **db.php** <?php mysql_connect("localhost","root","");`` mysql_select_db("kalooo"); ?> **index.php(21)** include("includes/db.php");
0debug
What will printf do when not enough arguments are passed? : <p>Let's say I used <code>printf</code> without passing enough arguments to match the format specifiers: </p> <pre><code>#include &lt;stdio.h&gt; int main(void) { printf("missing argument: %s\n"); } </code></pre> <p>Are there any guarantees on what the result will be?<br> On my machine, nothing gets printed at all.<br> Is this always the case, or is there a potential for it to print the string with an resolved specifier? </p> <p>for example: <code>missing argument: %s</code> </p> <p>or: <code>missing argument:</code></p>
0debug
static void spapr_lmb_release(DeviceState *dev, void *opaque) { HotplugHandler *hotplug_ctrl = qdev_get_hotplug_handler(dev); sPAPRMachineState *spapr = SPAPR_MACHINE(hotplug_ctrl); sPAPRDIMMState *ds = spapr_pending_dimm_unplugs_find(spapr, PC_DIMM(dev)); if (--ds->nr_lmbs) { return; } spapr_pending_dimm_unplugs_remove(spapr, ds); hotplug_handler_unplug(hotplug_ctrl, dev, &error_abort); }
1threat
How to remove .php, .html, .htm extensions with .htacess? : <p>I'm Developing one website and want to remove the extensions from my website <a href="https://s7info.in" rel="nofollow">s7info</a> in order to make the URLs more user and search friendly. I stumbled across tutorials on how to remove the .php extension from a PHP page. What about the .html? i want to remove those as well..!! </p>
0debug
How i can use horizontal scroll view in fragments? : I'm working with fragments i have a requirement to use horizontal scroll view inside a fragment.I know how to add it in activity but I have no idea how to add horizontal scroll view in fragment?
0debug
Schedule a message in Slack : <p>I need to send a message in slack at a time set in advance.</p> <p>Is there a way to do it through the Slack API or do I need to have a script running and checking if it's time to send the message and then send it?</p>
0debug
how can i recursively track empty folders and put an .keep file in it? : <p>In order to push empty folders into git, i want to use a recursive windows command to track those empty folders and put a ".keep" file in them.</p> <p>Thanks</p>
0debug
What type of ML algorithm / model should I use for prediction? : <p>I apologize this might be a poorly asked question, Im looking for more of a point in the right direction to start research. </p> <p>So say I have large sets of Array data. Ill be easiest to give an example:</p> <pre><code>[{a: 1}, {h: 3}, {r:7}, {p: 2}] [{y: 4}, {p: 3}, {w: -3}, {u: 54}] [{l: -9}, {h: 5}, {r: 9}, {p: 5}] [{o: -5}, {f: 4}, {i: 0}, {t: 1}] [{a: 1}, {h: 2}, {r:5}, {p: 2}] </code></pre> <p>Okay so the keys of the objects doesn't really matter. What I want to be able to do is train a model on these objects by saying which list is 'good' and which list is 'bad'. From the example data above, if the 1st , 3rd, 5th list is 'good' and the 2nd and 4th are 'bad' I want the model to be able to identify that they all share the similar factors of h, r, p, that h, r, p are positive value (or negative or something of that form), and that they are in the same order in the list. so for example if I were to pass in <code>[{h: 2}, {a: 1}, {p: 2}, {r:5}]</code> as bad I would be able to separate it out as a different order. So basically I want to be able to identify what is most likely to results in a 'good' list be comparing similarities.</p>
0debug
SQL server, get record which having both skills : I have a employee table and a skill table. In skills table, i have entries like (empid, skills) (1, C#) (1, PHP) (2, C#) (2, Java) now i want record which is having both C# and java
0debug
int ioinst_handle_msch(CPUS390XState *env, uint64_t reg1, uint32_t ipb) { int cssid, ssid, schid, m; SubchDev *sch; SCHIB *schib; uint64_t addr; int ret = -ENODEV; int cc; hwaddr len = sizeof(*schib); if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { program_interrupt(env, PGM_OPERAND, 2); return -EIO; } trace_ioinst_sch_id("msch", cssid, ssid, schid); addr = decode_basedisp_s(env, ipb); if (addr & 3) { program_interrupt(env, PGM_SPECIFICATION, 2); return -EIO; } schib = s390_cpu_physical_memory_map(env, addr, &len, 0); if (!schib || len != sizeof(*schib)) { program_interrupt(env, PGM_ADDRESSING, 2); cc = -EIO; goto out; } if (!ioinst_schib_valid(schib)) { program_interrupt(env, PGM_OPERAND, 2); cc = -EIO; goto out; } sch = css_find_subch(m, cssid, ssid, schid); if (sch && css_subch_visible(sch)) { ret = css_do_msch(sch, schib); } switch (ret) { case -ENODEV: cc = 3; break; case -EBUSY: cc = 2; break; case 0: cc = 0; break; default: cc = 1; break; } out: s390_cpu_physical_memory_unmap(env, schib, len, 0); return cc; }
1threat
Ruby array of hashes find values by key : <p>I have an array like below</p> <blockquote> <p>[{500=>{"id"=>1, "name"=>"Hock Tong Bee Pte Ltd/ Corner stone wines", "created_at"=>Thu, 19 Jan 2017 18:10:35 UTC +00:00, "updated_at"=>Thu, 19 Jan 2017 18:10:35 UTC +00:00, "website"=>nil, "status"=>nil, "industry_type_id"=>1, "major_category_id"=>1, "minor_category_id"=>75, "save_as_draft"=>false, "company_id"=>1}}, {600=>{"id"=>2, "name"=>"Continental Wines", "created_at"=>Thu, 19 Jan 2017 18:10:35 UTC +00:00, "updated_at"=>Thu, 19 Jan 2017 18:10:35 UTC +00:00, "website"=>nil, "status"=>nil, "industry_type_id"=>1, "major_category_id"=>1, "minor_category_id"=>75, "save_as_draft"=>false, "company_id"=>2}}]</p> </blockquote> <p>I have key's like 500/600 from this array i want tot get that object. I need to write one method, I will pass key only that should return appropriate object. Example if I send key is 500 result should be </p> <blockquote> <p>{"id"=>1, "name"=>"Hock Tong Bee Pte Ltd/ Corner stone wines", "created_at"=>Thu, 19 Jan 2017 18:10:35 UTC +00:00, "updated_at"=>Thu, 19 Jan 2017 18:10:35 UTC +00:00, "website"=>nil, "status"=>nil, "industry_type_id"=>1, "major_category_id"=>1, "minor_category_id"=>75, "save_as_draft"=>false, "company_id"=>1}</p> </blockquote> <p>Anyone have idea on how to achieve this in Ruby?</p>
0debug
static void test_qemu_strtoul_hex(void) { const char *str = "0123"; char f = 'X'; const char *endptr = &f; unsigned long res = 999; int err; err = qemu_strtoul(str, &endptr, 16, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 0x123); g_assert(endptr == str + strlen(str)); str = "0x123"; res = 999; endptr = &f; err = qemu_strtoul(str, &endptr, 0, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, 0x123); g_assert(endptr == str + strlen(str)); }
1threat
static void fill_yuv_image(AVFrame *pict, int frame_index, int width, int height) { int x, y, i, ret; ret = av_frame_make_writable(pict); if (ret < 0) exit(1); i = frame_index; for (y = 0; y < height; y++) for (x = 0; x < width; x++) pict->data[0][y * pict->linesize[0] + x] = x + y + i * 3; for (y = 0; y < height / 2; y++) { for (x = 0; x < width / 2; x++) { pict->data[1][y * pict->linesize[1] + x] = 128 + y + i * 2; pict->data[2][y * pict->linesize[2] + x] = 64 + x + i * 5; } } }
1threat
Powershell - Copy files from local machine to server machine : <p>local machine = from where you are executing command Server machine = where you copy files.</p> <p>copy (localfile) to server machine</p>
0debug
static int dx2_decode_slice_420(GetBitContext *gb, AVFrame *frame, int line, int left, uint8_t lru[3][8]) { int x, y; int width = frame->width; int ystride = frame->linesize[0]; int ustride = frame->linesize[1]; int vstride = frame->linesize[2]; uint8_t *Y = frame->data[0] + ystride * line; uint8_t *U = frame->data[1] + (ustride >> 1) * line; uint8_t *V = frame->data[2] + (vstride >> 1) * line; for (y = 0; y < left - 1 && get_bits_left(gb) > 16; y += 2) { for (x = 0; x < width; x += 2) { Y[x + 0 + 0 * ystride] = decode_sym(gb, lru[0]); Y[x + 1 + 0 * ystride] = decode_sym(gb, lru[0]); Y[x + 0 + 1 * ystride] = decode_sym(gb, lru[0]); Y[x + 1 + 1 * ystride] = decode_sym(gb, lru[0]); U[x >> 1] = decode_sym(gb, lru[1]) ^ 0x80; V[x >> 1] = decode_sym(gb, lru[2]) ^ 0x80; } Y += ystride << 1; U += ustride; V += vstride; } return y; }
1threat
HMAC encryption in Swift 2 : <p>Java provides <a href="https://docs.oracle.com/javase/7/docs/api/javax/crypto/Mac.html" rel="nofollow">MAC(Message Authentication Code) algorithm API</a> with which I can encrypt <code>data</code> by: </p> <pre><code>byte[] data = getDataBytes(); Mac mac = Mac.getInstance("HMAC-SHA256"); mac.init(new SecretKeySpec(key, "HMAC-SHA256")); byte[] encryptedBytes = mac.doFinal(data); </code></pre> <p>I am new in Swift, how can I implement the same thing as above with Swift 2 ?</p>
0debug
int load_image_targphys(const char *filename, target_phys_addr_t addr, int max_sz) { int size; size = get_image_size(filename); if (size > 0) rom_add_file_fixed(filename, addr, -1); return size; }
1threat
python - space in folder name : <p>I have this next bit of code</p> <pre><code>Path = os.getenv('PATH') Path = Path.split(';') for i, p in enumerate(Path): if len(P) != 0 and p[-1] != "\\": Path[i] = p + "\\" #this adds '\' to the ending of each line </code></pre> <p>printing <code>Path[0]</code> will show</p> <p><code>C:\Program Files (x86)\Common Files\Oracle\Java\javapath\</code></p> <p>However, When I try to run anything from this folder, I get the error</p> <p><code>'C:\Program' is not recognized</code></p> <p>How can I make it search in the entire path and not stop at the space?</p>
0debug
Django (TypeError): __init__() got an unexpected keyword argument 'widget' : <p>I have the problem that, when i run my website it comes with two Type Errors. I do not know what it is i need to edit, but i know it is in the models.py file.</p> <p><strong>Error 1:</strong></p> <pre><code>Unhandled exception in thread started by &lt;function check_errors.&lt;locals&gt;.wrapper at 0x000001D025692400&gt; Traceback (most recent call last): File "C:\Users\bruger\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper fn(*args, **kwargs) File "C:\Users\bruger\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run autoreload.raise_last_exception() File "C:\Users\bruger\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 248, in raise_last_exception raise _exception[1] File "C:\Users\bruger\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 337, in execute autoreload.check_errors(django.setup)() File "C:\Users\bruger\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper fn(*args, **kwargs) File "C:\Users\bruger\AppData\Local\Programs\Python\Python37\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\bruger\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 112, in populate app_config.import_models() File "C:\Users\bruger\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\config.py", line 198, in import_models self.models_module = import_module(models_module_name) File "C:\Users\bruger\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "&lt;frozen importlib._bootstrap&gt;", line 1006, in _gcd_import File "&lt;frozen importlib._bootstrap&gt;", line 983, in _find_and_load File "&lt;frozen importlib._bootstrap&gt;", line 967, in _find_and_load_unlocked File "&lt;frozen importlib._bootstrap&gt;", line 677, in _load_unlocked File "&lt;frozen importlib._bootstrap_external&gt;", line 728, in exec_module File "&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed File "C:\Users\bruger\Dropbox\min-login-web\web_login\users\models.py", line 25, in &lt;module&gt; class Desc(models.Model): File "C:\Users\bruger\Dropbox\min-login-web\web_login\users\models.py", line 26, in Desc description = models.CharField(widget = forms.Textarea, max_length = 250, required=False) File "C:\Users\bruger\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\fields\__init__.py", line 1037, in __init__ super().__init__(*args, **kwargs) TypeError: __init__() got an unexpected keyword argument 'widget' </code></pre> <p><strong>Error 2:</strong></p> <pre><code>Unhandled exception in thread started by &lt;function check_errors.&lt;locals&gt;.wrapper at 0x00000239D4B82400&gt; Traceback (most recent call last): File "C:\Users\bruger\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper fn(*args, **kwargs) File "C:\Users\bruger\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run autoreload.raise_last_exception() File "C:\Users\bruger\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 248, in raise_last_exception raise _exception[1] File "C:\Users\bruger\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 337, in execute autoreload.check_errors(django.setup)() File "C:\Users\bruger\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper fn(*args, **kwargs) File "C:\Users\bruger\AppData\Local\Programs\Python\Python37\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\bruger\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 112, in populate app_config.import_models() File "C:\Users\bruger\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\config.py", line 198, in import_models self.models_module = import_module(models_module_name) File "C:\Users\bruger\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "&lt;frozen importlib._bootstrap&gt;", line 1006, in _gcd_import File "&lt;frozen importlib._bootstrap&gt;", line 983, in _find_and_load File "&lt;frozen importlib._bootstrap&gt;", line 967, in _find_and_load_unlocked File "&lt;frozen importlib._bootstrap&gt;", line 677, in _load_unlocked File "&lt;frozen importlib._bootstrap_external&gt;", line 728, in exec_module File "&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed File "C:\Users\bruger\Dropbox\min-login-web\web_login\users\models.py", line 25, in &lt;module&gt; class Desc(models.Model): File "C:\Users\bruger\Dropbox\min-login-web\web_login\users\models.py", line 26, in Desc description = models.CharField(max_length = 250, required=False) File "C:\Users\bruger\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\fields\__init__.py", line 1037, in __init__ super().__init__(*args, **kwargs) TypeError: __init__() got an unexpected keyword argument 'required' </code></pre> <p>Here is my models.py, which the errors is in.</p> <p><strong>Models.py</strong></p> <pre><code>from django import forms from django.db import models from django.db.models.signals import post_save from django.contrib.auth.models import User from PIL import Image class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) image = models.ImageField(default='default.jpg', upload_to='profile_pics') def __str__(self): return f'{self.user.username} Profile' def save(self): super().save() img = Image.open(self.image.path) if img.height &gt; 300 or img.width &gt; 300: output_size = (300, 300) img.thumbnail(output_size) img.save(self.image.path) class Desc(models.Model): description = models.CharField(widget = forms.Textarea, max_length = 250, required=False) def __str__(self): return f'{self.user.username} Desc' </code></pre> <p>I hope somebody can help, because im not that good at programming python, because i started this week. :D</p>
0debug
Do I need to use an API to create an Andriod app that will direct to a radio station web site? : I am building an Andriod mobile application which will be coded to direct itself to a web site for a single radio station. Will it open and play what is on the station by coding the url into the app, or do I need an API? If so, where can I find one to use and possibly information about integrating it into the app?
0debug
static uint64_t vfio_bar_read(void *opaque, hwaddr addr, unsigned size) { VFIOBAR *bar = opaque; union { uint8_t byte; uint16_t word; uint32_t dword; uint64_t qword; } buf; uint64_t data = 0; if (pread(bar->fd, &buf, size, bar->fd_offset + addr) != size) { error_report("%s(,0x%"HWADDR_PRIx", %d) failed: %m", __func__, addr, size); return (uint64_t)-1; } switch (size) { case 1: data = buf.byte; break; case 2: data = le16_to_cpu(buf.word); break; case 4: data = le32_to_cpu(buf.dword); break; default: hw_error("vfio: unsupported read size, %d bytes\n", size); break; } DPRINTF("%s(BAR%d+0x%"HWADDR_PRIx", %d) = 0x%"PRIx64"\n", __func__, bar->nr, addr, size, data); vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr])); return data; }
1threat
How does reloadOnChange of Microsoft.Extensions.Configuration work for appsettings.json : <p>In two projects (a .NET Core Web API and a .NET Core WindowsService) I am using appsettings.json for the configuration. </p> <pre><code> var configuration = new ConfigurationBuilder() .SetBasePath(System.IO.Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddEnvironmentVariables() .Build(); </code></pre> <p>In both I have the reloadOnChange set to true and using it as injected <code>IOptions</code> via dependency injection. Within the web api into the controller classes and within the service into the classes that use the settings.</p> <p>Unfortunatly I experience that the values do not change when the appsettings.json changes.</p> <p>On the web api I created a controller to just return a string value from the config and this stays the same as on startup.</p> <p>So my questions:</p> <ol> <li>Anyone knows if that should work out of the box (at least in the web api)?</li> <li>Anything I have to do that it works?</li> </ol>
0debug
static void *build_pci_bus_begin(PCIBus *bus, void *parent_state) { AcpiBuildPciBusHotplugState *parent = parent_state; AcpiBuildPciBusHotplugState *child = g_malloc(sizeof *child); build_pci_bus_state_init(child, parent, parent->pcihp_bridge_en); return child; }
1threat
How to optimize python snippet? : def nonrep1(n): return sum(all(c != d for c, d in zip(str(i), str(i)[1:])) for i in xrange(1, n+1)) I have to optimize this code, how do I do that?? test case 1 simple input 7 simple output 7 test case 2 simple input 3456 simple output 2562
0debug
Cmder bash script executing : <p>I created basic script in Windows.</p> <pre><code>#!/bin/bash echo Hello </code></pre> <p>I am using Cmder, ConEmu derivative. I tried to change the priviliges with chmod, but they are the same. I don't know how can I execute this script. Normal Linux way, which is: ./hello.sh does not work, and typing just hello.sh makes Windows try to open it, which is bad, since I want it in console. How to execute this script in ConEmu/Cmder?</p>
0debug
Spliting 2 Words in Excel before the last capital Letter? : <p>I am trying to figure out how to split a single word into 2 separate words in excel.</p> <p>e.g. input word: BTCBitcoin</p> <pre><code> Desired output: BTC Bitcoin </code></pre> <p>any suggestions?</p> <p>Thanks.</p>
0debug
I am getting a Fatal Exception: Main : <p>I am very new to android and just learning on the fly mostly from tutorial videos. I am having an issue where I am getting a fatal exception when I try to run the app. I believe the portion of the code generating the error is below, I have a char array of letters that I am trying to scramble and then set the text of certain buttons to those letters (i.e. letter1A.setText(scrambleLettersChar[0]). I did the same thing above this portion of the code and it worked just fine. TIA.</p> <pre><code>char[] solutionLetters = {letter1, letter2, letter3, letter4, letter5, letter6, letter7, letter8, letter9, letter10, letter11, letter12}; for (int i = 0; i &lt; solutionLetters.length; i++) { int randomIndex = (int) (Math.random() * solutionLetters.length); char temp = solutionLetters[i]; solutionLetters[i] = solutionLetters[randomIndex]; solutionLetters[randomIndex] = temp; } String scrambleLettersString = new String(solutionLetters); scrambleLettersChar = scrambleLettersString.toCharArray(); letter1A.setText(scrambleLettersChar[0]); } </code></pre>
0debug
static av_always_inline int simple_limit(uint8_t *p, ptrdiff_t stride, int flim) { LOAD_PIXELS return 2*FFABS(p0-q0) + (FFABS(p1-q1) >> 1) <= flim; }
1threat
Amazon CodeCommit Error: git: 'credential-aws' is not a git command : <p>I am new to AWS world and I am implementing Continuous Delivery to the company I work for.</p> <p>I followed this instructions to configure CodeCommit Service: <a href="http://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-https-windows.html#setting-up-https-windows-account" rel="noreferrer">http://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-https-windows.html#setting-up-https-windows-account</a></p> <p><b>Step 1: Initial Configuration for AWS CodeCommit</b></p> <p><i>To create and configure an IAM user for accessing AWS CodeCommit</i>: I created a new IAM user and gave him AWSCodeCommitFullAcess</p> <p><i> To install and configure the AWS CLI </i>: I installed and configured the credentials doing <em>aws configure</em> (setting AWS Access Key ID, AWS Secret Access Key, Default region name to us-east-1 and de</p> <p><b> Step 2: Install Git </b> I installed GIT for windows making sure the Enable Git Credential Manager option was cleared.</p> <p><b> Step 3: Set Up the Credential Helper </b> I execute these commands:</p> <pre><code>git config --global credential.helper "!aws codecommit credential-helper $@" git config --global credential.UseHttpPath true </code></pre> <p>Executing:</p> <pre><code>git config --global --edit </code></pre> <p>I have:<br> [http]<br> sslVerify = false</p> <p>[credential]<br> helper = "aws codecommit list-repositories codecommit credential-helper " <br>UseHttpPath = true</p> <p><strong>Step 4: Connect to the AWS CodeCommit Console and Clone the Repository</strong></p> <pre><code>$ git clone https://git-codecommit.us-east-1.amazonaws.com/v1/repos/teste-git-to-s3&lt;br&gt; Cloning into 'teste-git-to-s3'...&lt;br&gt; git: 'credential-aws' is not a git command. See 'git --help'.&lt;br&gt; Username for 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/teste-git-to-s3': Lucas&lt;br&gt; fatal: unable to access 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/teste-git-to-s3/': The requested URL returned error: 403 </code></pre> <p>Looking for Troubleshooting solutions on aws, I found: <a href="http://docs.aws.amazon.com/codecommit/latest/userguide/troubleshooting.html#troubleshooting-ae1" rel="noreferrer">http://docs.aws.amazon.com/codecommit/latest/userguide/troubleshooting.html#troubleshooting-ae1</a> but I could'nt solve it.</p> <p>Does any one know how to solve this? Pleeeeease, help!</p>
0debug
android apk faild to build after adding a background image : **Unfortunately app stopped working ** after building apk with background image. I am a newbie to android, I thought of developing a beginner app likely(note app in phones). It was far good till applying a background image in .xml file. after the update, the apk file failed to run in mobile. Can any one suggest where I gone wrong? [enter image description here][1] [1]: https://i.stack.imgur.com/5pfNC.jpg
0debug
static void nam_writel (void *opaque, uint32_t addr, uint32_t val) { PCIAC97LinkState *d = opaque; AC97LinkState *s = &d->ac97; dolog ("U nam writel %#x <- %#x\n", addr, val); s->cas = 0; }
1threat
Delphi - How to use Alt Codes? : Delphi RIO - I need to build a string which contains Alt Codes, specifically Alt-16 (Arrow symbol). I have a line of text (aka a string). I append a Carriage return, then want an ARROW symbol and the new line of text. This line will then be passed to PPT. If I manually go into PPT, into a text box, I can hit Alt+16, and get the arrow symbol. This is what I programatically want to do. Alt symbols found [here][1]. Here is what I am trying, but it gives me a totally different symbol. line := line + #13 + Chr(VK_MENU) + #16 + NewLine; How do I build a string with ALT Codes as part of the string? [1]: https://www.alt-codes.net/
0debug
Excel Macro to compare two columns in two different sheets and replace thier value with a sequential number : how to create a macro that students ID in two columns in two different worksheets and change their values to a new sequential number
0debug
static void empty_input(void) { const char *empty = ""; QObject *obj = qobject_from_json(empty, NULL); g_assert(obj == NULL); }
1threat
React.js: Set innerHTML vs dangerouslySetInnerHTML : <p>Is there any "behind the scenes" difference from setting an element's innerHTML vs setting the dangerouslySetInnerHTML property on an element? Assume I'm properly sanitizing things for the sake of simplicity.</p> <p>Example:</p> <pre><code>var test = React.createClass({ render: function(){ return ( &lt;div contentEditable='true' dangerouslySetInnerHTML={{ __html: "Hello" }}&gt;&lt;/div&gt; ); } }); </code></pre> <p>vs</p> <pre><code>var test = React.createClass({ componentDidUpdate: function(prevProp, prevState){ this.refs.test.innerHTML = "Hello"; }, render: function(){ return ( &lt;div contentEditable='true' ref='test'&gt;&lt;/div&gt; ); } }); </code></pre> <p>I'm doing something a bit more complicated than the above example, but the overall idea is the same</p>
0debug
How do I query this (json looking) data? - Python : I have this data coming via an api and I want to pull all the "confidence" scores that are in there. How would I go about doing that: b'{"time":765,"annotations":[{"start":106,"end":115,"spot":"customers","confidence":0.7198,"id":234206,"title":"Customer","uri":"h' b'ttp://en.wikipedia.org/wiki/Customer","label":"Customer"},{"start":116,"end":122,"spot":"online","confidence":0.6313,"id":41440,' b'"title":"Online and offline","uri":"http://en.wikipedia.org/wiki/Online_and_offline","label":"Online"},{"start":138,"end":143,"s' b'pot":"small","confidence":0.7233,"id":276495,"title":"Small business","uri":"http://en.wikipedia.org/wiki/Small_business","label' b'":"Small business"},{"start":144,"end":149,"spot":"firms","confidence":0.655,"id":219287,"title":"Legal personality","uri":"http' b'://en.wikipedia.org/wiki/Legal_personality","label":"Legal personality"},{"start":174,"end":182,"spot":"exposure","confidence":0' b'.7016,"id":245583,"title":"Publicity","uri":"http://en.wikipedia.org/wiki/Publicity","label":"Publicity"},{"start":232,"end":239' b',"spot":"budgets","confidence":0.6104,"id":377116,"title":"Budget","uri":"http://en.wikipedia.org/wiki/Budget","label":"Budget"}' b',{"start":268,"end":290,"spot":"social media marketing","confidence":0.7992,"id":21179478,"title":"Social media marketing","uri"' b':"http://en.wikipedia.org/wiki/Social_media_marketing","label":"Social media marketing"},{"start":434,"end":439,"spot":"firms","' b'confidence":0.6336,"id":39206,"title":"Business","uri":"http://en.wikipedia.org/wiki/Business","label":"Business"},{"start":455,' b'"end":463,"spot":"exposure","confidence":0.6613,"id":245583,"title":"Publicity","uri":"http://en.wikipedia.org/wiki/Publicity","' b'label":"Publicity"},{"start":489,"end":498,"spot":"customers","confidence":0.6573,"id":234206,"title":"Customer","uri":"http://e' b'n.wikipedia.org/wiki/Customer","label":"Customer"},{"start":557,"end":573,"spot":"small businesses","confidence":0.6299,"id":276' b'495,"title":"Small business","uri":"http://en.wikipedia.org/wiki/Small_business","label":"Small business"},{"start":630,"end":63' b'5,"spot":"risks","confidence":0.6431,"id":26404,"title":"Risk management","uri":"http://en.wikipedia.org/wiki/Risk_management","' b'label":"Risk management"}...} I tried doing things like data["confidence"], but it didn't seem to pull the confidence figures. How do I pull the confidence figures in Python? Thank you in advance.
0debug
static int mov_read_stss(MOVContext *c, ByteIOContext *pb, MOVAtom atom) { AVStream *st = c->fc->streams[c->fc->nb_streams-1]; MOVStreamContext *sc = st->priv_data; unsigned int i, entries; get_byte(pb); get_be24(pb); entries = get_be32(pb); dprintf(c->fc, "keyframe_count = %d\n", entries); if(entries >= UINT_MAX / sizeof(int)) return -1; sc->keyframes = av_malloc(entries * sizeof(int)); if (!sc->keyframes) return AVERROR(ENOMEM); sc->keyframe_count = entries; for(i=0; i<entries; i++) { sc->keyframes[i] = get_be32(pb); } return 0; }
1threat
Problems with sessions in cakePHP : <p>Hello I am new to cakePHP and follow some nice online tuts. Now i have a problem i can't solve so here i am.</p> <pre><code> public function beforeFilter(){ parent::beforeFilter(); if($this-&gt;request-&gt;action != 'login' &amp;&amp; !this-&gt;Session-&gt;check('User')){ $this-&gt;Flash-&gt;error(__('U probeert toegang te krijgen tot een beveiligde omgeving')); return $this-&gt;redirect(array('controller' =&gt; 'users', 'action' =&gt; 'login')); } </code></pre> <p>}</p> <p>I think it is a bit old and the check need SessionComponent::check($name). But how ?? i can't get it to work.</p> <p>I use cakePHP 2.8</p> <p>Paul</p>
0debug
Firebase Auth Ui Google Sign In Code:10, message:10: : <p>Firebase Auth Ui Google Sign In Code:10, message:10:</p> <p>I use firebase auth-ui to sign in with google,</p> <p>it toasted</p> <blockquote> <p>Code:10, message:10:</p> </blockquote> <pre><code>implementation 'com.firebaseui:firebase-ui-auth:4.1.0' </code></pre>
0debug
Create object id from JSON key value using jq : <p>I am trying to restructure my JSON by assigning an id to each object in a given array. This id would be created by using an existing key value (osm_id). </p> <p>This is my input:</p> <pre><code>[ { "geometry" : { "coordinates" : [ -0.7118478, 51.0930284 ], "type" : "Point" }, "properties" : { "osm_id" : "262661", "religion" : "christian" }, "type" : "Feature" }, { "geometry" : { "coordinates" : [ -0.7207513, 51.0897118 ], "type" : "Point" }, "properties" : { "denomination" : "catholic", "osm_id" : "262662", "religion" : "christian" }, "type" : "Feature" } ] </code></pre> <p>This is my desired output:</p> <pre><code>[ "262661": { "geometry": { "coordinates": [ -0.7118478, 51.0930284 ], "type": "Point" }, "properties": { "osm_id": "262661", "religion": "christian" }, "type": "Feature" }, "262662": { "geometry": { "coordinates": [ -0.7207513, 51.0897118 ], "type": "Point" }, "properties": { "denomination": "catholic", "osm_id": "262662", "religion": "christian" }, "type": "Feature" } ] </code></pre> <p>I've been trying to work with jq to update the data, but I can't figure out how to assign that top level id. So far I have </p> <pre><code>.[] |= {geometry, properties, type} </code></pre> <p>but anything further results in errors. </p> <p>I appreciate any help or input. </p>
0debug
My SQL query ! What's wrong here? : please tell me what's wrong here: INSERT INTO `tbl_verkauf_am`(`fld_kdnr`, `fld_artikelnummer`, `fld_artikelbez1`, `fld_saal_lst`, `fld_anzahl`, `fld_preis`) VALUES (900000, (SELECT `id`, `fld_besch_0`, `fld_class` FROM `tbl_saal_koord` WHERE `id` < 20300), 1, 50) Thanks
0debug
Filtering a dataframe : <p>I have a main dataframe called <code> main </code> and a subset of this dataframe called <code> main1 </code>. I want to create a dataframe <code> main2 </code> which is includes everything in <code> main </code> which is not <code> main1 </code>. How would I do this?</p>
0debug
Align material icon vertically : <p>I am trying to vertically align my "dropdown arrow" in a naviation menu.</p> <p>I have tried varioust hings like vertical-align: middle, display: inline-block and stuff like that but that didn't help at all. <a href="http://img02.imgland.net/jfCmDoW.png" rel="noreferrer">http://img02.imgland.net/jfCmDoW.png</a></p> <p><strong>The HTML looks like this:</strong></p> <pre><code> &lt;li&gt; &lt;a href="#!" data-activates="dropdown1"&gt;English &lt;i class="material-icons"&gt;arrow_drop_down&lt;/i&gt; &lt;/a&gt; &lt;/li&gt; </code></pre> <p>I have created a JSFiddle which demonstrates the problem: <a href="https://jsfiddle.net/dbwaoLrh/" rel="noreferrer">https://jsfiddle.net/dbwaoLrh/</a></p> <p>Explanations of what I am doing wrong there are highly appreciated as I face this issue every time I am using "custom" font sizes using the materialize-framework.</p>
0debug
how to handle Array of column coming from UDF in spark dataframe : I am trying to concatenate the Array of column in spark dataframe i am recieving the Array of column through a spark scala UDF but I am getting below my code :- val sampleDf = sparksession.createDataFrame( List(("00", "DELHI", "111", "222", "333"), ("00", "SP", "123123123", "231231231", "312312312") )).toDF("RecordType", "CITY", "key1", "key2", "key3") //.printSchema() //.show(100,false) val test2 = sampleDf.withColumn("primayKEY",concat(getprimakey(aaa)(col("RecordType"),col("CITY"))): _*).show()//.printSchema()//show(false) } def getprimakey (mapconfig: Map[(String, String), (List[String], List[String])]) = udf((rec:String ,layout:String) => { println(rec+""+layout) val s = mapconfig(rec,layout)._1.map(x => col(x)).toArray//.map(x => col(x)) s }) Below is the error I am getting Exception in thread "main" java.lang.UnsupportedOperationException: Schema for type org.apache.spark.sql.Column is not supported at org.apache.spark.sql.catalyst.ScalaReflection$.schemaFor(ScalaReflection.scala:733) at org.apache.spark.sql.catalyst.ScalaReflection$.schemaFor(ScalaReflection.scala:693) at org.apache.spark.sql.catalyst.ScalaReflection$.schemaFor(ScalaReflection.scala:671) at org.apache.spark.sql.functions$.udf(functions.scala:3088) at com.rupesh.TEST_UDF$.getprimakey(TEST_UDF.scala:29) at com.rupesh.TEST_UDF$.main(TEST_UDF.scala:19) at com.rupesh.TEST_UDF.main(TEST_UDF.scala)
0debug
static int __qemu_rdma_delete_block(RDMAContext *rdma, ram_addr_t block_offset) { RDMALocalBlocks *local = &rdma->local_ram_blocks; RDMALocalBlock *block = g_hash_table_lookup(rdma->blockmap, (void *) block_offset); RDMALocalBlock *old = local->block; int x; assert(block); if (block->pmr) { int j; for (j = 0; j < block->nb_chunks; j++) { if (!block->pmr[j]) { continue; } ibv_dereg_mr(block->pmr[j]); rdma->total_registrations--; } g_free(block->pmr); block->pmr = NULL; } if (block->mr) { ibv_dereg_mr(block->mr); rdma->total_registrations--; block->mr = NULL; } g_free(block->transit_bitmap); block->transit_bitmap = NULL; g_free(block->unregister_bitmap); block->unregister_bitmap = NULL; g_free(block->remote_keys); block->remote_keys = NULL; for (x = 0; x < local->nb_blocks; x++) { g_hash_table_remove(rdma->blockmap, (void *)old[x].offset); } if (local->nb_blocks > 1) { local->block = g_malloc0(sizeof(RDMALocalBlock) * (local->nb_blocks - 1)); if (block->index) { memcpy(local->block, old, sizeof(RDMALocalBlock) * block->index); } if (block->index < (local->nb_blocks - 1)) { memcpy(local->block + block->index, old + (block->index + 1), sizeof(RDMALocalBlock) * (local->nb_blocks - (block->index + 1))); } } else { assert(block == local->block); local->block = NULL; } DDPRINTF("Deleted Block: %d, addr: %" PRIu64 ", offset: %" PRIu64 " length: %" PRIu64 " end: %" PRIu64 " bits %" PRIu64 " chunks %d\n", local->nb_blocks, (uint64_t) block->local_host_addr, block->offset, block->length, (uint64_t) (block->local_host_addr + block->length), BITS_TO_LONGS(block->nb_chunks) * sizeof(unsigned long) * 8, block->nb_chunks); g_free(old); local->nb_blocks--; if (local->nb_blocks) { for (x = 0; x < local->nb_blocks; x++) { g_hash_table_insert(rdma->blockmap, (void *)local->block[x].offset, &local->block[x]); } } return 0; }
1threat
How to host multiple .NET Core apps under same url : <p>I am building a few web sites in asp.net core (multiple user interface applications and a web api app). They all work together, utilising the web api. For the purpose of my question we'll call them App1, App2 and App3. I am hosting my websites in IIS.</p> <p>Typically, in the old .net Framework (4.5.1), I would have one website in IIS, with multiple web apps to host my multiple applications. Like so:</p> <ul> <li><p>WebSite1 - running on port 443</p> <ul> <li><p>App1</p></li> <li><p>App2</p></li> <li><p>App3</p></li> </ul></li> </ul> <p>If the website (WebSite1) runs on port 443 (using the SSL cert), that means all apps are accessible via one domain url as follows:</p> <ul> <li><p><a href="https://www.myapp.com/App1/" rel="noreferrer">https://www.myapp.com/App1/</a></p></li> <li><p><a href="https://www.myapp.com/App2/" rel="noreferrer">https://www.myapp.com/App2/</a></p></li> <li><p><a href="https://www.myapp.com/App3/" rel="noreferrer">https://www.myapp.com/App3/</a></p></li> </ul> <p>With different app names at the end of the url to identify them.</p> <p>When hosting the new asp.NET Core applications, I host in IIS as well, and following the documentation for asp.NET Core web site deployment, I host each .NET Core web app in a different site within IIS. </p> <p>As I have one domain name for all my sites, for example, <a href="https://www.example.com" rel="noreferrer">https://www.example.com</a> (I'm using an SSL cert), I have to give the other websites different ports. So I end up with something like this:</p> <ul> <li><p>WebSite1 - running on port 443</p></li> <li><p>WebSite2 - running on port 444</p></li> <li><p>WebSite3 - running on port 445</p></li> </ul> <p>All of these apps are then accessible via these domain name urls:</p> <ul> <li><p><a href="https://www.example.com/" rel="noreferrer">https://www.example.com/</a> or <a href="https://www.example.com:443/" rel="noreferrer">https://www.example.com:443/</a></p></li> <li><p><a href="https://www.example.com:444/" rel="noreferrer">https://www.example.com:444/</a></p></li> <li><p><a href="https://www.example.com:445/" rel="noreferrer">https://www.example.com:445/</a></p></li> </ul> <p>How do I host asp.NET Core applications all under one website as different "Applications", meaning they resolve to the same domain name url (<a href="https://www.example.com" rel="noreferrer">https://www.example.com</a> and the forward slash app name identifies which app we want)? OR alternatively, how do I take what I have configured now with the ports and route them all so App1 is default for example.com/, App 2 is example.com/app2/, and App 3 is example.com/app3/?</p> <p>Am I looking at this .NET Core deployment completely the wrong way?</p> <p>Thanks in advance for any pointers!</p>
0debug
i am getting an error in the cpanel when uploding a laravel project : this is the error note it is on cpanel it works in my local host: Parse error: syntax error, unexpected '?' in /home/hfindcok/public_html/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 242
0debug
int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum PixelFormat pix_fmt, int padtop, int padbottom, int padleft, int padright, int *color) { uint8_t *optr; int y_shift; int x_shift; int yheight; int i, y; if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB || !is_yuv_planar(&pix_fmt_info[pix_fmt])) return -1; for (i = 0; i < 3; i++) { x_shift = i ? av_pix_fmt_descriptors[pix_fmt].log2_chroma_w : 0; y_shift = i ? av_pix_fmt_descriptors[pix_fmt].log2_chroma_h : 0; if (padtop || padleft) { memset(dst->data[i], color[i], dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift)); } if (padleft || padright) { optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) + (dst->linesize[i] - (padright >> x_shift)); yheight = (height - 1 - (padtop + padbottom)) >> y_shift; for (y = 0; y < yheight; y++) { memset(optr, color[i], (padleft + padright) >> x_shift); optr += dst->linesize[i]; } } if (src) { uint8_t *iptr = src->data[i]; optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift); memcpy(optr, iptr, (width - padleft - padright) >> x_shift); iptr += src->linesize[i]; optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) + (dst->linesize[i] - (padright >> x_shift)); yheight = (height - 1 - (padtop + padbottom)) >> y_shift; for (y = 0; y < yheight; y++) { memset(optr, color[i], (padleft + padright) >> x_shift); memcpy(optr + ((padleft + padright) >> x_shift), iptr, (width - padleft - padright) >> x_shift); iptr += src->linesize[i]; optr += dst->linesize[i]; } } if (padbottom || padright) { optr = dst->data[i] + dst->linesize[i] * ((height - padbottom) >> y_shift) - (padright >> x_shift); memset(optr, color[i],dst->linesize[i] * (padbottom >> y_shift) + (padright >> x_shift)); } } return 0; }
1threat
document.write('<script src="evil.js"></script>');
1threat
static void gen_test_cc(int cc, int label) { TCGv tmp; TCGv tmp2; int inv; switch (cc) { case 0: tmp = load_cpu_field(ZF); tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, label); break; case 1: tmp = load_cpu_field(ZF); tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, label); break; case 2: tmp = load_cpu_field(CF); tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, label); break; case 3: tmp = load_cpu_field(CF); tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, label); break; case 4: tmp = load_cpu_field(NF); tcg_gen_brcondi_i32(TCG_COND_LT, tmp, 0, label); break; case 5: tmp = load_cpu_field(NF); tcg_gen_brcondi_i32(TCG_COND_GE, tmp, 0, label); break; case 6: tmp = load_cpu_field(VF); tcg_gen_brcondi_i32(TCG_COND_LT, tmp, 0, label); break; case 7: tmp = load_cpu_field(VF); tcg_gen_brcondi_i32(TCG_COND_GE, tmp, 0, label); break; case 8: inv = gen_new_label(); tmp = load_cpu_field(CF); tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, inv); dead_tmp(tmp); tmp = load_cpu_field(ZF); tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, label); gen_set_label(inv); break; case 9: tmp = load_cpu_field(CF); tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, label); dead_tmp(tmp); tmp = load_cpu_field(ZF); tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, label); break; case 10: tmp = load_cpu_field(VF); tmp2 = load_cpu_field(NF); tcg_gen_xor_i32(tmp, tmp, tmp2); dead_tmp(tmp2); tcg_gen_brcondi_i32(TCG_COND_GE, tmp, 0, label); break; case 11: tmp = load_cpu_field(VF); tmp2 = load_cpu_field(NF); tcg_gen_xor_i32(tmp, tmp, tmp2); dead_tmp(tmp2); tcg_gen_brcondi_i32(TCG_COND_LT, tmp, 0, label); break; case 12: inv = gen_new_label(); tmp = load_cpu_field(ZF); tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, inv); dead_tmp(tmp); tmp = load_cpu_field(VF); tmp2 = load_cpu_field(NF); tcg_gen_xor_i32(tmp, tmp, tmp2); dead_tmp(tmp2); tcg_gen_brcondi_i32(TCG_COND_GE, tmp, 0, label); gen_set_label(inv); break; case 13: tmp = load_cpu_field(ZF); tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, label); dead_tmp(tmp); tmp = load_cpu_field(VF); tmp2 = load_cpu_field(NF); tcg_gen_xor_i32(tmp, tmp, tmp2); dead_tmp(tmp2); tcg_gen_brcondi_i32(TCG_COND_LT, tmp, 0, label); break; default: fprintf(stderr, "Bad condition code 0x%x\n", cc); abort(); } dead_tmp(tmp); }
1threat
static int fic_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { FICContext *ctx = avctx->priv_data; uint8_t *src = avpkt->data; int ret; int slice, nslices; int msize; int tsize; uint8_t *sdata; if ((ret = ff_reget_buffer(avctx, ctx->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return ret; } if (avpkt->size < FIC_HEADER_SIZE + 4) { av_log(avctx, AV_LOG_ERROR, "Frame data is too small.\n"); return AVERROR_INVALIDDATA; } if (memcmp(src, fic_header, 7)) av_log(avctx, AV_LOG_WARNING, "Invalid FIC Header.\n"); if (src[17]) goto skip; nslices = src[13]; if (!nslices) { av_log(avctx, AV_LOG_ERROR, "Zero slices found.\n"); return AVERROR_INVALIDDATA; } ctx->qmat = src[23] ? fic_qmat_hq : fic_qmat_lq; tsize = AV_RB24(src + 24); if (tsize > avpkt->size - FIC_HEADER_SIZE) { av_log(avctx, AV_LOG_ERROR, "Invalid cursor data size.\n"); return AVERROR_INVALIDDATA; } ctx->slice_h = 16 * (ctx->aligned_height >> 4) / nslices; if (ctx->slice_h % 16) ctx->slice_h = FFALIGN(ctx->slice_h - 16, 16); sdata = src + tsize + FIC_HEADER_SIZE + 4 * nslices; msize = avpkt->size - nslices * 4 - tsize - FIC_HEADER_SIZE; if (msize <= 0) { av_log(avctx, AV_LOG_ERROR, "Not enough frame data to decode.\n"); return AVERROR_INVALIDDATA; } ctx->frame->key_frame = 1; ctx->frame->pict_type = AV_PICTURE_TYPE_I; av_fast_malloc(&ctx->slice_data, &ctx->slice_data_size, nslices * sizeof(ctx->slice_data[0])); if (!ctx->slice_data_size) { av_log(avctx, AV_LOG_ERROR, "Could not allocate slice data.\n"); return AVERROR(ENOMEM); } memset(ctx->slice_data, 0, nslices * sizeof(ctx->slice_data[0])); for (slice = 0; slice < nslices; slice++) { unsigned slice_off = AV_RB32(src + tsize + FIC_HEADER_SIZE + slice * 4); unsigned slice_size; int y_off = ctx->slice_h * slice; int slice_h = ctx->slice_h; if (slice == nslices - 1) { slice_size = msize; slice_h = FFALIGN(avctx->height - ctx->slice_h * (nslices - 1), 16); } else { slice_size = AV_RB32(src + tsize + FIC_HEADER_SIZE + slice * 4 + 4); } if (slice_size < slice_off || slice_size > msize) continue; slice_size -= slice_off; ctx->slice_data[slice].src = sdata + slice_off; ctx->slice_data[slice].src_size = slice_size; ctx->slice_data[slice].slice_h = slice_h; ctx->slice_data[slice].y_off = y_off; } if (ret = avctx->execute(avctx, fic_decode_slice, ctx->slice_data, NULL, nslices, sizeof(ctx->slice_data[0])) < 0) return ret; skip: *got_frame = 1; if ((ret = av_frame_ref(data, ctx->frame)) < 0) return ret; return avpkt->size; }
1threat
How to find the value stored in a particular index of a multiset in C++? : <p>Assume I have a multiset as {1,3,5,7,9}. I want to find what is the 3rd element in this multiset using C++. How can I do that without using a loop?</p>
0debug
static int bochs_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVBochsState *s = bs->opaque; uint32_t i; struct bochs_header bochs; int ret; bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false, errp); if (!bs->file) { return -EINVAL; } bdrv_set_read_only(bs, true); ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs)); if (ret < 0) { return ret; } if (strcmp(bochs.magic, HEADER_MAGIC) || strcmp(bochs.type, REDOLOG_TYPE) || strcmp(bochs.subtype, GROWING_TYPE) || ((le32_to_cpu(bochs.version) != HEADER_VERSION) && (le32_to_cpu(bochs.version) != HEADER_V1))) { error_setg(errp, "Image not in Bochs format"); return -EINVAL; } if (le32_to_cpu(bochs.version) == HEADER_V1) { bs->total_sectors = le64_to_cpu(bochs.extra.redolog_v1.disk) / 512; } else { bs->total_sectors = le64_to_cpu(bochs.extra.redolog.disk) / 512; } s->catalog_size = le32_to_cpu(bochs.catalog); if (s->catalog_size > 0x100000) { error_setg(errp, "Catalog size is too large"); return -EFBIG; } s->catalog_bitmap = g_try_new(uint32_t, s->catalog_size); if (s->catalog_size && s->catalog_bitmap == NULL) { error_setg(errp, "Could not allocate memory for catalog"); return -ENOMEM; } ret = bdrv_pread(bs->file, le32_to_cpu(bochs.header), s->catalog_bitmap, s->catalog_size * 4); if (ret < 0) { goto fail; } for (i = 0; i < s->catalog_size; i++) le32_to_cpus(&s->catalog_bitmap[i]); s->data_offset = le32_to_cpu(bochs.header) + (s->catalog_size * 4); s->bitmap_blocks = 1 + (le32_to_cpu(bochs.bitmap) - 1) / 512; s->extent_blocks = 1 + (le32_to_cpu(bochs.extent) - 1) / 512; s->extent_size = le32_to_cpu(bochs.extent); if (s->extent_size < BDRV_SECTOR_SIZE) { error_setg(errp, "Extent size must be at least 512"); ret = -EINVAL; goto fail; } else if (!is_power_of_2(s->extent_size)) { error_setg(errp, "Extent size %" PRIu32 " is not a power of two", s->extent_size); ret = -EINVAL; goto fail; } else if (s->extent_size > 0x800000) { error_setg(errp, "Extent size %" PRIu32 " is too large", s->extent_size); ret = -EINVAL; goto fail; } if (s->catalog_size < DIV_ROUND_UP(bs->total_sectors, s->extent_size / BDRV_SECTOR_SIZE)) { error_setg(errp, "Catalog size is too small for this disk size"); ret = -EINVAL; goto fail; } qemu_co_mutex_init(&s->lock); return 0; fail: g_free(s->catalog_bitmap); return ret; }
1threat
static int configuration_post_load(void *opaque, int version_id) { SaveState *state = opaque; const char *current_name = MACHINE_GET_CLASS(current_machine)->name; if (strncmp(state->name, current_name, state->len) != 0) { error_report("Machine type received is '%s' and local is '%s'", state->name, current_name); return -EINVAL; } return 0; }
1threat
What does "unsqueeze" do in Pytorch? : <p>I'm looking at the documentation, and here is their example. I cannot understand how this example corresponds to their explanation: "Returns a new tensor with a dimension of size one inserted at the specified position."</p> <pre><code>&gt;&gt;&gt; x = torch.tensor([1, 2, 3, 4]) &gt;&gt;&gt; torch.unsqueeze(x, 0) tensor([[ 1, 2, 3, 4]]) &gt;&gt;&gt; torch.unsqueeze(x, 1) tensor([[ 1], [ 2], [ 3], [ 4]]) </code></pre>
0debug
document.getElementById('input').innerHTML = user_input;
1threat
static inline void RENAME(initFilter)(int16_t *filter, int16_t *filterPos, int *filterSize, int xInc, int srcW, int dstW, int filterAlign, int one) { int i; #ifdef HAVE_MMX asm volatile("emms\n\t"::: "memory"); #endif if(ABS(xInc - 0x10000) <10) { int i; *filterSize= (1 +(filterAlign-1)) & (~(filterAlign-1)); for(i=0; i<dstW*(*filterSize); i++) filter[i]=0; for(i=0; i<dstW; i++) { filter[i*(*filterSize)]=1; filterPos[i]=i; } } else if(xInc <= (1<<16) || sws_flags==SWS_FAST_BILINEAR) { int i; int xDstInSrc; if(sws_flags==SWS_BICUBIC) *filterSize= 4; else *filterSize= 2; *filterSize= (*filterSize +(filterAlign-1)) & (~(filterAlign-1)); xDstInSrc= xInc - 0x8000; for(i=0; i<dstW; i++) { int xx= (xDstInSrc>>16) - (*filterSize>>1) + 1; int j; filterPos[i]= xx; if(sws_flags == SWS_BICUBIC) { double d= ABS(((xx+1)<<16) - xDstInSrc)/(double)(1<<16); int y1,y2,y3,y4; double A= -0.75; y1 = (int)floor(0.5 + ( + A*d - 2.0*A*d*d + A*d*d*d) * 16384.0); y2 = (int)floor(0.5 + (+ 1.0 - (A+3.0)*d*d + (A+2.0)*d*d*d) * 16384.0); y3 = (int)floor(0.5 + ( - A*d + (2.0*A+3.0)*d*d - (A+2.0)*d*d*d) * 16384.0); y4 = (int)floor(0.5 + ( + A*d*d - A*d*d*d) * 16384.0); filter[i*(*filterSize) + 0]= y1; filter[i*(*filterSize) + 1]= y2; filter[i*(*filterSize) + 2]= y3; filter[i*(*filterSize) + 3]= y4; } else { for(j=0; j<*filterSize; j++) { double d= ABS((xx<<16) - xDstInSrc)/(double)(1<<16); int coeff; coeff= (int)(0.5 + (1.0 - d)*(1<<14)); if(coeff<0) coeff=0; filter[i*(*filterSize) + j]= coeff; xx++; } } xDstInSrc+= xInc; } } else { int xDstInSrc; if(sws_flags==SWS_BICUBIC) *filterSize= (int)ceil(1 + 4.0*srcW / (double)dstW); else *filterSize= (int)ceil(1 + 2.0*srcW / (double)dstW); *filterSize= (*filterSize +(filterAlign-1)) & (~(filterAlign-1)); xDstInSrc= xInc - 0x8000; for(i=0; i<dstW; i++) { int xx= (int)((double)xDstInSrc/(double)(1<<16) - *filterSize*0.5 + 0.5); int j; filterPos[i]= xx; for(j=0; j<*filterSize; j++) { double d= ABS((xx<<16) - xDstInSrc)/(double)xInc; int coeff; if(sws_flags == SWS_BICUBIC) { double A= -0.75; if(d<1.0) coeff = (int)floor(0.5 + (1.0 - (A+3.0)*d*d + (A+2.0)*d*d*d) * (1<<14)); else if(d<2.0) coeff = (int)floor(0.5 + (-4.0*A + 8.0*A*d - 5.0*A*d*d + A*d*d*d) * (1<<14)); else coeff=0; } else { coeff= (int)(0.5 + (1.0 - d)*(1<<14)); if(coeff<0) coeff=0; } filter[i*(*filterSize) + j]= coeff; xx++; } xDstInSrc+= xInc; } } for(i=0; i<dstW; i++) { int j; if(filterPos[i] < 0) { for(j=1; j<*filterSize; j++) { int left= MAX(j + filterPos[i], 0); filter[i*(*filterSize) + left] += filter[i*(*filterSize) + j]; filter[i*(*filterSize) + j]=0; } filterPos[i]= 0; } if(filterPos[i] + *filterSize > srcW) { int shift= filterPos[i] + *filterSize - srcW; for(j=*filterSize-2; j>=0; j--) { int right= MIN(j + shift, *filterSize-1); filter[i*(*filterSize) +right] += filter[i*(*filterSize) +j]; filter[i*(*filterSize) +j]=0; } filterPos[i]= srcW - *filterSize; } } for(i=0; i<dstW; i++) { int j; double sum=0; double scale= one; for(j=0; j<*filterSize; j++) { sum+= filter[i*(*filterSize) + j]; } scale/= sum; for(j=0; j<*filterSize; j++) { filter[i*(*filterSize) + j]= (int)(filter[i*(*filterSize) + j]*scale); } } }
1threat
PCA analysis results on imbalanced data with duplicates : I am using sklearn PCA decomposition and surprised that if I delete duplicates from my dataset, the result differs from the "unclean" one. What is the reason? As I think, the variance is the same.
0debug
static int scsi_hot_add(Monitor *mon, DeviceState *adapter, DriveInfo *dinfo, int printinfo) { SCSIBus *scsibus; SCSIDevice *scsidev; scsibus = DO_UPCAST(SCSIBus, qbus, QLIST_FIRST(&adapter->child_bus)); if (!scsibus || strcmp(scsibus->qbus.info->name, "SCSI") != 0) { error_report("Device is not a SCSI adapter"); dinfo->unit = qemu_opt_get_number(dinfo->opts, "unit", -1); scsidev = scsi_bus_legacy_add_drive(scsibus, dinfo, dinfo->unit); dinfo->unit = scsidev->id; if (printinfo) monitor_printf(mon, "OK bus %d, unit %d\n", scsibus->busnr, scsidev->id); return 0;
1threat
How to make a curl request to get data from clickhouse database | Go : I'm trying to make a cURL request to get data from clickhouse database using Go, I don't have too much experience with cURL and not sure how to get the returned value by the query This is what I have: reader := strings.NewReader("SELECT COUNT(*) FROM system.tables WHERE database = 'local' AND name = 'persons'") request, err := http.NewRequest("GET", "http://localhost:8123", reader) if err != nil { fmt.Println(err) } client := &http.Client{} resp, err := client.Do(request) if err != nil { fmt.Println(err) } fmt.Println("The answer is: ", resp.Body) The expected output should be a number (1 means table exist and 0 means that doesn't exist) but I'm getting in `resp.Body` this output: The answer is: &{0xc4201741c0 {0 0} false <nil> 0x6a9bb0 0x6a9b20} Any idea to get just the value of the query?
0debug
How to access state inside Redux reducer? : <p>I have a reducer, and in order to calculate the new state I need data from the action and also data from a part of the state not managed by this reducer. Specifically, in the reducer I will show below, I need access to the <code>accountDetails.stateOfResidenceId</code> field.</p> <p><strong>initialState.js:</strong></p> <pre><code>export default { accountDetails: { stateOfResidenceId: '', accountType: '', accountNumber: '', product: '' }, forms: { blueprints: [ ] } }; </code></pre> <p><strong>formsReducer.js:</strong></p> <pre><code>import * as types from '../constants/actionTypes'; import objectAssign from 'object-assign'; import initialState from './initialState'; import formsHelper from '../utils/FormsHelper'; export default function formsReducer(state = initialState.forms, action) { switch (action.type) { case types.UPDATE_PRODUCT: { //I NEED accountDetails.stateOfResidenceId HERE console.log(state); const formBlueprints = formsHelper.getFormsByProductId(action.product.id); return objectAssign({}, state, {blueprints: formBlueprints}); } default: return state; } } </code></pre> <p><strong>index.js (root reducer):</strong></p> <pre><code>import { combineReducers } from 'redux'; import accountDetails from './accountDetailsReducer'; import forms from './formsReducer'; const rootReducer = combineReducers({ accountDetails, forms }); export default rootReducer; </code></pre> <p>How can I access this field?</p>
0debug
jQyery output is object Object restful web application : I have been working with an application that i have to use JQuery. And i have an issue my fucntions related to sons and grandsons in my below mentioned code: If i type into my browser http://localhost:8080/fathers I get : >[{"id":1,"fname":"fname","lname":"lname","sons":[{"id":1,"fname":"fname","lname":"lname","grandsons":[{"id":1,"fname":"fname","lname":"lname"}]}] My java classes: private int id; private String fname; private String lname; private Set<Son> sons = new HashSet<>(); public AppProduct(int id, String fname , String lname) { this.id = id; this.fname = fname; this.lname = lname; } My Son class: private int id; private String fname; private String lname; private Set<Grandson> grandsons = new HashSet<>(); public AppProduct(int id, String fname , String lname) { this.id = id; this.fname = fname; this.lname = lname; } --------------------- $.getJSON("http://localhost:8080/fathers", function(data) { for (var i in data) { $('#tag').append("<p>ID: " + data[i].id + "</p>") $('#tag').append("<p>First Name: " + data[i].fname + "</p>") $('#tag').append("<p>Last Name: " + data[i].lname + "</p>") $('#tag').append("<p>sons: " + data[i].sons + "</p>") $('#tag').append("<p>sons: " + data[i].grandsons + "</p>") } }); With my current $.getJSON i get the following output: for sons:[objtct Object] for grandsons: undefined function create() { var family = { id: document.getElementById("id").value, fname: document.getElementById("fname").value, lname: document.getElementById("lname").value, sons: document.getElementById("sons").value, grandsons: document.getElementById("grandsons").value } $.ajax({ url: "http://localhost:8080/fathers", headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, type: "POST", dataType: "json", data: JSON.stringify(family) }); } And for the same reason this part doesnot work in create() sons: document.getElementById("sons").value, grandsons: document.getElementById("grandsons").value
0debug
split value and add in to spinner : <p>want to add pipeline seprated value in to spinner. I have String defined below.</p> <blockquote> <p>String value = 12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35;</p> </blockquote> <p>how to split this value and add it in to spinner.</p>
0debug
Echo image php how? Right way : Im just looking for little help to make the right code. It should be very simple for you who know more php. What i want. echo "<a target='_blank' href='https://www.wbesite.kom". get_the_title() ."'>" IMAGE HERE "</a>"; This code deosnt work just because i dont understand how to put image in ''IMAGE HERE'' I have tryed to play with it but cant get it working. Can someone help? Thanks!
0debug
OS as algorithm? : <p>Can an Operating System be considered as an algorithm? Focus on the finiteness property, please. I have contradicting views on it right now with one prof. telling me something and the other something else.</p>
0debug
static uint64_t watch_mem_read(void *opaque, target_phys_addr_t addr, unsigned size) { check_watchpoint(addr & ~TARGET_PAGE_MASK, ~(size - 1), BP_MEM_READ); switch (size) { case 1: return ldub_phys(addr); case 2: return lduw_phys(addr); case 4: return ldl_phys(addr); default: abort(); } }
1threat
static void network_to_remote_block(RDMARemoteBlock *rb) { rb->remote_host_addr = ntohll(rb->remote_host_addr); rb->offset = ntohll(rb->offset); rb->length = ntohll(rb->length); rb->remote_rkey = ntohl(rb->remote_rkey); }
1threat
Working with spa services in .NetCore 3.0? : <p>I develop SPA web applicaton using ASP.Net Core React+Redux.</p> <p>After update to .Net Core 3.0 I see that UseWebpackDevMiddleware and AddNodeServices is obsolete. </p> <p>I learn new project-template React+Redux, but it isn't use webpack or SSR.</p> <p>1) Where I can find example or information of work with webpack in .Net Core 3.0? with UseWebpackDevMiddleware was realy easy to configure HMR and webpack build.</p> <p>2) Where I can find example or information about SSR with .Net 3.0 + React?</p>
0debug
Having a little trouble with this Number Sorter : <p>I'm trying to sort numbers in ascending or descending order, depending on the user input. I sorted the numbers in the text fields into an array and using an if-else statement to sort in ascending or descending order depending on the value of the select tag. However, the code only sorts in ascending order and does not sort in descending order when told to. I'm just wondering what I can do to fix this. </p> <p>This is my first coding in HTML and Javascript, let alone coding at all so this code is probably very inefficient, but I'm willing to accept any tips.</p> <pre><code>function sortingFunction() { var arr = []; arr.push(document.getElementById("one").value); arr.push(document.getElementById("two").value); arr.push(document.getElementById("three").value); arr.push(document.getElementById("four").value); arr.push(document.getElementById("five").value); arr.push(document.getElementById("six").value); arr.push(document.getElementById("seven").value); arr.push(document.getElementById("eight").value); arr.push(document.getElementById("nine").value); arr.push(document.getElementById("ten").value); var filtered = arr.filter(Boolean); var x = document.getElementById("mySelect").value; if (x = "ascending") { document.getElementById("answer").innerHTML = "Answer: " + filtered.sort(function(a,b) { return a - b;}); } else { document.getElementById("answer").innerHTML = "Answer: " + filtered.sort(function(a,b) { return b - a;}); } } //Text Fields Here with id="one" to "ten" &lt;button onclick="sortingFunction()"&gt;Submit&lt;/button&gt; &lt;select name="test" id="mySelect"&gt; &lt;option value="ascending"&gt;Ascending Order&lt;/option&gt; &lt;option value="descending"&gt;Descending Order&lt;/option&gt; &lt;/select&gt; &lt;p id="answer"&gt;&lt;/p&gt; </code></pre>
0debug
get speed information (calulate speed information) of a mouving car throug a road : ---------- I would like to detect the speed information of a moving car through a road using Arduino , Wich kind of censor can i use for this project?? Note that all this module (Arduino and censor are Outside of the Car) ----------
0debug
static void gen_dozo(DisasContext *ctx) { int l1 = gen_new_label(); int l2 = gen_new_label(); TCGv t0 = tcg_temp_new(); TCGv t1 = tcg_temp_new(); TCGv t2 = tcg_temp_new(); tcg_gen_movi_tl(cpu_ov, 0); tcg_gen_brcond_tl(TCG_COND_GE, cpu_gpr[rB(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], l1); tcg_gen_sub_tl(t0, cpu_gpr[rB(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); tcg_gen_xor_tl(t1, cpu_gpr[rB(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); tcg_gen_xor_tl(t2, cpu_gpr[rA(ctx->opcode)], t0); tcg_gen_andc_tl(t1, t1, t2); tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], t0); tcg_gen_brcondi_tl(TCG_COND_GE, t1, 0, l2); tcg_gen_movi_tl(cpu_ov, 1); tcg_gen_movi_tl(cpu_so, 1); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(cpu_gpr[rD(ctx->opcode)], 0); gen_set_label(l2); tcg_temp_free(t0); tcg_temp_free(t1); tcg_temp_free(t2); if (unlikely(Rc(ctx->opcode) != 0)) gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); }
1threat
Make Segue programmatically in Swift : <p>I have two VCs: VC1 and VC2. In VC1, I have a <code>finish button</code> which I programmatically made and a <code>result array</code> I want to pass to VC2.</p> <p>I know how to make Segue in Storyboard, but I cannot do that at this moment since the <code>finish button</code> is programmatically made. </p> <p>If I want to pass result array using segue, is there a way to make the segue programmatically? If this is not possible, should I just present VC2 using <code>presentViewController</code> and set a delegate to pass the <code>result array</code>?</p>
0debug
Laravel ShouldQueue How Does It Work : <p>I know how to use <code>ShouldQueue</code> my question is about why does it work the way it does.</p> <p>I need to edit how my <code>new Job</code> is stored in the database, and therefore am digging through Laravel's internals.</p> <p>The job I want to edit is launched from the following event listener:</p> <pre><code>&lt;?php namespace App\Listeners; use App\Events\NewMail; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use App\Jobs\SendEmail; use Carbon\Carbon; class NewMailListener implements ShouldQueue { /** * Create the event listener. * * @return void */ public function __construct() { // } /** * Handle the event. * * @param NewMail $event * @return void */ public function handle(NewMail $event) { $addressee = $event-&gt;user-&gt;name; $address = $event-&gt;user-&gt;email; $type = "NewMail"; $job = (new SendEmail($type,$addressee,$address))-&gt;delay(Carbon::now()-&gt;addMinutes(10)); dispatch($job); } } </code></pre> <p>What I don't understand is how the <code>ShouldQueue</code> magic works, because in the <a href="https://github.com/illuminate/contracts/blob/5.3/Queue/ShouldQueue.php" rel="noreferrer">source code</a> it appears to do nothing.</p> <pre><code>&lt;?php namespace Illuminate\Contracts\Queue; interface ShouldQueue { // } </code></pre> <p>I understand it is a <a href="https://laravel.com/docs/5.5/contracts" rel="noreferrer">contract</a> but it's not defining anything... so what it is doing exactly? Is there some auto-loading happening from the namespace?</p> <p>I wasn't sure what an interface was exactly, so I looked at this: <a href="http://php.net/manual/en/language.oop5.interfaces.php" rel="noreferrer">PHP Docs: Interfaces</a> and came away with the impression that even if it is for decoupling, and interface should be defining something, which I don't see in <code>ShouldQueue</code>.</p> <p>The top comment on that PHP docs page says this:</p> <blockquote> <p>An INTERFACE is provided so you can describe a set of functions and then hide the final implementation of those functions in an implementing class. This allows you to change the IMPLEMENTATION of those functions without changing how you use it.</p> </blockquote> <p>But where is this description of functions here?</p> <p>PS - I know this interface/contract is being used to queue the event listener itself, not the job that I want to edit. But I'm hoping understanding how the queue interacts with the event listener will better inform me as to how it works for the jobs.</p>
0debug
static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, int *data_size, const uint8_t *buf, int buf_size) { Mpeg1Context *s = avctx->priv_data; MpegEncContext *s2 = &s->mpeg_enc_ctx; const uint8_t *buf_ptr = buf; const uint8_t *buf_end = buf + buf_size; int ret, input_size; int last_code= 0; for(;;) { uint32_t start_code = -1; buf_ptr = ff_find_start_code(buf_ptr,buf_end, &start_code); if (start_code > 0x1ff){ if(s2->pict_type != AV_PICTURE_TYPE_B || avctx->skip_frame <= AVDISCARD_DEFAULT){ if(avctx->thread_count > 1){ int i; avctx->execute(avctx, slice_decode_thread, &s2->thread_context[0], NULL, s->slice_count, sizeof(void*)); for(i=0; i<s->slice_count; i++) s2->error_count += s2->thread_context[i]->error_count; } if (CONFIG_MPEG_VDPAU_DECODER && avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) ff_vdpau_mpeg_picture_complete(s2, buf, buf_size, s->slice_count); if (slice_end(avctx, picture)) { if(s2->last_picture_ptr || s2->low_delay) *data_size = sizeof(AVPicture); } } s2->pict_type= 0; return FFMAX(0, buf_ptr - buf - s2->parse_context.last_index); } input_size = buf_end - buf_ptr; if(avctx->debug & FF_DEBUG_STARTCODE){ av_log(avctx, AV_LOG_DEBUG, "%3X at %td left %d\n", start_code, buf_ptr-buf, input_size); } switch(start_code) { case SEQ_START_CODE: if(last_code == 0){ mpeg1_decode_sequence(avctx, buf_ptr, input_size); s->sync=1; }else{ av_log(avctx, AV_LOG_ERROR, "ignoring SEQ_START_CODE after %X\n", last_code); } break; case PICTURE_START_CODE: if (HAVE_THREADS && (avctx->active_thread_type&FF_THREAD_SLICE) && s->slice_count) { int i; avctx->execute(avctx, slice_decode_thread, s2->thread_context, NULL, s->slice_count, sizeof(void*)); for (i = 0; i < s->slice_count; i++) s2->error_count += s2->thread_context[i]->error_count; s->slice_count = 0; } if(last_code == 0 || last_code == SLICE_MIN_START_CODE){ if(mpeg_decode_postinit(avctx) < 0){ av_log(avctx, AV_LOG_ERROR, "mpeg_decode_postinit() failure\n"); return -1; } if(mpeg1_decode_picture(avctx, buf_ptr, input_size) < 0) s2->pict_type=0; s2->first_slice = 1; last_code= PICTURE_START_CODE; }else{ av_log(avctx, AV_LOG_ERROR, "ignoring pic after %X\n", last_code); } break; case EXT_START_CODE: init_get_bits(&s2->gb, buf_ptr, input_size*8); switch(get_bits(&s2->gb, 4)) { case 0x1: if(last_code == 0){ mpeg_decode_sequence_extension(s); }else{ av_log(avctx, AV_LOG_ERROR, "ignoring seq ext after %X\n", last_code); } break; case 0x2: mpeg_decode_sequence_display_extension(s); break; case 0x3: mpeg_decode_quant_matrix_extension(s2); break; case 0x7: mpeg_decode_picture_display_extension(s); break; case 0x8: if(last_code == PICTURE_START_CODE){ mpeg_decode_picture_coding_extension(s); }else{ av_log(avctx, AV_LOG_ERROR, "ignoring pic cod ext after %X\n", last_code); } break; } break; case USER_START_CODE: mpeg_decode_user_data(avctx, buf_ptr, input_size); break; case GOP_START_CODE: if(last_code == 0){ s2->first_field=0; mpeg_decode_gop(avctx, buf_ptr, input_size); s->sync=1; }else{ av_log(avctx, AV_LOG_ERROR, "ignoring GOP_START_CODE after %X\n", last_code); } break; default: if (start_code >= SLICE_MIN_START_CODE && start_code <= SLICE_MAX_START_CODE && last_code!=0) { const int field_pic= s2->picture_structure != PICT_FRAME; int mb_y= (start_code - SLICE_MIN_START_CODE) << field_pic; last_code= SLICE_MIN_START_CODE; if(s2->picture_structure == PICT_BOTTOM_FIELD) mb_y++; if (mb_y >= s2->mb_height){ av_log(s2->avctx, AV_LOG_ERROR, "slice below image (%d >= %d)\n", mb_y, s2->mb_height); return -1; } if(s2->last_picture_ptr==NULL){ if(s2->pict_type==AV_PICTURE_TYPE_B){ if(!s2->closed_gop) break; } } if(s2->pict_type==AV_PICTURE_TYPE_I) s->sync=1; if(s2->next_picture_ptr==NULL){ if(s2->pict_type==AV_PICTURE_TYPE_P && !s->sync) break; } if( (avctx->skip_frame >= AVDISCARD_NONREF && s2->pict_type==AV_PICTURE_TYPE_B) ||(avctx->skip_frame >= AVDISCARD_NONKEY && s2->pict_type!=AV_PICTURE_TYPE_I) || avctx->skip_frame >= AVDISCARD_ALL) break; if (!s->mpeg_enc_ctx_allocated) break; if(s2->codec_id == CODEC_ID_MPEG2VIDEO){ if(mb_y < avctx->skip_top || mb_y >= s2->mb_height - avctx->skip_bottom) break; } if(!s2->pict_type){ av_log(avctx, AV_LOG_ERROR, "Missing picture start code\n"); break; } if(s2->first_slice){ s2->first_slice=0; if(mpeg_field_start(s2, buf, buf_size) < 0) return -1; } if(!s2->current_picture_ptr){ av_log(avctx, AV_LOG_ERROR, "current_picture not initialized\n"); return -1; } if (avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) { s->slice_count++; break; } if(avctx->thread_count > 1){ int threshold= (s2->mb_height*s->slice_count + avctx->thread_count/2) / avctx->thread_count; if(threshold <= mb_y){ MpegEncContext *thread_context= s2->thread_context[s->slice_count]; thread_context->start_mb_y= mb_y; thread_context->end_mb_y = s2->mb_height; if(s->slice_count){ s2->thread_context[s->slice_count-1]->end_mb_y= mb_y; ff_update_duplicate_context(thread_context, s2); } init_get_bits(&thread_context->gb, buf_ptr, input_size*8); s->slice_count++; } buf_ptr += 2; }else{ ret = mpeg_decode_slice(s, mb_y, &buf_ptr, input_size); emms_c(); if(ret < 0){ if(s2->resync_mb_x>=0 && s2->resync_mb_y>=0) ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x, s2->mb_y, AC_ERROR|DC_ERROR|MV_ERROR); }else{ ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x-1, s2->mb_y, AC_END|DC_END|MV_END); } } } break; } } }
1threat
How to use R 3.3.2 to add index column to dataframe based on column value? : <h2>Problem</h2> <p>How to create a index column in a dataframe for R given the categorical values in a column? </p> <p>In other words, assume we have a dataframe as follows: </p> <pre><code>id cat 1 A 2 A 3 A 4 B 5 B 6 C 7 C 8 C 9 C 10 C </code></pre> <p>How can we create a column called rank that does the following: </p> <pre><code>id cat rank 1 A 1 2 A 2 3 A 3 4 B 1 5 B 2 6 C 1 7 C 2 8 C 3 9 C 4 10 C 5 </code></pre> <h2>Attempts</h2> <p>Assume the dataframe is called <code>df</code>. I tried the following: </p> <ul> <li>aggregate(df, by = c('A','B','C'), length)</li> <li>Starting writing a custom function to work with lapply, but ran into too many boundary cases. </li> </ul> <p>This gave me mismatched length errors. Obviously the idea here was to get the count for each group and then write a function that can take the row value with lapply and keep counting until I hit the length. </p> <h2>Additional Notes</h2> <p>I am thinking about abandoning the above ideas and splitting the dataframe into separate smaller dataframes by cat value. I will then create a rank variable for each dataframe that is indexed. The challenge then becomes, what is a good way to combine all the dataframe values back into one dataframe with the new rank column? </p> <p>None of this is sitting quite right with me though. Frankly, my gut says I'm doing this all wrong. Am I making this too hard? Is there a package or R trick that does this easily? I apologize if this seems silly, but I cannot in good conscious proceed further without seeking the advice of R programmers more skilled than me. </p>
0debug
static int _decode_exponents(int expstr, int ngrps, uint8_t absexp, uint8_t *gexps, uint8_t *dexps) { int exps; int i = 0; while (ngrps--) { exps = gexps[i++]; absexp += exp_1[exps]; assert(absexp <= 24); switch (expstr) { case AC3_EXPSTR_D45: *(dexps++) = absexp; *(dexps++) = absexp; case AC3_EXPSTR_D25: *(dexps++) = absexp; case AC3_EXPSTR_D15: *(dexps++) = absexp; } absexp += exp_2[exps]; assert(absexp <= 24); switch (expstr) { case AC3_EXPSTR_D45: *(dexps++) = absexp; *(dexps++) = absexp; case AC3_EXPSTR_D25: *(dexps++) = absexp; case AC3_EXPSTR_D15: *(dexps++) = absexp; } absexp += exp_3[exps]; assert(absexp <= 24); switch (expstr) { case AC3_EXPSTR_D45: *(dexps++) = absexp; *(dexps++) = absexp; case AC3_EXPSTR_D25: *(dexps++) = absexp; case AC3_EXPSTR_D15: *(dexps++) = absexp; } } return 0; }
1threat
VBA script to send email : I have written the bellow code to request roster from different teams however the code is not working.. need help to check where I am wrong. Sub RosterRequest() Dim counter As Integer Dim outapp As Object Dim outmail As Object Set outapp = CreateObject("Outlook.Application") Set outmail = outapp.CreateItem(0) Do While counter < 5 counter = counter + 1 c = Cells(counter, 1).Value d = Cells(counter, 2).Value MsgBox ("loop number " & counter & " Name is " & c & " Email is " & d) With outmail .to = d .Subject = "Roster Request" .Body = "Hi " & c & " Please Share the roster for your team " .send End With Loop End Sub
0debug
Convert a String from LowerTo Upper (vice-versa) without using type casting or built-in functions in Java : <p>How can we convert a String from lower to upper (Vice-versa ) in Java without using any built-in function or using any type casting ?</p>
0debug
void acpi_pcihp_init(AcpiPciHpState *s, PCIBus *root_bus, MemoryRegion *address_space_io) { s->root= root_bus; memory_region_init_io(&s->io, NULL, &acpi_pcihp_io_ops, s, "acpi-pci-hotplug", PCI_HOTPLUG_SIZE); memory_region_add_subregion(address_space_io, PCI_HOTPLUG_ADDR, &s->io); }
1threat
VSTS release pull request build trigger : <p>My team are using the VSTS Build &amp; Release mechanism, combined with pull request branch safety settings, so that code can only be merged in when a pull request is completed.</p> <p>We are experiencing something odd though, in that when a pull-request is created (and a build is spawned to prove the commit) - the completion of this build triggered by the pull request also indirectly triggers a release because we have a release trigger setup.</p> <p>This in itself is probably ok, but then what also happens is upon 'completing' the pull request, another build &amp; release cycle takes place!</p> <p>Is there a way of making VSTS release triggers only kick in when the pull request is completed and merged into the release branch? </p> <p>Thank you!</p>
0debug
static void xen_config_cleanup_dir(char *dir) { struct xs_dirs *d; d = qemu_malloc(sizeof(*d)); d->xs_dir = dir; TAILQ_INSERT_TAIL(&xs_cleanup, d, list); }
1threat
Can i fill android app forms in code by decompile it? : I want to fill android forms in android app code it self for example an app is asking email and name while you open the app i want to fill details by decompile that app and fill the respective email and name fields in code itself and compile it again so it can directly take from code.is it possible??
0debug
Pycharm/Python OpenCV and CV2 install error : <p>I've been trying to install both OpenCV and cv2 from both Pycharm and from the terminal as suggested using:</p> <pre><code>pip install --user opencv pip install --user cv2 </code></pre> <p>but I'm getting the following error for them:</p> <pre><code>Collecting opencv Could not find a version that satisfies the requirement opencv (from versions: ) No matching distribution found for opencv </code></pre> <p>and</p> <pre><code>Collecting cv2 Could not find a version that satisfies the requirement cv2 (from versions: ) No matching distribution found for cv2 </code></pre> <p>How can I fix these and install the packages properly? I'm using python 3.4.</p>
0debug
Are there extensions to let optimizers assume const-ref parameters will stay const? : <p>Related to my former question: <a href="https://stackoverflow.com/questions/49117489/are-compilers-not-allowed-to-assume-const-ref-parameters-will-stay-const">Are compilers not allowed to assume const-ref parameters will stay const?</a></p> <p>My new question is: Is there compiler-specific, non-standard extensions or syntax to tell GCC/Clang/MSVC that an object is not writable? For example, here's some fake-ish code I'd like to be able to write:</p> <pre><code>void f(const int&amp; i) { // At this point, compiler doesn't know if "i" can be mutated or not, // so it assumes it can // Fake-ish -- compiler now assumes "i" cannot be mutated and optimizes accordingly __assume(readonly i); // ... } </code></pre>
0debug
Why is System.Net.Http.HttpMethod a class, not an enum? : <p><code>HttpStatusCode</code> is implemented as an <code>enum</code>, with each possible value assigned to its corresponding HTTP status code (e.g. <code>(int)HttpStatusCode.Ok == 200</code>). </p> <p>However, <code>HttpMethod</code> is <a href="https://msdn.microsoft.com/en-us/library/system.net.http.httpmethod(v=vs.118).aspx" rel="noreferrer">implemented as a <code>class</code></a>, with static properties to get instances for the various HTTP verbs (<code>HttpStatus.GET</code>, <code>HttpStatus.PUT</code> etc). What is the rationale behind <em>not</em> implementing <code>HttpMethod</code> as an <code>enum</code>?</p>
0debug
Can you use http POST from a web page? : I am trying to use Jira to REST API to submit issues. This answer gives a POST method to submit issues http://stackoverflow.com/questions/5884960/how-to-create-an-issue-in-jira-via-rest-api Is there a way to integrate POST with html so you could submit things from a webpage? As you can probably tell I know very little about POST so simple would be better :) Thank you!
0debug
I WANT TO KNOW WHY IS THIS CODE NOT TAKING INPUTS FOR "DESIGNATION"? : [WHY IS IT NOT TAKING INPUTS FOR "DESIGNATION"][1] IF U CAN SEE THE OUTPUT FROM THE SCREENSHOT, THE fgets() function is running only once to take in the string "name", but it is not accepting the "designation" string and is skipping onto the "salary" input. What is intriguing me even more is the fact that this same code is running perfectly well in TurboC3....I am getting problems only with GCC compiler based IDE such as DevCPP and now in GCC itself in Linux. #include<iostream> #include<conio.h> #include<stdio.h> #include<string.h> using namespace std; class emp { private: char name[20],desig[20]; int id; float salary; public: void getdata() { cout<<"ENTER NAME:\n"; fgets(name,20,stdin); cout<<"ENTER ID:\n"; cin>>id; cout<<"ENTER DESIGNATION:\n"; fgets(desig,20,stdin); cout<<"ENTER SALARY:\n"; cin>>salary; } void showdata() { cout<<"NAME:- "<<name<<"\n"; cout<<"ID:- "<<id<<"\n"; cout<<"DESIGNATION: "<<desig<<"\n"; cout<<"SALARY: "<<salary<<"\n"; } }; int main() { emp ins[3]; int i; cout<<"ENTER DETAILS:\n"; for(i=0;i<3;i++) ins[i].getdata(); cout<<"*****************************DETAILS***************************\n"; for(i=0;i<3;i++) ins[i].showdata(); return 0; } [1]: http://i.stack.imgur.com/jG8LI.png
0debug
static void qed_copy_from_backing_file(BDRVQEDState *s, uint64_t pos, uint64_t len, uint64_t offset, BlockDriverCompletionFunc *cb, void *opaque) { CopyFromBackingFileCB *copy_cb; if (len == 0) { cb(opaque, 0); return; } copy_cb = gencb_alloc(sizeof(*copy_cb), cb, opaque); copy_cb->s = s; copy_cb->offset = offset; copy_cb->iov.iov_base = qemu_blockalign(s->bs, len); copy_cb->iov.iov_len = len; qemu_iovec_init_external(&copy_cb->qiov, &copy_cb->iov, 1); qed_read_backing_file(s, pos, &copy_cb->qiov, qed_copy_from_backing_file_write, copy_cb); }
1threat
Simple Java mistake : <pre><code>package e.power.bhd; </code></pre> <p>import java.util.Scanner;</p> <p>public class EPowerBhd {</p> <pre><code>public static void main(String[] args) { int accountNum = 1; double cMeter; double pMeter; double eUsage; double totalDueAmount = 0.0; double Tot = 0.0; Scanner input = new Scanner(System.in); while (accountNum != 0) { // user enter account no System.out.print("Enter Account number (0 to stop ) : "); accountNum = input.nextInt(); // user enter current meter reading System.out.print("Current meter reading : "); cMeter = input.nextDouble(); // user enter previous meter reading System.out.print("Previous meter reading : "); pMeter = input.nextDouble(); eUsage = cMeter - pMeter; System.out.print("Electricity Usage(in kWh) : " + eUsage); System.out.println(); if (eUsage &gt;= 1 &amp;&amp; eUsage &lt;= 200) { totalDueAmount = 0.218 * eUsage; } else if (eUsage &gt; 200 &amp;&amp; eUsage &lt;= 300) { totalDueAmount = 0.334 * eUsage; } else if (eUsage &gt; 300 &amp;&amp; eUsage &lt;= 600) { totalDueAmount = 0.516 * eUsage; } else if (eUsage &gt; 600 &amp;&amp; eUsage &lt;= 900) { totalDueAmount = 0.546 * eUsage; } else { totalDueAmount = 0.571 * eUsage; } System.out.println(); // total amount for the account is displayed System.out.println("Amount number : " + accountNum + "," + " your charge is " + "RM" + totalDueAmount); Tot = totalDueAmount++; System.out.println(); } // loop exit and displa the total amount for all accounts System.out.println("Total Amount collected = " + "RM" + Tot); System.out.println("________________________________"); System.out.println("--- DONE ----"); System.out.println("________________________________"); } } </code></pre> <p>I have completed a java program in which the user enter account number, current meter reading and previous current reading and then calculates electricity usag It will calculate electricity usage for accounts until user terminates the loop by entering 0 and the total for all accounts are calculated and displayed.</p> <p>In this program if user enter 0 at first it should show "No account has been processed." only and terminates.</p> <p>Attached is the program code and detail of the program.</p> <p><a href="https://www.dropbox.com/s/85mm1w09tl7c1n3/1.png?dl=0" rel="nofollow noreferrer">https://www.dropbox.com/s/85mm1w09tl7c1n3/1.png?dl=0</a> <a href="https://www.dropbox.com/s/8w0ngjt9em70q7w/2.png?dl=0" rel="nofollow noreferrer">https://www.dropbox.com/s/8w0ngjt9em70q7w/2.png?dl=0</a></p> <p>Any help is mostly appreciated..</p>
0debug
static QOSState *qvirtio_9p_start(void) { const char *cmd = "-fsdev local,id=fsdev0,security_model=none,path=%s " "-device virtio-9p-pci,fsdev=fsdev0,mount_tag=%s"; test_share = g_strdup("/tmp/qtest.XXXXXX"); g_assert_nonnull(mkdtemp(test_share)); return qtest_pc_boot(cmd, test_share, mount_tag); }
1threat
VS Express dosen't compile the code properly (?) : <p>So I used to use Code::Blocks IDE, and like it a lot. Recently I switched to Visual Studio. I downloaded VS Express, it was 600mb and I can only use 1gb data per day, I don't have Wi-Fi, so I that was my only option.I inserted the same code that compiled properly in Code::Blocks in it , it took a few tweaks to make it work in VS, but when I finally check it, the output was totally different, Instead of a command line Tetris, it glitched and filled the command prompt with strange characters.</p> <p>This is the code I tweaked a bit to make it work in VS:</p> <pre><code>#include &lt;iostream&gt; #include &lt;time.h&gt; #include &lt;string&gt; #include &lt;windows.h&gt; using namespace std; int nScreenHeight = 30; int nScreenWidth = 80; int nFieldWidth = 10; int nFieldHeight = 25; unsigned char *pField = NULL; wstring tetromine[7]; int currentPiece = 0; int currentRotation = 0; int currentX = (nFieldWidth/2); int currentY = 0; unsigned int score = 0; int pieceCounter = 0; int speed = 20; int speedCounter = 0; bool forcePieceDown =false; bool key[4]; bool shiftGridDown = false; int rotate(int px,int py,int r) { switch(r/90) { case 0: return py*4+px;//0 degs case 1: return 12+py - (px*4);//90 degs case 2: return 15 - (py*4) - px;//180 degs case 3: return 3 - py + (px*4);//270 degs } return 0; } int doesPieceFit(int id,int rot, int x, int y) { for(int px = 0;px&lt;4;px++){ for(int py = 0;py&lt;4;py++){ int pi = rotate(px,py,rot); int fi = (y+py) * nFieldWidth + (x+px); if(x + px&gt;= 0 &amp;&amp; x+px &lt; nFieldWidth){ if(tetromine[id][pi] == L'X' &amp;&amp; pField[fi]!=0){ return false; } } } } return true; } void lineCheck(){ bool line = true; int lines = 0; for(int y = 0; y&lt;= nFieldHeight-1;y++){ for(int x = 1; x&lt; nFieldWidth-1;x++){ if(pField[(y)*nFieldWidth+x]!=0){ line &amp;= true; } else line &amp;= false; } if(line) lines++; if(line){ for(int x = 1; x&lt; nFieldWidth-1;x++){ pField[(y)*nFieldWidth+x] = 8; } } } } int main() { //assets tetromine[0].append(L"..X."); tetromine[0].append(L"..X."); tetromine[0].append(L"..X."); tetromine[0].append(L"..X."); tetromine[1].append(L"..X."); tetromine[1].append(L".XX."); tetromine[1].append(L".X.."); tetromine[1].append(L"...."); tetromine[2].append(L".X.."); tetromine[2].append(L".XX."); tetromine[2].append(L"..X."); tetromine[2].append(L"...."); tetromine[3].append(L"...."); tetromine[3].append(L".XX."); tetromine[3].append(L".XX."); tetromine[3].append(L"...."); tetromine[4].append(L"..X."); tetromine[4].append(L".XX."); tetromine[4].append(L"..X."); tetromine[4].append(L"...."); tetromine[5].append(L"...."); tetromine[5].append(L".XX."); tetromine[5].append(L"..X."); tetromine[5].append(L"..X."); tetromine[6].append(L"...."); tetromine[6].append(L".XX."); tetromine[6].append(L".X.."); tetromine[6].append(L".X.."); pField = new unsigned char[nFieldWidth*nFieldHeight]; for(int x = 0; x&lt;nFieldWidth; x++) { for(int y = 0; y&lt;nFieldHeight; y++) { pField[y*nFieldWidth + x] = (x==0||x==nFieldWidth -1 || y == nFieldHeight - 1) ? 9 : 0; } } char *screen = new char [nScreenWidth * nScreenHeight]; HANDLE hConsole = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL); SetConsoleActiveScreenBuffer(hConsole); DWORD dwBytesWritten = 0; //Display frame COORD here; here.X = 0; here.Y = 0; WriteConsoleOutputCharacter(hConsole, (LPCWSTR)screen, nScreenWidth * nScreenHeight,here, &amp;dwBytesWritten); bool gameOver = false; while(!gameOver) { Sleep(100); speedCounter++; if(speedCounter&gt;=speed){ forcePieceDown = true; speedCounter = 0; } else { forcePieceDown = false; } if(shiftGridDown){ score++; for(int y = nFieldHeight-2;y &gt; 0;y--){ for(int x = 1;x&lt;nFieldWidth -1;x++){ if((pField[(y)*nFieldWidth+x]) != 0){ pField[(y+1)*nFieldWidth+x] = pField[(y)*nFieldWidth+x]; pField[(y)*nFieldWidth+x] = 0; } } } shiftGridDown = false; lineCheck(); } for(int x = 1; x&lt; nFieldWidth-1;x++){ if(pField[(nFieldHeight-2)*nFieldWidth+x]==8){ pField[(nFieldHeight-2)*nFieldWidth+x]=0; if(x==nFieldWidth-2){ shiftGridDown = true; score+=100; } } } for(int k = 0;k&lt;4;k++){ // R L D Z key[k] = (0x8000 &amp; GetAsyncKeyState((unsigned char)("DASZ"[k]))) != 0; } if(key[1]){ if(doesPieceFit(currentPiece,currentRotation,currentX-1,currentY)){ currentX = currentX-1; } }else if(key[0]){ if(doesPieceFit(currentPiece,currentRotation,currentX+1,currentY)){ currentX = currentX+1; } }if(key[2]){ speedCounter = speed; } if(key[3]&amp;&amp;doesPieceFit(currentPiece,currentRotation+90,currentX,currentY)){ (currentRotation+90&lt;=270)?currentRotation+=90:currentRotation=0; } if(forcePieceDown){ if(doesPieceFit(currentPiece,currentRotation,currentX,currentY+1)) currentY++; else { //lock piece pieceCounter++; if(pieceCounter%5==0){ speed-=1; } for(int px = 0;px&lt;4;px++){ for(int py = 0;py&lt;4;py++){ if(tetromine[currentPiece][rotate(px,py,currentRotation)]==L'X'){ pField[(currentY+py)*nFieldWidth+(currentX+px)] = currentPiece+1; } } } score+=20; //check lines lineCheck(); //get next piece currentX = nFieldWidth/2; currentY = 0; currentRotation = 0; srand(time(0)); currentPiece = rand() % 7; //check game over gameOver = !doesPieceFit(currentPiece,currentRotation,currentX,currentY); } } //draw field for(int x = 0; x &lt; nFieldWidth; x++) { for(int y = 0; y &lt; nFieldHeight; y++) { screen[(y+2)*nScreenWidth + (x+ 2)] = L" xxxxxxx=#"[pField[y*nFieldWidth + x]]; } } //draw piece for(int px = 0;px&lt;4;px++){ for(int py = 0;py&lt;4;py++){ if(tetromine[currentPiece][rotate(px,py,currentRotation)] == L'X'){ screen[(currentY+py+2)*nScreenWidth+(currentX+px+2)] = '+'; } } } string s("Score -&gt; "); string num; int tmp = score; while(tmp!=0){ int rem = tmp%10; tmp /= 10; num = ((char)(48+rem)) + num; } s+=num; for(int i = 0; i&lt;s.size();i++){ screen[i] = s[i]; } //display frame WriteConsoleOutputCharacter(hConsole, (LPCWSTR)screen, nScreenWidth * nScreenHeight,here, &amp;dwBytesWritten); } return 0; } </code></pre> <p>This is the origional code :</p> <pre><code>#include &lt;iostream&gt; #include &lt;time.h&gt; #include &lt;string&gt; #include &lt;windows.h&gt; using namespace std; int nScreenHeight = 30; int nScreenWidth = 80; int nFieldWidth = 10; int nFieldHeight = 25; unsigned char *pField = NULL; wstring tetromine[7]; int currentPiece = 0; int currentRotation = 0; int currentX = (nFieldWidth/2); int currentY = 0; unsigned int score = 0; int pieceCounter = 0; int speed = 20; int speedCounter = 0; bool forcePieceDown =false; bool key[4]; bool shiftGridDown = false; int rotate(int px,int py,int r) { switch(r/90) { case 0: return py*4+px;//0 degs case 1: return 12+py - (px*4);//90 degs case 2: return 15 - (py*4) - px;//180 degs case 3: return 3 - py + (px*4);//270 degs } return 0; } int doesPieceFit(int id,int rot, int x, int y) { for(int px = 0;px&lt;4;px++){ for(int py = 0;py&lt;4;py++){ int pi = rotate(px,py,rot); int fi = (y+py) * nFieldWidth + (x+px); if(x + px&gt;= 0 &amp;&amp; x+px &lt; nFieldWidth){ if(tetromine[id][pi] == L'X' &amp;&amp; pField[fi]!=0){ return false; } } } } return true; } void lineCheck(){ bool line = true; int lines = 0; for(int y = 0; y&lt;= nFieldHeight-1;y++){ for(int x = 1; x&lt; nFieldWidth-1;x++){ if(pField[(y)*nFieldWidth+x]!=0){ line &amp;= true; } else line &amp;= false; } if(line) lines++; if(line){ for(int x = 1; x&lt; nFieldWidth-1;x++){ pField[(y)*nFieldWidth+x] = 8; } } } } int main() { //assets tetromine[0].append(L"..X."); tetromine[0].append(L"..X."); tetromine[0].append(L"..X."); tetromine[0].append(L"..X."); tetromine[1].append(L"..X."); tetromine[1].append(L".XX."); tetromine[1].append(L".X.."); tetromine[1].append(L"...."); tetromine[2].append(L".X.."); tetromine[2].append(L".XX."); tetromine[2].append(L"..X."); tetromine[2].append(L"...."); tetromine[3].append(L"...."); tetromine[3].append(L".XX."); tetromine[3].append(L".XX."); tetromine[3].append(L"...."); tetromine[4].append(L"..X."); tetromine[4].append(L".XX."); tetromine[4].append(L"..X."); tetromine[4].append(L"...."); tetromine[5].append(L"...."); tetromine[5].append(L".XX."); tetromine[5].append(L"..X."); tetromine[5].append(L"..X."); tetromine[6].append(L"...."); tetromine[6].append(L".XX."); tetromine[6].append(L".X.."); tetromine[6].append(L".X.."); pField = new unsigned char[nFieldWidth*nFieldHeight]; for(int x = 0; x&lt;nFieldWidth; x++) { for(int y = 0; y&lt;nFieldHeight; y++) { pField[y*nFieldWidth + x] = (x==0||x==nFieldWidth -1 || y == nFieldHeight - 1) ? 9 : 0; } } char *screen = new char [nScreenWidth * nScreenHeight]; HANDLE hConsole = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL); SetConsoleActiveScreenBuffer(hConsole); DWORD dwBytesWritten = 0; //Display frame WriteConsoleOutputCharacter(hConsole, screen, nScreenWidth * nScreenHeight, {0,0}, &amp;dwBytesWritten); bool gameOver = false; while(!gameOver) { Sleep(100); speedCounter++; if(speedCounter&gt;=speed){ forcePieceDown = true; speedCounter = 0; } else { forcePieceDown = false; } if(shiftGridDown){ score++; for(int y = nFieldHeight-2;y &gt; 0;y--){ for(int x = 1;x&lt;nFieldWidth -1;x++){ if((pField[(y)*nFieldWidth+x]) != 0){ pField[(y+1)*nFieldWidth+x] = pField[(y)*nFieldWidth+x]; pField[(y)*nFieldWidth+x] = 0; } } } shiftGridDown = false; lineCheck(); } for(int x = 1; x&lt; nFieldWidth-1;x++){ if(pField[(nFieldHeight-2)*nFieldWidth+x]==8){ pField[(nFieldHeight-2)*nFieldWidth+x]=0; if(x==nFieldWidth-2){ shiftGridDown = true; score+=100; } } } for(int k = 0;k&lt;4;k++){ // R L D Z key[k] = (0x8000 &amp; GetAsyncKeyState((unsigned char)("DASZ"[k]))) != 0; } if(key[1]){ if(doesPieceFit(currentPiece,currentRotation,currentX-1,currentY)){ currentX = currentX-1; } }else if(key[0]){ if(doesPieceFit(currentPiece,currentRotation,currentX+1,currentY)){ currentX = currentX+1; } }if(key[2]){ speedCounter = speed; } if(key[3]&amp;&amp;doesPieceFit(currentPiece,currentRotation+90,currentX,currentY)){ (currentRotation+90&lt;=270)?currentRotation+=90:currentRotation=0; } if(forcePieceDown){ if(doesPieceFit(currentPiece,currentRotation,currentX,currentY+1)) currentY++; else { //lock piece pieceCounter++; if(pieceCounter%5==0){ speed-=1; } for(int px = 0;px&lt;4;px++){ for(int py = 0;py&lt;4;py++){ if(tetromine[currentPiece][rotate(px,py,currentRotation)]==L'X'){ pField[(currentY+py)*nFieldWidth+(currentX+px)] = currentPiece+1; } } } score+=20; //check lines lineCheck(); //get next piece currentX = nFieldWidth/2; currentY = 0; currentRotation = 0; srand(time(0)); currentPiece = rand() % 7; //check game over gameOver = !doesPieceFit(currentPiece,currentRotation,currentX,currentY); } } //draw field for(int x = 0; x &lt; nFieldWidth; x++) { for(int y = 0; y &lt; nFieldHeight; y++) { screen[(y+2)*nScreenWidth + (x+ 2)] = L" xxxxxxx=#"[pField[y*nFieldWidth + x]]; } } //draw piece for(int px = 0;px&lt;4;px++){ for(int py = 0;py&lt;4;py++){ if(tetromine[currentPiece][rotate(px,py,currentRotation)] == L'X'){ screen[(currentY+py+2)*nScreenWidth+(currentX+px+2)] = '+'; } } } string s("Score -&gt; "); string num; int tmp = score; while(tmp!=0){ int rem = tmp%10; tmp /= 10; num = ((char)(48+rem)) + num; } s+=num; for(int i = 0; i&lt;s.size();i++){ screen[i] = s[i]; } //display frame WriteConsoleOutputCharacter(hConsole, screen, nScreenWidth * nScreenHeight, { 0, 0}, &amp;dwBytesWritten); } return 0; } </code></pre>
0debug
static int find_headers_search_validate(FLACParseContext *fpc, int offset) { FLACFrameInfo fi; uint8_t *header_buf; int size = 0; header_buf = flac_fifo_read_wrap(fpc, offset, MAX_FRAME_HEADER_SIZE, &fpc->wrap_buf, &fpc->wrap_buf_allocated_size); if (frame_header_is_valid(fpc->avctx, header_buf, &fi)) { FLACHeaderMarker **end_handle = &fpc->headers; int i; size = 0; while (*end_handle) { end_handle = &(*end_handle)->next; size++; *end_handle = av_mallocz(sizeof(**end_handle)); if (!*end_handle) { av_log(fpc->avctx, AV_LOG_ERROR, "couldn't allocate FLACHeaderMarker\n"); (*end_handle)->fi = fi; (*end_handle)->offset = offset; (*end_handle)->link_penalty = av_malloc(sizeof(int) * FLAC_MAX_SEQUENTIAL_HEADERS); for (i = 0; i < FLAC_MAX_SEQUENTIAL_HEADERS; i++) (*end_handle)->link_penalty[i] = FLAC_HEADER_NOT_PENALIZED_YET; fpc->nb_headers_found++; size++; return size;
1threat
C ampersand operator from command line : I need to develop a client and server program with using sockets. My program should get port number from the command line. I saw an example which says "myprogram 2454 &" I wonder what that & means there. Thanks
0debug
Flutter nested StreamBuilders causing Bad state: Stream has already been listened to : <p>I'm trying to build a Flutter app using the BLoC pattern described in the video <a href="https://www.youtube.com/watch?v=PLHln7wHgPE&amp;feature=youtu.be" rel="noreferrer" title="Flutter / AngularDart – Code sharing, better together &#40;DartConf 2018&#41;">Flutter / AngularDart – Code sharing, better together (DartConf 2018)</a></p> <p>A BLoC is basically a view model with <code>Sink</code> inputs and <code>Stream</code> outputs. In my example it looks a bit like this:</p> <pre><code> class BLoC { // inputs Sink&lt;String&gt; inputTextChanges; Sink&lt;Null&gt; submitButtonClicks; // outputs Stream&lt;bool&gt; showLoading; Stream&lt;bool&gt; submitEnabled; } </code></pre> <p>I have the BLoC defined in a widget near the root of the hierarchy and it is passed down to widgets beneath it, including nested <code>StreamBuilders</code>. Like so:</p> <p><a href="https://i.stack.imgur.com/RQlJL.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RQlJL.png" alt="BLoC widget hierarchy"></a></p> <p>The top <code>StreamBuilder</code> listens to a <code>showLoading</code> stream on the BLoC so that it can rebuild to show an overlaid progress spinner. The bottom <code>StreamBuilder</code> listens to a <code>submitEnabled</code> stream to enable/disable a button.</p> <p>The problem is whenever the <code>showLoading</code> stream causes the top <code>StreamBuilder</code> to rebuild the widget it rebuilds nested widgets too. This in itself is fine and expected. However this results in the bottom <code>StreamBuilder</code> being recreated. When this happens it attempts to re-subscribe to the existing <code>submitEnabled</code> stream on the BLoC causing <code>Bad state: Stream has already been listened to</code></p> <p>Is there any way to accomplish this without making all of the outputs <code>BroadcastStreams</code>?</p> <p>(There is also a chance that I'm fundamentally misunderstanding the BLoC pattern.)</p> <hr> <p>Actual code example below:</p> <pre><code>import 'package:flutter/material.dart'; import 'package:rxdart/rxdart.dart'; import 'dart:async'; void main() =&gt; runApp(BlocExampleApp()); class BlocExampleApp extends StatefulWidget { BlocExampleApp({Key key}) : super(key: key); @override _BlocExampleAppState createState() =&gt; _BlocExampleAppState(); } class _BlocExampleAppState extends State&lt;BlocExampleApp&gt; { Bloc bloc = Bloc(); @override Widget build(BuildContext context) =&gt; MaterialApp( home: Scaffold( appBar: AppBar(elevation: 0.0), body: new StreamBuilder&lt;bool&gt;( stream: bloc.showLoading, builder: (context, snapshot) =&gt; snapshot.data ? _overlayLoadingWidget(_buildContent(context)) : _buildContent(context) ) ), ); Widget _buildContent(context) =&gt; Column( crossAxisAlignment: CrossAxisAlignment.center, children: &lt;Widget&gt;[ TextField( onChanged: bloc.inputTextChanges.add, ), StreamBuilder&lt;bool&gt;( stream: bloc.submitEnabled, builder: ((context, snapshot) =&gt; MaterialButton( onPressed: snapshot.data ? () =&gt; bloc.submitClicks.add(null) : null, child: Text('Submit'), ) ) ) ] ); Widget _overlayLoadingWidget(Widget content) =&gt; Stack( children: &lt;Widget&gt;[ content, Container( color: Colors.black54, ), Center(child: CircularProgressIndicator()), ], ); } class Bloc { final StreamController&lt;String&gt; _inputTextChanges = StreamController&lt;String&gt;(); final StreamController&lt;Null&gt; _submitClicks = StreamController(); // Inputs Sink&lt;String&gt; get inputTextChanges =&gt; _inputTextChanges.sink; Sink&lt;Null&gt; get submitClicks =&gt; _submitClicks.sink; // Outputs Stream&lt;bool&gt; get submitEnabled =&gt; Observable&lt;String&gt;(_inputTextChanges.stream) .distinct() .map(_isInputValid); Stream&lt;bool&gt; get showLoading =&gt; _submitClicks.stream.map((_) =&gt; true); bool _isInputValid(String input) =&gt; true; void dispose() { _inputTextChanges.close(); _submitClicks.close(); } } </code></pre>
0debug
element not interactable exception in selenium web automation : <p>In the below code i cannot send password keys in the password field, i tried clicking the field, clearing the field and sending the keys. But now working in any of the method. But its working if i debug and test</p> <pre><code> public class TestMail { protected static WebDriver driver; protected static String result; @BeforeClass public static void setup() { System.setProperty("webdriver.gecko.driver","D:\\geckodriver.exe"); driver = new FirefoxDriver(); driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); } @Test void Testcase1() { driver.get("http://mail.google.com"); WebElement loginfield = driver.findElement(By.name("Email")); if(loginfield.isDisplayed()){ loginfield.sendKeys("ragesh@gmail.in"); } else{ WebElement newloginfield = driver.findElemnt(By.cssSelector("#identifierId")); newloginfield.sendKeys("ragesh@gmail.in"); // System.out.println("This is new login"); } driver.findElement(By.name("signIn")).click(); // driver.findElement(By.cssSelector(".RveJvd")).click(); driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); // WebElement pwd = driver.findElement(By.name("Passwd")); WebElement pwd = driver.findElement(By.cssSelector("#Passwd")); pwd.click(); pwd.clear(); // pwd.sendKeys("123"); if(pwd.isEnabled()){ pwd.sendKeys("123"); } else{ System.out.println("Not Enabled"); } </code></pre>
0debug
void video_encode_example(const char *filename) { AVCodec *codec; AVCodecContext *c= NULL; int i, out_size, size, x, y, outbuf_size; FILE *f; AVFrame *picture; uint8_t *outbuf, *picture_buf; printf("Video encoding\n"); codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO); if (!codec) { fprintf(stderr, "codec not found\n"); exit(1); } c= avcodec_alloc_context(); picture= avcodec_alloc_frame(); c->bit_rate = 400000; c->width = 352; c->height = 288; c->frame_rate = 25; c->frame_rate_base= 1; c->gop_size = 10; c->max_b_frames=1; if (avcodec_open(c, codec) < 0) { fprintf(stderr, "could not open codec\n"); exit(1); } f = fopen(filename, "w"); if (!f) { fprintf(stderr, "could not open %s\n", filename); exit(1); } outbuf_size = 100000; outbuf = malloc(outbuf_size); size = c->width * c->height; picture_buf = malloc((size * 3) / 2); picture->data[0] = picture_buf; picture->data[1] = picture->data[0] + size; picture->data[2] = picture->data[1] + size / 4; picture->linesize[0] = c->width; picture->linesize[1] = c->width / 2; picture->linesize[2] = c->width / 2; for(i=0;i<25;i++) { fflush(stdout); for(y=0;y<c->height;y++) { for(x=0;x<c->width;x++) { picture->data[0][y * picture->linesize[0] + x] = x + y + i * 3; } } for(y=0;y<c->height/2;y++) { for(x=0;x<c->width/2;x++) { picture->data[1][y * picture->linesize[1] + x] = 128 + y + i * 2; picture->data[2][y * picture->linesize[2] + x] = 64 + x + i * 5; } } out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture); printf("encoding frame %3d (size=%5d)\n", i, out_size); fwrite(outbuf, 1, out_size, f); } for(; out_size; i++) { fflush(stdout); out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL); printf("write frame %3d (size=%5d)\n", i, out_size); fwrite(outbuf, 1, out_size, f); } outbuf[0] = 0x00; outbuf[1] = 0x00; outbuf[2] = 0x01; outbuf[3] = 0xb7; fwrite(outbuf, 1, 4, f); fclose(f); free(picture_buf); free(outbuf); avcodec_close(c); free(c); free(picture); printf("\n"); }
1threat
const char *small_strptime(const char *p, const char *fmt, struct tm *dt) { int c, val; for(;;) { c = *fmt++; if (c == '\0') { return p; } else if (c == '%') { c = *fmt++; switch(c) { case 'H': val = date_get_num(&p, 0, 23, 2); if (val == -1) return NULL; dt->tm_hour = val; break; case 'M': val = date_get_num(&p, 0, 59, 2); if (val == -1) return NULL; dt->tm_min = val; break; case 'S': val = date_get_num(&p, 0, 59, 2); if (val == -1) return NULL; dt->tm_sec = val; break; case 'Y': val = date_get_num(&p, 0, 9999, 4); if (val == -1) return NULL; dt->tm_year = val - 1900; break; case 'm': val = date_get_num(&p, 1, 12, 2); if (val == -1) return NULL; dt->tm_mon = val - 1; break; case 'd': val = date_get_num(&p, 1, 31, 2); if (val == -1) return NULL; dt->tm_mday = val; break; case '%': goto match; default: return NULL; } } else { match: if (c != *p) return NULL; p++; } } return p; }
1threat
static uint32_t scsi_init_iovec(SCSIDiskReq *r) { r->iov.iov_len = MIN(r->sector_count * 512, SCSI_DMA_BUF_SIZE); qemu_iovec_init_external(&r->qiov, &r->iov, 1); return r->qiov.size / 512; }
1threat
static int ff_filter_frame_framed(AVFilterLink *link, AVFilterBufferRef *frame) { int (*filter_frame)(AVFilterLink *, AVFilterBufferRef *); AVFilterPad *src = link->srcpad; AVFilterPad *dst = link->dstpad; AVFilterBufferRef *out; int perms, ret; AVFilterCommand *cmd= link->dst->command_queue; int64_t pts; if (link->closed) { avfilter_unref_buffer(frame); return AVERROR_EOF; } if (!(filter_frame = dst->filter_frame)) filter_frame = default_filter_frame; av_assert1((frame->perms & src->min_perms) == src->min_perms); frame->perms &= ~ src->rej_perms; perms = frame->perms; if (frame->linesize[0] < 0) perms |= AV_PERM_NEG_LINESIZES; if ((dst->min_perms & perms) != dst->min_perms || dst->rej_perms & perms) { av_log(link->dst, AV_LOG_DEBUG, "Copying data in avfilter (have perms %x, need %x, reject %x)\n", perms, link->dstpad->min_perms, link->dstpad->rej_perms); switch (link->type) { case AVMEDIA_TYPE_VIDEO: out = ff_get_video_buffer(link, dst->min_perms, link->w, link->h); break; case AVMEDIA_TYPE_AUDIO: out = ff_get_audio_buffer(link, dst->min_perms, frame->audio->nb_samples); break; default: return AVERROR(EINVAL); } if (!out) { avfilter_unref_buffer(frame); return AVERROR(ENOMEM); } avfilter_copy_buffer_ref_props(out, frame); switch (link->type) { case AVMEDIA_TYPE_VIDEO: av_image_copy(out->data, out->linesize, frame->data, frame->linesize, frame->format, frame->video->w, frame->video->h); break; case AVMEDIA_TYPE_AUDIO: av_samples_copy(out->extended_data, frame->extended_data, 0, 0, frame->audio->nb_samples, av_get_channel_layout_nb_channels(frame->audio->channel_layout), frame->format); break; default: return AVERROR(EINVAL); } avfilter_unref_buffer(frame); } else out = frame; while(cmd && cmd->time <= frame->pts * av_q2d(link->time_base)){ av_log(link->dst, AV_LOG_DEBUG, "Processing command time:%f command:%s arg:%s\n", cmd->time, cmd->command, cmd->arg); avfilter_process_command(link->dst, cmd->command, cmd->arg, 0, 0, cmd->flags); ff_command_queue_pop(link->dst); cmd= link->dst->command_queue; } pts = out->pts; ret = filter_frame(link, out); ff_update_link_current_pts(link, pts); return ret; }
1threat
int socket_connect(SocketAddressLegacy *addr, NonBlockingConnectHandler *callback, void *opaque, Error **errp) { int fd; switch (addr->type) { case SOCKET_ADDRESS_LEGACY_KIND_INET: fd = inet_connect_saddr(addr->u.inet.data, callback, opaque, errp); break; case SOCKET_ADDRESS_LEGACY_KIND_UNIX: fd = unix_connect_saddr(addr->u.q_unix.data, callback, opaque, errp); break; case SOCKET_ADDRESS_LEGACY_KIND_FD: fd = monitor_get_fd(cur_mon, addr->u.fd.data->str, errp); if (fd >= 0 && callback) { qemu_set_nonblock(fd); callback(fd, NULL, opaque); } break; case SOCKET_ADDRESS_LEGACY_KIND_VSOCK: fd = vsock_connect_saddr(addr->u.vsock.data, callback, opaque, errp); break; default: abort(); } return fd; }
1threat