problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
413 error with Kubernetes and Nginx ingress controller : <p>I'm trying to change the <code>client_max_body_size</code> value, so my nginx ingress will not return 413 error. </p>
<p>I've tested few solutions.<br>
Here is my test config map: </p>
<pre><code>kind: ConfigMap
apiVersion: v1
data:
proxy-connect-timeout: "15"
proxy-read-timeout: "600"
proxy-send-timeout: "600"
proxy-body-size: "8m"
hsts-include-subdomains: "false"
body-size: "64m"
server-name-hash-bucket-size: "256"
client-max-body-size: "50m"
metadata:
name: nginx-configuration
namespace: ingress-nginx
labels:
app: ingress-nginx
</code></pre>
<p>These changes has no effect at all, after loading it, in the nginx controller log I can see the information about reloading config map, but the values in nginx.conf are the same: </p>
<pre><code>root@nginx-ingress-controller-95db685f5-b5s6s:/# cat /etc/nginx/nginx.conf | grep client_max
client_max_body_size "8m";
client_max_body_size "1m";
client_max_body_size "1m";
client_max_body_size "1m";
client_max_body_size "1m";
client_max_body_size "1m";
client_max_body_size "1m";
client_max_body_size "1m";
client_max_body_size "1m";
client_max_body_size "1m";
client_max_body_size "1m";
client_max_body_size "1m";
client_max_body_size "1m";
</code></pre>
<p>My nginx-controller config uses this image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.13.0 </p>
<p>How can I force the nginx to change the value? I need to change it globally, for all my ingresses.</p>
| 0debug |
static void gen_mfdcr(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
#else
TCGv dcrn;
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
return;
}
gen_update_nip(ctx, ctx->nip - 4);
dcrn = tcg_const_tl(SPR(ctx->opcode));
gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], cpu_env, dcrn);
tcg_temp_free(dcrn);
#endif
}
| 1threat |
Adding Autofac to WPF MVVM application : <p>I can't seem to find an solution to this problem. I've seen several questions about this, but none really give me a solution. I am totally new to Autofac and haven't really done much WPF + MVVM, but know the basics. </p>
<p>I have a WPF application (using ModernUI for WPF) which I'm trying to add Autofac to, and I am having a hard time figuring out how to resolve my services within all the views, since they have no access to my container. I have a main view, which is my entry point, where I set up my container:</p>
<pre><code>public partial class MainWindow : ModernWindow
{
IContainer AppContainer;
public MainWindow()
{
SetUpContainer();
this.DataContext = new MainWindowViewModel();
InitializeComponent();
Application.Current.MainWindow = this;
}
private void SetUpContainer()
{
var builder = new ContainerBuilder();
BuildupContainer(builder);
var container = builder.Build();
AppContainer = container;
}
private void BuildupContainer(ContainerBuilder builder)
{
builder.RegisterType<Logger>().As<ILogger>();
...
}
}
</code></pre>
<p>The problem I'm having is figuring out how I can resolve my logger and other services within my other views, where I inject all my dependencies through the ViewModel constructor, like so:</p>
<pre><code>public partial class ItemsView : UserControl
{
private ItemsViewModel _vm;
public ItemsView()
{
InitializeComponent();
IFileHashHelper fileHashHelper = new MD5FileHashHelper();
ILibraryLoader libraryLoader = new LibraryLoader(fileHashHelper);
ILogger logger = new Logger();
_vm = new ItemsViewModel(libraryLoader, logger);
this.DataContext = _vm;
}
}
</code></pre>
<p>Some views have a ridiculous amount of injected parameters, and this is where I want Autofac to come in and help me clean things up. </p>
<p>I was thinking of passing the container to the ViewModel and storing it as a property on my ViewModelBase class, but I've read that this would be an anti-pattern, and even then I don't know if that would automatically resolve my objects within the other ViewModels. </p>
<p>I managed to put together a simple Console Application using Autofac</p>
<pre><code>class Program
{
static void Main(string[] args)
{
var builder = new ContainerBuilder();
builder.RegisterType<Cleaner>().As<ICleaner>();
builder.RegisterType<Repository>().AsImplementedInterfaces().InstancePerLifetimeScope();
var container = builder.Build();
using (var scope = container.BeginLifetimeScope())
{
ICleaner cleaner = container.Resolve<ICleaner>();
cleaner.Update(stream);
}
}
}
</code></pre>
<p>but that was simple since it has a single entry point. </p>
<p>I'd like some ideas on how to add Autofac to my WPF app. I'm sure that I'm doing something wrong. Your help is appreciated.</p>
| 0debug |
What is going on with my nav bar and footer? : For some reason, my nav bar and footer are messed up. I don't want the user to have to scroll down at all, I want everything to fit on one page. Well for some reason the footer and the image are screwing that up. The biggest problem though is that my main content is not going in the middle of the page, but rather behind the nav bar.
Here is both CSS and HTML, and my website. Do you guys see any problems?
http://pastebin.com/Vzdascc1
http://pastebin.com/iVXQpJW9
http://ryfixit.tech/ | 0debug |
Error: Status{statusCode=DEVELOPER_ERROR, resolution=null} : <p>I am usign gplus sign in, and getting this error at time I am in onActivityResult....</p>
<pre><code>@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
client.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
GoogleSignInAccount acct = result.getSignInAccount();
// Log.d("Result","details"+ acct.getDisplayName() + acct.getEmail());
mEmail = acct.getEmail();
String mFullName = acct.getDisplayName();
String mGoogleplusId = acct.getId();
SocialUser user = new SocialUser();
user.setType("googleplus");
user.setEmail(mEmail);
user.setFullname(mFullName);
user.setId(mGoogleplusId + "");
loginParams.put("email_id", mEmail);
loginParams.put("googlePlusId", mGoogleplusId);
loginParams.put("full_name", mFullName);
loginParams.put("registrationType", "googleplus");
SignUpService(user);
} else {
Toast.makeText(CustomerLogIn.this, "Unable to fetch data, Proceed manually", Toast.LENGTH_SHORT).show();
}
}
}
</code></pre>
<p>And I am calling for gplus login on button click. On clcking button following code is executed....</p>
<pre><code> GoogleSignInOptions googleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(CustomerLogIn.this)
.addApi(Auth.GOOGLE_SIGN_IN_API, googleSignInOptions)
.build();
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, 0);
</code></pre>
<p>And I am geetng this error...</p>
<pre><code>Status{statusCode=DEVELOPER_ERROR, resolution=null}
</code></pre>
<p>on this line....</p>
<pre><code>GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
</code></pre>
<p>Please suggest the solution.</p>
| 0debug |
static inline unsigned long align_sigframe(unsigned long sp)
{
unsigned long i;
i = sp & ~3UL;
return i;
}
| 1threat |
Getting selenium to launch safari with default profile in python : <p>I'm trying to launch Safari with Selenium in python with all my sessions logged in (e.g. gmail) so I don't have to login manually.</p>
<p>The easy solution would be to launch safari with the default user profile, but I can't find documentation on how to do this.</p>
<pre><code>from selenium import webdriver
driver = webdriver.Safari()
url = 'https://www.gmail.com/'
driver.get(url)
</code></pre>
<p>Just for reference, the code below is the code for Chrome. What is the safari equivalent?</p>
<pre><code>options.add_argument("user-data-dir=/Users/alexiseggermont/Library/Application Support/Google/Chrome/Default/") #Path to your chrome profile
driver = webdriver.Chrome(chrome_options=options)
driver.get(url)
</code></pre>
| 0debug |
How does this short memoization function in the GHC test suite work? : <p><a href="https://github.com/ryantm/ghc/blob/master/testsuite/tests/simplCore/should_run/simplrun005.hs" rel="noreferrer">Here</a> is the complete runnable code for the following memoization function:</p>
<pre><code>memo f = g
where
fz = f Z
fs = memo (f . S)
g Z = fz
g (S n) = fs n
-- It is a BAD BUG to inline 'fs' inside g
-- and that happened in 6.4.1, resulting in exponential behaviour
-- memo f = g (f Z) (memo (f . S))
-- = g (f Z) (g (f (S Z)) (memo (f . S . S)))
-- = g (f Z) (g (f (S Z)) (g (f (S (S Z))) (memo (f . S . S . S))))
fib' :: Nat -> Integer
fib' = memo fib
where
fib Z = 0
fib (S Z) = 1
fib (S (S n)) = fib' (S n) + fib' n
</code></pre>
<p>I tried to figure it out with expansion of the terms by hand, but that expansion looks just like the slow, unmemoized function. How does it work? And how is the commented out code derived?</p>
| 0debug |
NGINX - Reverse proxy multiple API on different ports : <p>I have the following API(s):</p>
<ol>
<li>localhost:300/api/customers/ </li>
<li>localhost:400/api/customers/:id/billing</li>
<li>localhost:500/api/orders</li>
</ol>
<p>I'd like to use NGINX to have them all run under the following location:</p>
<p>localhost:443/api/</p>
<p>This seems very difficult because of customers spanning two servers.</p>
<p>Here's my failed attempt starting with orders</p>
<pre><code>server {
listen 443;
server_name localhost;
location /api/orders {
proxy_pass https://localhost:500/api/orders;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
server {
listen 443;
server_name localhost;
location /api/customers/$id/billing {
proxy_pass https://localhost:400/api/customers/$id/billing;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
server {
listen 443;
server_name localhost;
location /api/customers {
proxy_pass https://localhost:300/api/customers;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
</code></pre>
<p>Anything jump out as far as a fix? Thanks!</p>
| 0debug |
static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd, const char **p,
int line_num, FFServerStream **pstream)
{
char arg[1024], arg2[1024];
FFServerStream *stream;
int val;
av_assert0(pstream);
stream = *pstream;
if (!av_strcasecmp(cmd, "<Stream")) {
char *q;
FFServerStream *s;
stream = av_mallocz(sizeof(FFServerStream));
if (!stream)
return AVERROR(ENOMEM);
ffserver_get_arg(stream->filename, sizeof(stream->filename), p);
q = strrchr(stream->filename, '>');
if (q)
*q = '\0';
for (s = config->first_stream; s; s = s->next) {
if (!strcmp(stream->filename, s->filename))
ERROR("Stream '%s' already registered\n", s->filename);
}
stream->fmt = ffserver_guess_format(NULL, stream->filename, NULL);
if (stream->fmt) {
config->audio_id = stream->fmt->audio_codec;
config->video_id = stream->fmt->video_codec;
} else {
config->audio_id = AV_CODEC_ID_NONE;
config->video_id = AV_CODEC_ID_NONE;
}
*pstream = stream;
return 0;
}
av_assert0(stream);
if (!av_strcasecmp(cmd, "Feed")) {
FFServerStream *sfeed;
ffserver_get_arg(arg, sizeof(arg), p);
sfeed = config->first_feed;
while (sfeed) {
if (!strcmp(sfeed->filename, arg))
break;
sfeed = sfeed->next_feed;
}
if (!sfeed)
ERROR("Feed with name '%s' for stream '%s' is not defined\n", arg, stream->filename);
else
stream->feed = sfeed;
} else if (!av_strcasecmp(cmd, "Format")) {
ffserver_get_arg(arg, sizeof(arg), p);
if (!strcmp(arg, "status")) {
stream->stream_type = STREAM_TYPE_STATUS;
stream->fmt = NULL;
} else {
stream->stream_type = STREAM_TYPE_LIVE;
if (!strcmp(arg, "jpeg"))
strcpy(arg, "mjpeg");
stream->fmt = ffserver_guess_format(arg, NULL, NULL);
if (!stream->fmt)
ERROR("Unknown Format: %s\n", arg);
}
if (stream->fmt) {
config->audio_id = stream->fmt->audio_codec;
config->video_id = stream->fmt->video_codec;
}
} else if (!av_strcasecmp(cmd, "InputFormat")) {
ffserver_get_arg(arg, sizeof(arg), p);
stream->ifmt = av_find_input_format(arg);
if (!stream->ifmt)
ERROR("Unknown input format: %s\n", arg);
} else if (!av_strcasecmp(cmd, "FaviconURL")) {
if (stream->stream_type == STREAM_TYPE_STATUS)
ffserver_get_arg(stream->feed_filename, sizeof(stream->feed_filename), p);
else
ERROR("FaviconURL only permitted for status streams\n");
} else if (!av_strcasecmp(cmd, "Author") ||
!av_strcasecmp(cmd, "Comment") ||
!av_strcasecmp(cmd, "Copyright") ||
!av_strcasecmp(cmd, "Title")) {
char key[32];
int i;
ffserver_get_arg(arg, sizeof(arg), p);
for (i = 0; i < strlen(cmd); i++)
key[i] = av_tolower(cmd[i]);
key[i] = 0;
WARNING("'%s' option in configuration file is deprecated, "
"use 'Metadata %s VALUE' instead\n", cmd, key);
if (av_dict_set(&stream->metadata, key, arg, 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "Metadata")) {
ffserver_get_arg(arg, sizeof(arg), p);
ffserver_get_arg(arg2, sizeof(arg2), p);
if (av_dict_set(&stream->metadata, arg, arg2, 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "Preroll")) {
ffserver_get_arg(arg, sizeof(arg), p);
stream->prebuffer = atof(arg) * 1000;
} else if (!av_strcasecmp(cmd, "StartSendOnKey")) {
stream->send_on_key = 1;
} else if (!av_strcasecmp(cmd, "AudioCodec")) {
ffserver_get_arg(arg, sizeof(arg), p);
config->audio_id = opt_codec(arg, AVMEDIA_TYPE_AUDIO);
if (config->audio_id == AV_CODEC_ID_NONE)
ERROR("Unknown AudioCodec: %s\n", arg);
} else if (!av_strcasecmp(cmd, "VideoCodec")) {
ffserver_get_arg(arg, sizeof(arg), p);
config->video_id = opt_codec(arg, AVMEDIA_TYPE_VIDEO);
if (config->video_id == AV_CODEC_ID_NONE)
ERROR("Unknown VideoCodec: %s\n", arg);
} else if (!av_strcasecmp(cmd, "MaxTime")) {
ffserver_get_arg(arg, sizeof(arg), p);
stream->max_time = atof(arg) * 1000;
} else if (!av_strcasecmp(cmd, "AudioBitRate")) {
float f;
ffserver_get_arg(arg, sizeof(arg), p);
ffserver_set_float_param(&f, arg, 1000, 0, FLT_MAX, config, line_num, "Invalid %s: %s\n", cmd, arg);
if (av_dict_set_int(&config->audio_conf, cmd, lrintf(f), 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "AudioChannels")) {
ffserver_get_arg(arg, sizeof(arg), p);
ffserver_set_int_param(NULL, arg, 0, 1, 8, config, line_num, "Invalid %s: %s, valid range is 1-8.", cmd, arg);
if (av_dict_set(&config->audio_conf, cmd, arg, 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "AudioSampleRate")) {
ffserver_get_arg(arg, sizeof(arg), p);
ffserver_set_int_param(NULL, arg, 0, 0, INT_MAX, config, line_num, "Invalid %s: %s", cmd, arg);
if (av_dict_set(&config->audio_conf, cmd, arg, 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "VideoBitRateRange")) {
int minrate, maxrate;
ffserver_get_arg(arg, sizeof(arg), p);
if (sscanf(arg, "%d-%d", &minrate, &maxrate) == 2) {
if (av_dict_set_int(&config->video_conf, "VideoBitRateRangeMin", minrate, 0) < 0 ||
av_dict_set_int(&config->video_conf, "VideoBitRateRangeMax", maxrate, 0) < 0)
goto nomem;
} else
ERROR("Incorrect format for VideoBitRateRange -- should be <min>-<max>: %s\n", arg);
} else if (!av_strcasecmp(cmd, "Debug")) {
ffserver_get_arg(arg, sizeof(arg), p);
ffserver_set_int_param(NULL, arg, 0, INT_MIN, INT_MAX, config, line_num, "Invalid %s: %s", cmd, arg);
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "Strict")) {
ffserver_get_arg(arg, sizeof(arg), p);
ffserver_set_int_param(NULL, arg, 0, INT_MIN, INT_MAX, config, line_num, "Invalid %s: %s", cmd, arg);
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "VideoBufferSize")) {
ffserver_get_arg(arg, sizeof(arg), p);
ffserver_set_int_param(NULL, arg, 8*1024, 0, INT_MAX, config, line_num, "Invalid %s: %s", cmd, arg);
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "VideoBitRateTolerance")) {
ffserver_get_arg(arg, sizeof(arg), p);
ffserver_set_int_param(NULL, arg, 1000, INT_MIN, INT_MAX, config, line_num, "Invalid %s: %s", cmd, arg);
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "VideoBitRate")) {
ffserver_get_arg(arg, sizeof(arg), p);
ffserver_set_int_param(NULL, arg, 1000, 0, INT_MAX, config, line_num, "Invalid %s: %s", cmd, arg);
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "VideoSize")) {
int ret, w, h;
ffserver_get_arg(arg, sizeof(arg), p);
ret = av_parse_video_size(&w, &h, arg);
if (ret < 0)
ERROR("Invalid video size '%s'\n", arg);
else if ((w % 16) || (h % 16))
ERROR("Image size must be a multiple of 16\n");
if (av_dict_set_int(&config->video_conf, "VideoSizeWidth", w, 0) < 0 ||
av_dict_set_int(&config->video_conf, "VideoSizeHeight", h, 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "VideoFrameRate")) {
AVRational frame_rate;
ffserver_get_arg(arg, sizeof(arg), p);
if (av_parse_video_rate(&frame_rate, arg) < 0) {
ERROR("Incorrect frame rate: %s\n", arg);
} else {
if (av_dict_set_int(&config->video_conf, "VideoFrameRateNum", frame_rate.num, 0) < 0 ||
av_dict_set_int(&config->video_conf, "VideoFrameRateDen", frame_rate.den, 0) < 0)
goto nomem;
}
} else if (!av_strcasecmp(cmd, "PixelFormat")) {
enum AVPixelFormat pix_fmt;
ffserver_get_arg(arg, sizeof(arg), p);
pix_fmt = av_get_pix_fmt(arg);
if (pix_fmt == AV_PIX_FMT_NONE)
ERROR("Unknown pixel format: %s\n", arg);
if (av_dict_set_int(&config->video_conf, cmd, pix_fmt, 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "VideoGopSize")) {
ffserver_get_arg(arg, sizeof(arg), p);
ffserver_set_int_param(NULL, arg, 0, INT_MIN, INT_MAX, config, line_num, "Invalid %s: %s", cmd, arg);
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "VideoIntraOnly")) {
if (av_dict_set(&config->video_conf, cmd, "1", 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "VideoHighQuality")) {
if (av_dict_set(&config->video_conf, cmd, "", 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "Video4MotionVector")) {
if (av_dict_set(&config->video_conf, cmd, "", 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "AVOptionVideo") ||
!av_strcasecmp(cmd, "AVOptionAudio")) {
AVDictionary **dict;
ffserver_get_arg(arg, sizeof(arg), p);
ffserver_get_arg(arg2, sizeof(arg2), p);
if (!av_strcasecmp(cmd, "AVOptionVideo"))
dict = &config->video_opts;
else
dict = &config->audio_opts;
if (av_dict_set(dict, arg, arg2, 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "AVPresetVideo") ||
!av_strcasecmp(cmd, "AVPresetAudio")) {
char **preset = NULL;
ffserver_get_arg(arg, sizeof(arg), p);
if (!av_strcasecmp(cmd, "AVPresetVideo")) {
preset = &config->video_preset;
ffserver_opt_preset(arg, NULL, 0, NULL, &config->video_id);
} else {
preset = &config->audio_preset;
ffserver_opt_preset(arg, NULL, 0, &config->audio_id, NULL);
}
*preset = av_strdup(arg);
if (!preset)
return AVERROR(ENOMEM);
} else if (!av_strcasecmp(cmd, "VideoTag")) {
ffserver_get_arg(arg, sizeof(arg), p);
if (strlen(arg) == 4) {
if (av_dict_set(&config->video_conf, "VideoTag", "arg", 0) < 0)
goto nomem;
}
} else if (!av_strcasecmp(cmd, "BitExact")) {
if (av_dict_set(&config->video_conf, cmd, "", 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "DctFastint")) {
if (av_dict_set(&config->video_conf, cmd, "", 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "IdctSimple")) {
if (av_dict_set(&config->video_conf, cmd, "", 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "Qscale")) {
ffserver_get_arg(arg, sizeof(arg), p);
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "VideoQDiff")) {
ffserver_get_arg(arg, sizeof(arg), p);
ffserver_set_int_param(NULL, arg, 0, 1, 31, config, line_num, "%s out of range\n", cmd);
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "VideoQMax")) {
ffserver_get_arg(arg, sizeof(arg), p);
ffserver_set_int_param(NULL, arg, 0, 1, 31, config, line_num, "%s out of range\n", cmd);
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "VideoQMin")) {
ffserver_get_arg(arg, sizeof(arg), p);
ffserver_set_int_param(NULL, arg, 0, 1, 31, config, line_num, "%s out of range\n", cmd);
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "LumiMask")) {
ffserver_get_arg(arg, sizeof(arg), p);
ffserver_set_float_param(NULL, arg, 0, -FLT_MAX, FLT_MAX, config, line_num, "Invalid %s: %s", cmd, arg);
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "DarkMask")) {
ffserver_get_arg(arg, sizeof(arg), p);
ffserver_set_float_param(NULL, arg, 0, -FLT_MAX, FLT_MAX, config, line_num, "Invalid %s: %s", cmd, arg);
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
goto nomem;
} else if (!av_strcasecmp(cmd, "NoVideo")) {
config->video_id = AV_CODEC_ID_NONE;
} else if (!av_strcasecmp(cmd, "NoAudio")) {
config->audio_id = AV_CODEC_ID_NONE;
} else if (!av_strcasecmp(cmd, "ACL")) {
ffserver_parse_acl_row(stream, NULL, NULL, *p, config->filename, line_num);
} else if (!av_strcasecmp(cmd, "DynamicACL")) {
ffserver_get_arg(stream->dynamic_acl, sizeof(stream->dynamic_acl), p);
} else if (!av_strcasecmp(cmd, "RTSPOption")) {
ffserver_get_arg(arg, sizeof(arg), p);
av_freep(&stream->rtsp_option);
stream->rtsp_option = av_strdup(arg);
} else if (!av_strcasecmp(cmd, "MulticastAddress")) {
ffserver_get_arg(arg, sizeof(arg), p);
if (resolve_host(&stream->multicast_ip, arg) != 0)
ERROR("Invalid host/IP address: %s\n", arg);
stream->is_multicast = 1;
stream->loop = 1;
} else if (!av_strcasecmp(cmd, "MulticastPort")) {
ffserver_get_arg(arg, sizeof(arg), p);
ffserver_set_int_param(&val, arg, 0, 1, 65535, config, line_num, "Invalid MulticastPort: %s\n", arg);
stream->multicast_port = val;
} else if (!av_strcasecmp(cmd, "MulticastTTL")) {
ffserver_get_arg(arg, sizeof(arg), p);
ffserver_set_int_param(&val, arg, 0, INT_MIN, INT_MAX, config, line_num, "Invalid MulticastTTL: %s\n", arg);
stream->multicast_ttl = val;
} else if (!av_strcasecmp(cmd, "NoLoop")) {
stream->loop = 0;
} else if (!av_strcasecmp(cmd, "</Stream>")) {
if (stream->feed && stream->fmt && strcmp(stream->fmt->name, "ffm") != 0) {
if (config->audio_id != AV_CODEC_ID_NONE) {
AVCodecContext *audio_enc = avcodec_alloc_context3(avcodec_find_encoder(config->audio_id));
if (config->audio_preset &&
ffserver_opt_preset(arg, audio_enc, AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_ENCODING_PARAM,
NULL, NULL) < 0)
ERROR("Could not apply preset '%s'\n", arg);
if (ffserver_apply_stream_config(audio_enc, config->audio_conf, &config->audio_opts) < 0)
config->errors++;
add_codec(stream, audio_enc);
}
if (config->video_id != AV_CODEC_ID_NONE) {
AVCodecContext *video_enc = avcodec_alloc_context3(avcodec_find_encoder(config->video_id));
if (config->video_preset &&
ffserver_opt_preset(arg, video_enc, AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_ENCODING_PARAM,
NULL, NULL) < 0)
ERROR("Could not apply preset '%s'\n", arg);
if (ffserver_apply_stream_config(video_enc, config->video_conf, &config->video_opts) < 0)
config->errors++;
add_codec(stream, video_enc);
}
}
av_dict_free(&config->video_opts);
av_dict_free(&config->video_conf);
av_dict_free(&config->audio_opts);
av_dict_free(&config->audio_conf);
av_freep(&config->video_preset);
av_freep(&config->audio_preset);
*pstream = NULL;
} else if (!av_strcasecmp(cmd, "File") || !av_strcasecmp(cmd, "ReadOnlyFile")) {
ffserver_get_arg(stream->feed_filename, sizeof(stream->feed_filename), p);
} else {
ERROR("Invalid entry '%s' inside <Stream></Stream>\n", cmd);
}
return 0;
nomem:
av_log(NULL, AV_LOG_ERROR, "Out of memory. Aborting.\n");
av_dict_free(&config->video_opts);
av_dict_free(&config->video_conf);
av_dict_free(&config->audio_opts);
av_dict_free(&config->audio_conf);
av_freep(&config->video_preset);
av_freep(&config->audio_preset);
return AVERROR(ENOMEM);
}
| 1threat |
How can i hide request header and parameters for rest api : I am using laravel and vue js.
In vue js, i am requesting api using axios.
when i inspect and get request header and parameters in browser and it is possible to request in Postman.
Everyone can request any apis after login because it is possible to get header and parameters. | 0debug |
How to obtain frames from react-native-camera in real time : <p>I am using the react-native-camera component (<a href="https://github.com/lwansbrough/react-native-camera" rel="noreferrer">https://github.com/lwansbrough/react-native-camera</a>) in an application I am developing.</p>
<p>Is there any way to obtain the individual frames from the video / camera feed such that I may perform processing in real time.</p>
<p>My end goal is to use the tracking.js library to track objects in real time in order to to implement an AR effect.</p>
<p>Thanks for the help!</p>
| 0debug |
static int virtio_net_handle_mac(VirtIONet *n, uint8_t cmd,
VirtQueueElement *elem)
{
struct virtio_net_ctrl_mac mac_data;
if (cmd != VIRTIO_NET_CTRL_MAC_TABLE_SET || elem->out_num != 3 ||
elem->out_sg[1].iov_len < sizeof(mac_data) ||
elem->out_sg[2].iov_len < sizeof(mac_data))
return VIRTIO_NET_ERR;
n->mac_table.in_use = 0;
memset(n->mac_table.macs, 0, MAC_TABLE_ENTRIES * ETH_ALEN);
mac_data.entries = ldl_le_p(elem->out_sg[1].iov_base);
if (sizeof(mac_data.entries) +
(mac_data.entries * ETH_ALEN) > elem->out_sg[1].iov_len)
return VIRTIO_NET_ERR;
if (mac_data.entries <= MAC_TABLE_ENTRIES) {
memcpy(n->mac_table.macs, elem->out_sg[1].iov_base + sizeof(mac_data),
mac_data.entries * ETH_ALEN);
n->mac_table.in_use += mac_data.entries;
} else {
n->promisc = 1;
return VIRTIO_NET_OK;
}
mac_data.entries = ldl_le_p(elem->out_sg[2].iov_base);
if (sizeof(mac_data.entries) +
(mac_data.entries * ETH_ALEN) > elem->out_sg[2].iov_len)
return VIRTIO_NET_ERR;
if (mac_data.entries) {
if (n->mac_table.in_use + mac_data.entries <= MAC_TABLE_ENTRIES) {
memcpy(n->mac_table.macs + (n->mac_table.in_use * ETH_ALEN),
elem->out_sg[2].iov_base + sizeof(mac_data),
mac_data.entries * ETH_ALEN);
n->mac_table.in_use += mac_data.entries;
} else
n->allmulti = 1;
}
return VIRTIO_NET_OK;
}
| 1threat |
static void fill_coding_method_array (sb_int8_array tone_level_idx, sb_int8_array tone_level_idx_temp,
sb_int8_array coding_method, int nb_channels,
int c, int superblocktype_2_3, int cm_table_select)
{
int ch, sb, j;
int tmp, acc, esp_40, comp;
int add1, add2, add3, add4;
int64_t multres;
if (nb_channels <= 0)
return;
if (!superblocktype_2_3) {
SAMPLES_NEEDED
for (ch = 0; ch < nb_channels; ch++)
for (sb = 0; sb < 30; sb++) {
for (j = 1; j < 64; j++) {
add1 = tone_level_idx[ch][sb][j] - 10;
if (add1 < 0)
add1 = 0;
add2 = add3 = add4 = 0;
if (sb > 1) {
add2 = tone_level_idx[ch][sb - 2][j] + tone_level_idx_offset_table[sb][0] - 6;
if (add2 < 0)
add2 = 0;
}
if (sb > 0) {
add3 = tone_level_idx[ch][sb - 1][j] + tone_level_idx_offset_table[sb][1] - 6;
if (add3 < 0)
add3 = 0;
}
if (sb < 29) {
add4 = tone_level_idx[ch][sb + 1][j] + tone_level_idx_offset_table[sb][3] - 6;
if (add4 < 0)
add4 = 0;
}
tmp = tone_level_idx[ch][sb][j + 1] * 2 - add4 - add3 - add2 - add1;
if (tmp < 0)
tmp = 0;
tone_level_idx_temp[ch][sb][j + 1] = tmp & 0xff;
}
tone_level_idx_temp[ch][sb][0] = tone_level_idx_temp[ch][sb][1];
}
acc = 0;
for (ch = 0; ch < nb_channels; ch++)
for (sb = 0; sb < 30; sb++)
for (j = 0; j < 64; j++)
acc += tone_level_idx_temp[ch][sb][j];
if (acc)
tmp = c * 256 / (acc & 0xffff);
multres = 0x66666667 * (acc * 10);
esp_40 = (multres >> 32) / 8 + ((multres & 0xffffffff) >> 31);
for (ch = 0; ch < nb_channels; ch++)
for (sb = 0; sb < 30; sb++)
for (j = 0; j < 64; j++) {
comp = tone_level_idx_temp[ch][sb][j]* esp_40 * 10;
if (comp < 0)
comp += 0xff;
comp /= 256;
switch(sb) {
case 0:
if (comp < 30)
comp = 30;
comp += 15;
break;
case 1:
if (comp < 24)
comp = 24;
comp += 10;
break;
case 2:
case 3:
case 4:
if (comp < 16)
comp = 16;
}
if (comp <= 5)
tmp = 0;
else if (comp <= 10)
tmp = 10;
else if (comp <= 16)
tmp = 16;
else if (comp <= 24)
tmp = -1;
else
tmp = 0;
coding_method[ch][sb][j] = ((tmp & 0xfffa) + 30 )& 0xff;
}
for (sb = 0; sb < 30; sb++)
fix_coding_method_array(sb, nb_channels, coding_method);
for (ch = 0; ch < nb_channels; ch++)
for (sb = 0; sb < 30; sb++)
for (j = 0; j < 64; j++)
if (sb >= 10) {
if (coding_method[ch][sb][j] < 10)
coding_method[ch][sb][j] = 10;
} else {
if (sb >= 2) {
if (coding_method[ch][sb][j] < 16)
coding_method[ch][sb][j] = 16;
} else {
if (coding_method[ch][sb][j] < 30)
coding_method[ch][sb][j] = 30;
}
}
} else {
for (ch = 0; ch < nb_channels; ch++)
for (sb = 0; sb < 30; sb++)
for (j = 0; j < 64; j++)
coding_method[ch][sb][j] = coding_method_table[cm_table_select][sb];
}
return;
}
| 1threat |
If statement for all except one : <p>I am more familiar with JS than with PHP. What I would like to have, is a php condition that runs for all pages except one. </p>
<p>I would like below "only not for page ID 2":</p>
<pre><code>function my_action() {
if( is_page( 2 ) ) {
// code here
}
}
</code></pre>
<p>Does PHP cover also cover the <code>!</code> exception rule and if so; where do I put this?</p>
| 0debug |
void fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value)
{
uint16_t *copy;
copy = g_malloc(sizeof(value));
*copy = cpu_to_le16(value);
fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));
}
| 1threat |
static int ff_filter_frame_framed(AVFilterLink *link, AVFrame *frame)
{
int (*filter_frame)(AVFilterLink *, AVFrame *);
AVFilterContext *dstctx = link->dst;
AVFilterPad *dst = link->dstpad;
AVFrame *out;
int ret;
AVFilterCommand *cmd= link->dst->command_queue;
int64_t pts;
if (link->closed) {
av_frame_free(&frame);
return AVERROR_EOF;
}
if (!(filter_frame = dst->filter_frame))
filter_frame = default_filter_frame;
if (dst->needs_writable && !av_frame_is_writable(frame)) {
av_log(link->dst, AV_LOG_DEBUG, "Copying data in avfilter.\n");
switch (link->type) {
case AVMEDIA_TYPE_VIDEO:
out = ff_get_video_buffer(link, link->w, link->h);
break;
case AVMEDIA_TYPE_AUDIO:
out = ff_get_audio_buffer(link, frame->nb_samples);
break;
default:
ret = AVERROR(EINVAL);
goto fail;
}
if (!out) {
ret = AVERROR(ENOMEM);
goto fail;
}
ret = av_frame_copy_props(out, frame);
if (ret < 0)
goto fail;
switch (link->type) {
case AVMEDIA_TYPE_VIDEO:
av_image_copy(out->data, out->linesize, (const uint8_t **)frame->data, frame->linesize,
frame->format, frame->width, frame->height);
break;
case AVMEDIA_TYPE_AUDIO:
av_samples_copy(out->extended_data, frame->extended_data,
0, 0, frame->nb_samples,
av_get_channel_layout_nb_channels(frame->channel_layout),
frame->format);
break;
default:
ret = AVERROR(EINVAL);
goto fail;
}
av_frame_free(&frame);
} else
out = frame;
while(cmd && cmd->time <= out->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;
if (dstctx->enable_str) {
int64_t pos = av_frame_get_pkt_pos(out);
dstctx->var_values[VAR_N] = link->frame_count;
dstctx->var_values[VAR_T] = pts == AV_NOPTS_VALUE ? NAN : pts * av_q2d(link->time_base);
dstctx->var_values[VAR_POS] = pos == -1 ? NAN : pos;
dstctx->is_disabled = fabs(av_expr_eval(dstctx->enable, dstctx->var_values, NULL)) < 0.5;
if (dstctx->is_disabled &&
(dstctx->filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC))
filter_frame = default_filter_frame;
}
ret = filter_frame(link, out);
link->frame_count++;
link->frame_requested = 0;
ff_update_link_current_pts(link, pts);
return ret;
fail:
av_frame_free(&out);
av_frame_free(&frame);
return ret;
}
| 1threat |
static void vmxnet3_activate_device(VMXNET3State *s)
{
int i;
static const uint32_t VMXNET3_DEF_TX_THRESHOLD = 1;
hwaddr qdescr_table_pa;
uint64_t pa;
uint32_t size;
if (!vmxnet3_verify_driver_magic(s->drv_shmem)) {
VMW_ERPRN("Device configuration received from driver is invalid");
return;
}
if (s->device_active) {
VMW_CFPRN("Vmxnet3 device is active");
return;
}
vmxnet3_adjust_by_guest_type(s);
vmxnet3_update_features(s);
vmxnet3_update_pm_state(s);
vmxnet3_setup_rx_filtering(s);
s->mtu = VMXNET3_READ_DRV_SHARED32(s->drv_shmem, devRead.misc.mtu);
VMW_CFPRN("MTU is %u", s->mtu);
s->max_rx_frags =
VMXNET3_READ_DRV_SHARED16(s->drv_shmem, devRead.misc.maxNumRxSG);
if (s->max_rx_frags == 0) {
s->max_rx_frags = 1;
}
VMW_CFPRN("Max RX fragments is %u", s->max_rx_frags);
s->event_int_idx =
VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.intrConf.eventIntrIdx);
assert(vmxnet3_verify_intx(s, s->event_int_idx));
VMW_CFPRN("Events interrupt line is %u", s->event_int_idx);
s->auto_int_masking =
VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.intrConf.autoMask);
VMW_CFPRN("Automatic interrupt masking is %d", (int)s->auto_int_masking);
s->txq_num =
VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.misc.numTxQueues);
s->rxq_num =
VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.misc.numRxQueues);
VMW_CFPRN("Number of TX/RX queues %u/%u", s->txq_num, s->rxq_num);
vmxnet3_validate_queues(s);
qdescr_table_pa =
VMXNET3_READ_DRV_SHARED64(s->drv_shmem, devRead.misc.queueDescPA);
VMW_CFPRN("TX queues descriptors table is at 0x%" PRIx64, qdescr_table_pa);
s->max_tx_frags = 0;
for (i = 0; i < s->txq_num; i++) {
hwaddr qdescr_pa =
qdescr_table_pa + i * sizeof(struct Vmxnet3_TxQueueDesc);
s->txq_descr[i].intr_idx =
VMXNET3_READ_TX_QUEUE_DESCR8(qdescr_pa, conf.intrIdx);
assert(vmxnet3_verify_intx(s, s->txq_descr[i].intr_idx));
VMW_CFPRN("TX Queue %d interrupt: %d", i, s->txq_descr[i].intr_idx);
pa = VMXNET3_READ_TX_QUEUE_DESCR64(qdescr_pa, conf.txRingBasePA);
size = VMXNET3_READ_TX_QUEUE_DESCR32(qdescr_pa, conf.txRingSize);
vmxnet3_ring_init(&s->txq_descr[i].tx_ring, pa, size,
sizeof(struct Vmxnet3_TxDesc), false);
VMXNET3_RING_DUMP(VMW_CFPRN, "TX", i, &s->txq_descr[i].tx_ring);
s->max_tx_frags += size;
pa = VMXNET3_READ_TX_QUEUE_DESCR64(qdescr_pa, conf.compRingBasePA);
size = VMXNET3_READ_TX_QUEUE_DESCR32(qdescr_pa, conf.compRingSize);
vmxnet3_ring_init(&s->txq_descr[i].comp_ring, pa, size,
sizeof(struct Vmxnet3_TxCompDesc), true);
VMXNET3_RING_DUMP(VMW_CFPRN, "TXC", i, &s->txq_descr[i].comp_ring);
s->txq_descr[i].tx_stats_pa =
qdescr_pa + offsetof(struct Vmxnet3_TxQueueDesc, stats);
memset(&s->txq_descr[i].txq_stats, 0,
sizeof(s->txq_descr[i].txq_stats));
VMXNET3_WRITE_TX_QUEUE_DESCR32(qdescr_pa,
ctrl.txThreshold,
VMXNET3_DEF_TX_THRESHOLD);
}
VMW_CFPRN("Max TX fragments is %u", s->max_tx_frags);
net_tx_pkt_init(&s->tx_pkt, PCI_DEVICE(s),
s->max_tx_frags, s->peer_has_vhdr);
net_rx_pkt_init(&s->rx_pkt, s->peer_has_vhdr);
for (i = 0; i < s->rxq_num; i++) {
int j;
hwaddr qd_pa =
qdescr_table_pa + s->txq_num * sizeof(struct Vmxnet3_TxQueueDesc) +
i * sizeof(struct Vmxnet3_RxQueueDesc);
s->rxq_descr[i].intr_idx =
VMXNET3_READ_TX_QUEUE_DESCR8(qd_pa, conf.intrIdx);
assert(vmxnet3_verify_intx(s, s->rxq_descr[i].intr_idx));
VMW_CFPRN("RX Queue %d interrupt: %d", i, s->rxq_descr[i].intr_idx);
for (j = 0; j < VMXNET3_RX_RINGS_PER_QUEUE; j++) {
pa = VMXNET3_READ_RX_QUEUE_DESCR64(qd_pa, conf.rxRingBasePA[j]);
size = VMXNET3_READ_RX_QUEUE_DESCR32(qd_pa, conf.rxRingSize[j]);
vmxnet3_ring_init(&s->rxq_descr[i].rx_ring[j], pa, size,
sizeof(struct Vmxnet3_RxDesc), false);
VMW_CFPRN("RX queue %d:%d: Base: %" PRIx64 ", Size: %d",
i, j, pa, size);
}
pa = VMXNET3_READ_RX_QUEUE_DESCR64(qd_pa, conf.compRingBasePA);
size = VMXNET3_READ_RX_QUEUE_DESCR32(qd_pa, conf.compRingSize);
vmxnet3_ring_init(&s->rxq_descr[i].comp_ring, pa, size,
sizeof(struct Vmxnet3_RxCompDesc), true);
VMW_CFPRN("RXC queue %d: Base: %" PRIx64 ", Size: %d", i, pa, size);
s->rxq_descr[i].rx_stats_pa =
qd_pa + offsetof(struct Vmxnet3_RxQueueDesc, stats);
memset(&s->rxq_descr[i].rxq_stats, 0,
sizeof(s->rxq_descr[i].rxq_stats));
}
vmxnet3_validate_interrupts(s);
smp_wmb();
vmxnet3_reset_mac(s);
s->device_active = true;
}
| 1threat |
Python sorting two lists together? : <p>I'm having some problems with my code below. I have my two lists names and scores. These lists, correspond with each other as seen below. My goal is to print out the first three greatest items in both lists. I've attempted to sort them together from greatest to least and then print out the first three items, but I'm getting some unbounderror. Any thoughts? Thanks. </p>
<pre><code>names = ['Xander', 'Spec', 'Meng', 'Sparc', 'Jones', 'Nick', 'Link']
scores = [120, 450, 300, 200, 66, 183, 80]
scores, names = (list(t) for t in zip(*sorted(zip(scores, names))))
print(names[:3] + " " + scores[:3])
</code></pre>
<p>Example Output:</p>
<pre><code>Spec 450
Meng 300
Sparc 200
</code></pre>
| 0debug |
Need help to check winning conditions for a Tic-Tac-Toe game in Js : <p>I dont know how to check for the winning conditions.Could someone explain it to me step by step.I'll post my code. Im also new to coding.</p>
<p>prntscr.com/m06ew1</p>
<pre><code><!DOCTYPE html>
<html>
<head>
<title>Tic-Tac-Toe</title>
<link rel="stylesheet" href="TicTacToe.css">
</head>
<body>
<h1> Tic-Tac-Toe game!</h1>
<div class="grid">
<div class="grid-item" id="grid1" ></div>
<div class="grid-item" id="grid2" ></div>
<div class="grid-item" id="grid3" ></div>
<div class="grid-item" id="grid4" ></div>
<div class="grid-item" id="grid5" ></div>
<div class="grid-item" id="grid6" ></div>
<div class="grid-item" id="grid7" ></div>
<div class="grid-item" id="grid8" ></div>
<div class="grid-item" id="grid9" ></div>
</div>
</body>
<script type="text/javascript" src="jquery-3.3.1.js" ></script>
<script type="text/javascript" src="TicTacToe.js" ></script>
<aside>
<h2>History</h2>
</aside>
<section>Player <span id="player"> <b>1</b> </span> it's your
turn!</section>
<footer>
Copyright Irfan - 2018
</footer>
</html>
JSFILE
$("document").ready (function(){
const player1 = 'X'
const player2 = 'O'
CurrentPlayer = 1
$(".grid-item").click (function(){
if(CurrentPlayer == 1) {
$(this).html(player1);
$("#player").html("<b>2<b>")
CurrentPlayer = 2
}
else if ( CurrentPlayer == 2) {
$(this).html(player2);
$("#player").html("<b>1<b>")
CurrentPlayer =1
}
});
});
</code></pre>
<p>here is my code and i link a print screen above.Its for a tic tac tow game sdfafsdfdfsafdfasdafsdafafdfasddasfasdfafsdfda</p>
| 0debug |
document.getElementById('input').innerHTML = user_input; | 1threat |
How to return value from webView.evaluateJavascript callback? : <p>So I have a class named <strong>JavascriptBridge</strong> that I use to communicate between Java and Javascript.</p>
<p>To send commands to javascript, I simply use this:</p>
<pre><code>public void sendDataToJs(String command) {
webView.loadUrl("javascript:(function() { " + command + "})()");
}
</code></pre>
<p>My problem is that I would also need a function that return a response from the Javascript. I try using <strong>webView.evaluateJavascript</strong>, but it skip the callback, as evaluateJavascript is done on another thread.</p>
<pre><code>public String getDataFromJs(String command, WebView webView) {
String data = null;
webView.evaluateJavascript("(function() { return " + command + "; })();", new ValueCallback<String>() {
@Override
public void onReceiveValue(String s) {
Log.d("LogName", s); // Print "test"
// data = s; // The value that I would like to return
}
});
return data; // Return null, not "test"
}
</code></pre>
<p>The call to the method:</p>
<pre><code>String result = getDataFromJs("test", webView); // Should return "test" from the webView
</code></pre>
<p>I've also tried using a <strong>@JavascriptInterface</strong>, but it gives the same result.</p>
| 0debug |
static void megasas_complete_frame(MegasasState *s, uint64_t context)
{
PCIDevice *pci_dev = PCI_DEVICE(s);
int tail, queue_offset;
s->busy--;
if (s->reply_queue_pa) {
tail = s->reply_queue_head;
if (megasas_use_queue64(s)) {
queue_offset = tail * sizeof(uint64_t);
stq_le_phys(&address_space_memory,
s->reply_queue_pa + queue_offset, context);
} else {
queue_offset = tail * sizeof(uint32_t);
stl_le_phys(&address_space_memory,
s->reply_queue_pa + queue_offset, context);
}
s->reply_queue_head = megasas_next_index(s, tail, s->fw_cmds);
s->reply_queue_tail = ldl_le_phys(&address_space_memory,
s->consumer_pa);
trace_megasas_qf_complete(context, s->reply_queue_head,
s->reply_queue_tail, s->busy, s->doorbell);
}
if (megasas_intr_enabled(s)) {
s->doorbell++;
if (s->doorbell == 1) {
if (msix_enabled(pci_dev)) {
trace_megasas_msix_raise(0);
msix_notify(pci_dev, 0);
} else if (msi_enabled(pci_dev)) {
trace_megasas_msi_raise(0);
msi_notify(pci_dev, 0);
} else {
trace_megasas_irq_raise();
pci_irq_assert(pci_dev);
}
}
} else {
trace_megasas_qf_complete_noirq(context);
}
}
| 1threat |
static void lm32_uclinux_init(QEMUMachineInitArgs *args)
{
const char *cpu_model = args->cpu_model;
const char *kernel_filename = args->kernel_filename;
const char *kernel_cmdline = args->kernel_cmdline;
const char *initrd_filename = args->initrd_filename;
LM32CPU *cpu;
CPULM32State *env;
DriveInfo *dinfo;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
qemu_irq *cpu_irq, irq[32];
HWSetup *hw;
ResetInfo *reset_info;
int i;
target_phys_addr_t flash_base = 0x04000000;
size_t flash_sector_size = 256 * 1024;
size_t flash_size = 32 * 1024 * 1024;
target_phys_addr_t ram_base = 0x08000000;
size_t ram_size = 64 * 1024 * 1024;
target_phys_addr_t uart0_base = 0x80000000;
target_phys_addr_t timer0_base = 0x80002000;
target_phys_addr_t timer1_base = 0x80010000;
target_phys_addr_t timer2_base = 0x80012000;
int uart0_irq = 0;
int timer0_irq = 1;
int timer1_irq = 20;
int timer2_irq = 21;
target_phys_addr_t hwsetup_base = 0x0bffe000;
target_phys_addr_t cmdline_base = 0x0bfff000;
target_phys_addr_t initrd_base = 0x08400000;
size_t initrd_max = 0x01000000;
reset_info = g_malloc0(sizeof(ResetInfo));
if (cpu_model == NULL) {
cpu_model = "lm32-full";
}
cpu = cpu_lm32_init(cpu_model);
env = &cpu->env;
reset_info->cpu = cpu;
reset_info->flash_base = flash_base;
memory_region_init_ram(phys_ram, "lm32_uclinux.sdram", ram_size);
vmstate_register_ram_global(phys_ram);
memory_region_add_subregion(address_space_mem, ram_base, phys_ram);
dinfo = drive_get(IF_PFLASH, 0, 0);
pflash_cfi02_register(flash_base, NULL, "lm32_uclinux.flash", flash_size,
dinfo ? dinfo->bdrv : NULL, flash_sector_size,
flash_size / flash_sector_size, 1, 2,
0x01, 0x7e, 0x43, 0x00, 0x555, 0x2aa, 1);
cpu_irq = qemu_allocate_irqs(cpu_irq_handler, env, 1);
env->pic_state = lm32_pic_init(*cpu_irq);
for (i = 0; i < 32; i++) {
irq[i] = qdev_get_gpio_in(env->pic_state, i);
}
sysbus_create_simple("lm32-uart", uart0_base, irq[uart0_irq]);
sysbus_create_simple("lm32-timer", timer0_base, irq[timer0_irq]);
sysbus_create_simple("lm32-timer", timer1_base, irq[timer1_irq]);
sysbus_create_simple("lm32-timer", timer2_base, irq[timer2_irq]);
env->juart_state = lm32_juart_init();
reset_info->bootstrap_pc = flash_base;
if (kernel_filename) {
uint64_t entry;
int kernel_size;
kernel_size = load_elf(kernel_filename, NULL, NULL, &entry, NULL, NULL,
1, ELF_MACHINE, 0);
reset_info->bootstrap_pc = entry;
if (kernel_size < 0) {
kernel_size = load_image_targphys(kernel_filename, ram_base,
ram_size);
reset_info->bootstrap_pc = ram_base;
}
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
kernel_filename);
exit(1);
}
}
hw = hwsetup_init();
hwsetup_add_cpu(hw, "LM32", 75000000);
hwsetup_add_flash(hw, "flash", flash_base, flash_size);
hwsetup_add_ddr_sdram(hw, "ddr_sdram", ram_base, ram_size);
hwsetup_add_timer(hw, "timer0", timer0_base, timer0_irq);
hwsetup_add_timer(hw, "timer1_dev_only", timer1_base, timer1_irq);
hwsetup_add_timer(hw, "timer2_dev_only", timer2_base, timer2_irq);
hwsetup_add_uart(hw, "uart", uart0_base, uart0_irq);
hwsetup_add_trailer(hw);
hwsetup_create_rom(hw, hwsetup_base);
hwsetup_free(hw);
reset_info->hwsetup_base = hwsetup_base;
if (kernel_cmdline && strlen(kernel_cmdline)) {
pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE,
kernel_cmdline);
reset_info->cmdline_base = cmdline_base;
}
if (initrd_filename) {
size_t initrd_size;
initrd_size = load_image_targphys(initrd_filename, initrd_base,
initrd_max);
reset_info->initrd_base = initrd_base;
reset_info->initrd_size = initrd_size;
}
qemu_register_reset(main_cpu_reset, reset_info);
}
| 1threat |
Unable to create tempDir, java.io.tmpdir is set to C:\Windows\ : <p>I'm using Spring Boot with embedded tomcat, everything worked fine and suddenly I got the error :</p>
<pre><code>Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to create tempDir. java.io.tmpdir is set to C:\Windows\
at org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory.createTempDir(AbstractEmbeddedServletContainerFactory.java:183)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:165)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134)
... 11 common frames omitted
Caused by: java.io.IOException: Access is denied
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createTempFile(File.java:2024)
at java.io.File.createTempFile(File.java:2070)
at org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory.createTempDir(AbstractEmbeddedServletContainerFactory.java:174)
... 14 common frames omitted
</code></pre>
<p>I didn't do any manipulations with user or system variables.</p>
<p>My TEMP <strong>user</strong> variable is looking on C:/Users/<em>me</em>/AppData/Local/Temp , and I guess tomcat has to use this value insted of system one, which is actually C:/Windows/Temp</p>
| 0debug |
Javascript Dont Change The Background : <p>I want to change my list background but it wont work</p>
<p>my code :</p>
<pre><code>change(num, element){
var text
if (num == 1){ ... }
else if (num == 2) { ... }
else { ... }
document.getElementById('text').innerHTML = text;
document.getElementByClass("left").style.backgroundColor = "black"; //<------
element.style.backgroundColor = "white"; //<------
}
</code></pre>
<p>and my html :</p>
<pre><code><ul>
<li><a class="left" href="#" onclick="change(1,this)>First</a></li>
<li><a class="left" href="#" onclick="change(2,this)>Second</a></li>
<li><a class="left" href="#" onclick="change(3,this)>Third</a></li>
</ul>
</code></pre>
<p>When i click on one of my list element , the text changes but background color won't ...</p>
<p>How i can fix this ?</p>
<p>Thanks,</p>
| 0debug |
static inline void rv34_mc(RV34DecContext *r, const int block_type,
const int xoff, const int yoff, int mv_off,
const int width, const int height, int dir,
const int thirdpel, int weighted,
qpel_mc_func (*qpel_mc)[16],
h264_chroma_mc_func (*chroma_mc))
{
MpegEncContext *s = &r->s;
uint8_t *Y, *U, *V, *srcY, *srcU, *srcV;
int dxy, mx, my, umx, umy, lx, ly, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride + mv_off;
int is16x16 = 1;
if(thirdpel){
int chroma_mx, chroma_my;
mx = (s->current_picture_ptr->f.motion_val[dir][mv_pos][0] + (3 << 24)) / 3 - (1 << 24);
my = (s->current_picture_ptr->f.motion_val[dir][mv_pos][1] + (3 << 24)) / 3 - (1 << 24);
lx = (s->current_picture_ptr->f.motion_val[dir][mv_pos][0] + (3 << 24)) % 3;
ly = (s->current_picture_ptr->f.motion_val[dir][mv_pos][1] + (3 << 24)) % 3;
chroma_mx = s->current_picture_ptr->f.motion_val[dir][mv_pos][0] / 2;
chroma_my = s->current_picture_ptr->f.motion_val[dir][mv_pos][1] / 2;
umx = (chroma_mx + (3 << 24)) / 3 - (1 << 24);
umy = (chroma_my + (3 << 24)) / 3 - (1 << 24);
uvmx = chroma_coeffs[(chroma_mx + (3 << 24)) % 3];
uvmy = chroma_coeffs[(chroma_my + (3 << 24)) % 3];
}else{
int cx, cy;
mx = s->current_picture_ptr->f.motion_val[dir][mv_pos][0] >> 2;
my = s->current_picture_ptr->f.motion_val[dir][mv_pos][1] >> 2;
lx = s->current_picture_ptr->f.motion_val[dir][mv_pos][0] & 3;
ly = s->current_picture_ptr->f.motion_val[dir][mv_pos][1] & 3;
cx = s->current_picture_ptr->f.motion_val[dir][mv_pos][0] / 2;
cy = s->current_picture_ptr->f.motion_val[dir][mv_pos][1] / 2;
umx = cx >> 2;
umy = cy >> 2;
uvmx = (cx & 3) << 1;
uvmy = (cy & 3) << 1;
if(uvmx == 6 && uvmy == 6)
uvmx = uvmy = 4;
}
if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) {
int mb_row = FFMIN(s->mb_height - 1, s->mb_y + ((yoff + my + 21) >> 4));
AVFrame *f = dir ? &s->next_picture_ptr->f : &s->last_picture_ptr->f;
ff_thread_await_progress(f, mb_row, 0);
}
dxy = ly*4 + lx;
srcY = dir ? s->next_picture_ptr->f.data[0] : s->last_picture_ptr->f.data[0];
srcU = dir ? s->next_picture_ptr->f.data[1] : s->last_picture_ptr->f.data[1];
srcV = dir ? s->next_picture_ptr->f.data[2] : s->last_picture_ptr->f.data[2];
src_x = s->mb_x * 16 + xoff + mx;
src_y = s->mb_y * 16 + yoff + my;
uvsrc_x = s->mb_x * 8 + (xoff >> 1) + umx;
uvsrc_y = s->mb_y * 8 + (yoff >> 1) + umy;
srcY += src_y * s->linesize + src_x;
srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
if(s->h_edge_pos - (width << 3) < 6 || s->v_edge_pos - (height << 3) < 6 ||
(unsigned)(src_x - !!lx*2) > s->h_edge_pos - !!lx*2 - (width <<3) - 4 ||
(unsigned)(src_y - !!ly*2) > s->v_edge_pos - !!ly*2 - (height<<3) - 4) {
uint8_t *uvbuf = s->edge_emu_buffer + 22 * s->linesize;
srcY -= 2 + 2*s->linesize;
s->dsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, (width<<3)+6, (height<<3)+6,
src_x - 2, src_y - 2, s->h_edge_pos, s->v_edge_pos);
srcY = s->edge_emu_buffer + 2 + 2*s->linesize;
s->dsp.emulated_edge_mc(uvbuf , srcU, s->uvlinesize, (width<<2)+1, (height<<2)+1,
uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1);
s->dsp.emulated_edge_mc(uvbuf + 16, srcV, s->uvlinesize, (width<<2)+1, (height<<2)+1,
uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1);
srcU = uvbuf;
srcV = uvbuf + 16;
}
if(!weighted){
Y = s->dest[0] + xoff + yoff *s->linesize;
U = s->dest[1] + (xoff>>1) + (yoff>>1)*s->uvlinesize;
V = s->dest[2] + (xoff>>1) + (yoff>>1)*s->uvlinesize;
}else{
Y = r->tmp_b_block_y [dir] + xoff + yoff *s->linesize;
U = r->tmp_b_block_uv[dir*2] + (xoff>>1) + (yoff>>1)*s->uvlinesize;
V = r->tmp_b_block_uv[dir*2+1] + (xoff>>1) + (yoff>>1)*s->uvlinesize;
}
if(block_type == RV34_MB_P_16x8){
qpel_mc[1][dxy](Y, srcY, s->linesize);
Y += 8;
srcY += 8;
}else if(block_type == RV34_MB_P_8x16){
qpel_mc[1][dxy](Y, srcY, s->linesize);
Y += 8 * s->linesize;
srcY += 8 * s->linesize;
}
is16x16 = (block_type != RV34_MB_P_8x8) && (block_type != RV34_MB_P_16x8) && (block_type != RV34_MB_P_8x16);
qpel_mc[!is16x16][dxy](Y, srcY, s->linesize);
chroma_mc[2-width] (U, srcU, s->uvlinesize, height*4, uvmx, uvmy);
chroma_mc[2-width] (V, srcV, s->uvlinesize, height*4, uvmx, uvmy);
}
| 1threat |
int ff_mpeg_ref_picture(MpegEncContext *s, Picture *dst, Picture *src)
{
int ret;
av_assert0(!dst->f.buf[0]);
av_assert0(src->f.buf[0]);
src->tf.f = &src->f;
dst->tf.f = &dst->f;
ret = ff_thread_ref_frame(&dst->tf, &src->tf);
if (ret < 0)
goto fail;
ret = update_picture_tables(dst, src);
if (ret < 0)
goto fail;
if (src->hwaccel_picture_private) {
dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf);
if (!dst->hwaccel_priv_buf)
goto fail;
dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data;
}
dst->field_picture = src->field_picture;
dst->mb_var_sum = src->mb_var_sum;
dst->mc_mb_var_sum = src->mc_mb_var_sum;
dst->b_frame_score = src->b_frame_score;
dst->needs_realloc = src->needs_realloc;
dst->reference = src->reference;
dst->shared = src->shared;
return 0;
fail:
ff_mpeg_unref_picture(s, dst);
return ret;
}
| 1threat |
av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth,
const int chroma_format_idc)
{
#undef FUNC
#define FUNC(a, depth) a ## _ ## depth ## _c
#define ADDPX_DSP(depth) \
c->h264_add_pixels4_clear = FUNC(ff_h264_add_pixels4, depth);\
c->h264_add_pixels8_clear = FUNC(ff_h264_add_pixels8, depth)
if (bit_depth > 8 && bit_depth <= 16) {
ADDPX_DSP(16);
} else {
ADDPX_DSP(8);
}
#define H264_DSP(depth) \
c->h264_idct_add= FUNC(ff_h264_idct_add, depth);\
c->h264_idct8_add= FUNC(ff_h264_idct8_add, depth);\
c->h264_idct_dc_add= FUNC(ff_h264_idct_dc_add, depth);\
c->h264_idct8_dc_add= FUNC(ff_h264_idct8_dc_add, depth);\
c->h264_idct_add16 = FUNC(ff_h264_idct_add16, depth);\
c->h264_idct8_add4 = FUNC(ff_h264_idct8_add4, depth);\
if (chroma_format_idc == 1)\
c->h264_idct_add8 = FUNC(ff_h264_idct_add8, depth);\
else\
c->h264_idct_add8 = FUNC(ff_h264_idct_add8_422, depth);\
c->h264_idct_add16intra= FUNC(ff_h264_idct_add16intra, depth);\
c->h264_luma_dc_dequant_idct= FUNC(ff_h264_luma_dc_dequant_idct, depth);\
if (chroma_format_idc == 1)\
c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma_dc_dequant_idct, depth);\
else\
c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma422_dc_dequant_idct, depth);\
\
c->weight_h264_pixels_tab[0]= FUNC(weight_h264_pixels16, depth);\
c->weight_h264_pixels_tab[1]= FUNC(weight_h264_pixels8, depth);\
c->weight_h264_pixels_tab[2]= FUNC(weight_h264_pixels4, depth);\
c->weight_h264_pixels_tab[3]= FUNC(weight_h264_pixels2, depth);\
c->biweight_h264_pixels_tab[0]= FUNC(biweight_h264_pixels16, depth);\
c->biweight_h264_pixels_tab[1]= FUNC(biweight_h264_pixels8, depth);\
c->biweight_h264_pixels_tab[2]= FUNC(biweight_h264_pixels4, depth);\
c->biweight_h264_pixels_tab[3]= FUNC(biweight_h264_pixels2, depth);\
\
c->h264_v_loop_filter_luma= FUNC(h264_v_loop_filter_luma, depth);\
c->h264_h_loop_filter_luma= FUNC(h264_h_loop_filter_luma, depth);\
c->h264_h_loop_filter_luma_mbaff= FUNC(h264_h_loop_filter_luma_mbaff, depth);\
c->h264_v_loop_filter_luma_intra= FUNC(h264_v_loop_filter_luma_intra, depth);\
c->h264_h_loop_filter_luma_intra= FUNC(h264_h_loop_filter_luma_intra, depth);\
c->h264_h_loop_filter_luma_mbaff_intra= FUNC(h264_h_loop_filter_luma_mbaff_intra, depth);\
c->h264_v_loop_filter_chroma= FUNC(h264_v_loop_filter_chroma, depth);\
if (chroma_format_idc == 1)\
c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma, depth);\
else\
c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma422, depth);\
if (chroma_format_idc == 1)\
c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma_mbaff, depth);\
else\
c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma422_mbaff, depth);\
c->h264_v_loop_filter_chroma_intra= FUNC(h264_v_loop_filter_chroma_intra, depth);\
if (chroma_format_idc == 1)\
c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma_intra, depth);\
else\
c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma422_intra, depth);\
if (chroma_format_idc == 1)\
c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma_mbaff_intra, depth);\
else\
c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma422_mbaff_intra, depth);\
c->h264_loop_filter_strength= NULL;
switch (bit_depth) {
case 9:
H264_DSP(9);
break;
case 10:
H264_DSP(10);
break;
default:
H264_DSP(8);
break;
}
c->h264_find_start_code_candidate = h264_find_start_code_candidate_c;
if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth, chroma_format_idc);
if (ARCH_PPC) ff_h264dsp_init_ppc(c, bit_depth, chroma_format_idc);
if (ARCH_X86) ff_h264dsp_init_x86(c, bit_depth, chroma_format_idc);
}
| 1threat |
static int gif_video_probe(AVProbeData * pd)
{
const uint8_t *p, *p_end;
int bits_per_pixel, has_global_palette, ext_code, ext_len;
int gce_flags, gce_disposal;
if (pd->buf_size < 24 ||
memcmp(pd->buf, gif89a_sig, 6) != 0)
return 0;
p_end = pd->buf + pd->buf_size;
p = pd->buf + 6;
bits_per_pixel = (p[4] & 0x07) + 1;
has_global_palette = (p[4] & 0x80);
p += 7;
if (has_global_palette)
p += (1 << bits_per_pixel) * 3;
for(;;) {
if (p >= p_end)
return 0;
if (*p != '!')
break;
p++;
if (p >= p_end)
return 0;
ext_code = *p++;
if (p >= p_end)
return 0;
ext_len = *p++;
if (ext_code == 0xf9) {
if (p >= p_end)
return 0;
gce_flags = *p++;
gce_disposal = (gce_flags >> 2) & 0x7;
if (gce_disposal != 0)
return AVPROBE_SCORE_MAX;
else
return 0;
}
for(;;) {
if (ext_len == 0)
break;
p += ext_len;
if (p >= p_end)
return 0;
ext_len = *p++;
}
}
return 0;
}
| 1threat |
Pure c . Array of structures. Dynamically allocated within a function. How to allocate memory correct? : The code below had made from examples of this site. I can't understand what am I doing wrong? Could you please point me.
Compiling with:
gcc -std=c11 main.c
Prints only:
> Thing: Boiled buckwheat, weight: 1500
> Segmentation fault
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
typedef struct {
// Weight in grams
size_t weight;
// Name of Thing
char name[255];
} Things;
void add_new_thing(Things **things,size_t *size)
{
size_t index = *size;
if(index == 0){
(*size) = 1;
*things = (Things*)calloc((*size),sizeof(Things));
if (*things == NULL) {
fprintf(stderr, "Error: can't allocate memory! %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
}else{
(*size) += 1;
Things *temp = (Things*)realloc(*things,(*size)*sizeof(Things));
if(temp != NULL) {
*things = temp;
}else{
fprintf(stderr, "Error: can't reallocate memory! %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
// Zeroing of new structure's elements
things[index]->name[0] = '\0';
things[index]->weight = 0;
}
}
void another_function(Things *things,size_t *size)
{
// Add one element to array of structures
add_new_thing(&things,size);
const char *str1 = "Boiled buckwheat";
strncpy(things[*size-1].name, str1, strlen(str1) + 1);
things[*size-1].weight = 1500;
for(size_t i = 0;i < *size;i++){
printf("Thing: %s, weight: %zu\n",things[i].name,things[i].weight);
}
// One element of array of structures was printed there
// Add new one element to array of structures
add_new_thing(&things,size);
const char *str2 = "A toy";
strncpy(things[*size-1].name, str2, strlen(str2) + 1);
things[*size-1].weight = 350;
// Segmentation fault is there
for(size_t i = 0;i < *size;i++){
printf("Thing: %s, weight: %zu\n",things[i].name,things[i].weight);
}
}
void some_function(Things *things,size_t *size)
{
// Pass array of structures to another function
another_function(things,size);
}
int main(void)
{
// Create NULL pointer for array of structures
Things *things = NULL;
// And size of structures array which will be allocated within add_new_thing() function
size_t size = 0;
// Call some function
some_function(things,&size);
// Segmentation fault is there
printf("Print results:\n");
for(size_t i = 0;i < size;i++){
printf("Thing: %s, weight: %zu\n",things[i].name,things[i].weight);
}
free(things);
return(EXIT_SUCCESS);
}
| 0debug |
How do I disable the Show Tab Bar menu option in Sierra apps? : <p>I've got an app that uses a Toolbar in a NSWindow. I don't want users to be able to customize this toolbar for aesthetic reasons. In Sierra there's a new Menu option that gets inserted into "Menu > View" called <code>Show Tab Bar</code>. How do I disable this? Enabling it only seems to increase the tool bar's height as I don't have extra labels showing under the icons.</p>
| 0debug |
static int coroutine_fn do_perform_cow(BlockDriverState *bs,
uint64_t src_cluster_offset,
uint64_t cluster_offset,
int offset_in_cluster,
int bytes)
{
BDRVQcow2State *s = bs->opaque;
QEMUIOVector qiov;
struct iovec iov;
int ret;
iov.iov_len = bytes;
iov.iov_base = qemu_try_blockalign(bs, iov.iov_len);
if (iov.iov_base == NULL) {
return -ENOMEM;
}
qemu_iovec_init_external(&qiov, &iov, 1);
BLKDBG_EVENT(bs->file, BLKDBG_COW_READ);
if (!bs->drv) {
ret = -ENOMEDIUM;
goto out;
}
ret = bs->drv->bdrv_co_preadv(bs, src_cluster_offset + offset_in_cluster,
bytes, &qiov, 0);
if (ret < 0) {
goto out;
}
if (bs->encrypted) {
Error *err = NULL;
int64_t sector = (cluster_offset + offset_in_cluster)
>> BDRV_SECTOR_BITS;
assert(s->cipher);
assert((offset_in_cluster & ~BDRV_SECTOR_MASK) == 0);
assert((bytes & ~BDRV_SECTOR_MASK) == 0);
if (qcow2_encrypt_sectors(s, sector, iov.iov_base, iov.iov_base,
bytes >> BDRV_SECTOR_BITS, true, &err) < 0) {
ret = -EIO;
error_free(err);
goto out;
}
}
ret = qcow2_pre_write_overlap_check(bs, 0,
cluster_offset + offset_in_cluster, bytes);
if (ret < 0) {
goto out;
}
BLKDBG_EVENT(bs->file, BLKDBG_COW_WRITE);
ret = bdrv_co_pwritev(bs->file->bs, cluster_offset + offset_in_cluster,
bytes, &qiov, 0);
if (ret < 0) {
goto out;
}
ret = 0;
out:
qemu_vfree(iov.iov_base);
return ret;
}
| 1threat |
def tuple_to_dict(test_tup):
res = dict(test_tup[idx : idx + 2] for idx in range(0, len(test_tup), 2))
return (res) | 0debug |
JQuery, Javascript, HTML Checkbox Price Quote : Ok, I have been trying to figure this out for about a day now. What I am trying to do is to create a form. The first question and the only question that they will see is a drop down that allows them to pick a state. Once they picked a state, pending on their selection, it will pick a check list according to their selection. Check list will have roughly 20 selections, but for now, it just six. The user can then go through the check list and check the items they wanted. Once an item been checked, another div will appear below it prompting the user to put in how many years they want to purchase this item for and the quantity. Which is the part that I got to so far.
But Now, here is where I am stuck at and what I am trying to do... I did add hidden input values of service fee, license fee, and training hours. Once the user checks on an item... I want to use jquery to calculate the service fee times years to get the total_service. then add total_service plus the license fee to get the item_cost. Then the item_cost times the quantity which I will then get the total_item_cost.
I then want to get and display, show, or list out the item description, service fee, years, license fee, quantity and training hours into a line, div, or table, kinda of like a shopping cart. And each time an item is checked, it will show each item below.
Finally, at the bottom of list, I want to have the total cost of the items and total training times.
Right now I am having issues with the dropdown of years, it seems to reset itself. And issues with the calculations.
As far as the form, once I submit the form it will go to people emails and etc. just trying to get the jquery code to work first.
Any advice is great. Code is below...
<style>
.box {
display: none;
}
</style>
<form name="" id="myForm" method="post" class="" action="http://demo.camavision.com/VCSWeb/remarks-look-up/" >
<div class="tx-row" style="width:100%; float:left; clear:right;">
<div style="float:left; margin-top:-20px; ">
<label>
<strong style="font-size:14px;">State:</strong> <span style="font-size:10px; color:#ff0000;">(required)</span><br />
<select style= "width:90%; height:35px; font-size:18px; border: 1px #396ba5 solid;" id="state" name="state" required>
<option value="" selected="selected" >Select State</option>
<option value="IlIaNd" >Iowa</option>
<option value="IlIaNd" >Illinois</option>
<option value="Minnesota" >Minnesota</option>
<option value="Missouri" >Missouri</option>
<option value="Nebraska" >Nebraska</option>
<option value="IlIaNd" >North Dakota</option>
<option value="SouthDakota" >South Dakota</option>
</select>
</label>
</div>
</div>
<script>
$(document).ready(function(){
$("select").change(function(){
$(this).find("option:selected").each(function(){
if($(this).attr("value")=="IlIaNd"){
$(".box").not(".IlIaNd").hide();
$(".IlIaNd").show();
}else if($(this).attr("value")=="Minnesota"){
$(".box").not(".Minnesota").hide();
$(".Minnesota").show();
}else if($(this).attr("value")=="Missouri"){
$(".box").not(".Missouri").hide();
$(".Missouri").show();
}else if($(this).attr("value")=="Nebraska"){
$(".box").not(".Nebraska").hide();
$(".Nebraska").show();
}else if($(this).attr("value")=="SouthDakota"){
$(".box").not(".SouthDakota").hide();
$(".SouthDakota").show();
}else{
$(".box").hide();
}
});
}).change();
});
</script>
<div style="width: 100%; float:left; clear:both; height:25px;" > </div>
<div style="border-bottom: 1px solid #cccccc; width: 100%; float:left; clear:both;" > </div>
<div style="width: 100%; float:left; clear:both; height:25px;" > </div>
<div style="width: 100%; float:left; clear:both;" class="IlIaNd box">
<div class="tx-column tx-column-size-1-3" >
<input type="checkbox" name="description" id="chk10" value="Advanced Scheduler" > Advanced Scheduler
<div id="sb10" style="width:100%;">
<div style='width:50%; float:left;'>
Years: <select name='Years'>
<option value=\"1\">1</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
<option value=\"5\">5</option>
</select>
</div>
<div style='width:50%; float:left;'>
Quantity: <select name='Qty'>
<option value=\"1\">1</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
<option value=\"5\">5</option>
</select>
</div>
<input type='hidden' name='servicefee' value="1000">
<input type='hidden' name='licensefee' value="1500">
<input type='hidden' name='traininghrs' value="8" >
</div>
<input type="checkbox" name="description" id="chk11" value="Advanced Printer" > Advanced Printer
<div id="sb11" style="width:100%;">
<div style='width:50%; float:left;'>
Years: <select name='Years'>
<option value=\"1\">1</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
<option value=\"5\">5</option>
</select>
</div>
<div style='width:50%; float:left;'>
Quantity: <select name='Qty'>
<option value=\"1\">1</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
<option value=\"5\">5</option>
</select>
</div>
<input type='hidden' name='servicefee' value="1000">
<input type='hidden' name='licensefee' value="">
<input type='hidden' name='traininghrs' value="10" >
</div>
</div>
<div class="tx-column tx-column-size-1-3" >
<input type="checkbox" name="description" id="chk12" value="Advanced Reader" > Advanced Reader
<div id="sb12" style="width:100%;">
<div style='width:50%; float:left;'>
Years: <select name='Years'>
<option value=\"1\">1</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
<option value=\"5\">5</option>
</select>
</div>
<div style='width:50%; float:left;'>
Quantity: <select name='Qty'>
<option value=\"1\">1</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
<option value=\"5\">5</option>
</select>
</div>
<input type='hidden' name='servicefee' value="1200">
<input type='hidden' name='licensefee' value="2000">
<input type='hidden' name='traininghrs' value="8" >
</div>
<input type="checkbox" name="description" id="chk13" value="Advanced Organizer" > Advanced Organizer
<div id="sb13" style="width:100%;">
<div style='width:50%; float:left;'>
Years: <select name='Years'>
<option value=\"1\">1</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
<option value=\"5\">5</option>
</select>
</div>
<div style='width:50%; float:left;'>
Quantity: <select name='Qty'>
<option value=\"1\">1</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
<option value=\"5\">5</option>
</select>
</div>
<input type='hidden' name='servicefee' value=" ">
<input type='hidden' name='licensefee' value="3000">
<input type='hidden' name='traininghrs' value="10" >
</div>
</div>
<div class="tx-column tx-column-size-1-3" >
<input type="checkbox" name="description" id="chk14" value="Advanced TaskMaster" > Advanced TaskMaster
<div id="sb14" style="width:100%;">
<div style='width:50%; float:left;'>
Years: <select name='Years'>
<option value=\"1\">1</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
<option value=\"5\">5</option>
</select>
</div>
<div style='width:50%; float:left;'>
Quantity: <select name='Qty'>
<option value=\"1\">1</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
<option value=\"5\">5</option>
</select>
</div>
<input type='hidden' name='servicefee' value="1000">
<input type='hidden' name='licensefee' value="2000">
<input type='hidden' name='traininghrs' value="10" >
</div>
<input type="checkbox" name="description" id="chk15" value="Advanced Viewer" > Advanced Viewer
<div id="sb15" style="width:100%;">
<div style='width:50%; float:left;'>
Years: <select name='Years'>
<option value=\"1\">1</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
<option value=\"5\">5</option>
</select>
</div>
<div style='width:50%; float:left;'>
Quantity: <select name='Qty'>
<option value=\"1\">1</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
<option value=\"5\">5</option>
</select>
</div>
<input type='hidden' name='servicefee' value="1200">
<input type='hidden' name='licensefee' value="1000">
<input type='hidden' name='traininghrs' value="0" >
</div>
</div>
</div>
<div style="width: 100%; float:left; clear:both;" class="Minnesota box" >
<p>Minnesota test 2</p>
</div>
<div style="width: 100%; float:left; clear:both;" class="Missouri box">
<p>Missouri test 3</p>
</div>
<div style="width: 100%; float:left; clear:both;" class="Nebraska box" >
<p>Nebraska test 4</p>
</div>
<div style="width: 100%; float:left; clear:both;" class="SouthDakota box">
<p>SouthDakota test 5</p>
</div>
<div id="total_fees"></div>
<script>
$(document).ready(function()
{
//hide all contents
$('div[id^=sb]').hide();
$('input[id^=chk]').change(function(){
// get checkbox index
var index = $(this).attr('id').replace('chk','');
//show respective contents
if($(this).is(':checked'))
$('#sb'+index).show();
else
$('#sb'+index).hide();
});
});
$(document).ready(function() {
$(".calculate-fees").click(function() {
var descr = $('input[name="description"]').val();
var service = $('input[name="servicefee"]').val();
var years = $('input[name="Years"]').val();
var license = $('input[name="licensefee"]').val();
var qty = $('input[name="Qty"]').val();
if (qty == " "){
var qty = "1";
}
var training = $('input[name="traininghrs"]').val();
var servicefee = service * years;
var fees = servicefee + license;
var total_fees = fees * quantity;
$("#total_fees").html(descr + "Sevice Fees: " + service + "Years: " + years + "License Fee: " +license + "Quantity: " + qty + "Training Hours: " + training + "Item Cost: " + total_fees );
});
});
</script>
</form> | 0debug |
void nbd_client_session_close(NbdClientSession *client)
{
if (!client->bs) {
return;
}
nbd_teardown_connection(client);
client->bs = NULL;
}
| 1threat |
PHP single & double quotes in CLI argument : I've write a simple php script file that must execute in CLI and it needs 2 arguments.
/usr/local/bin/php myscipt.php arg1 arg2
it works well, but IF I put something like
/usr/local/bin/php myscipt.php ar"g1 arg2
or
/usr/local/bin/php myscipt.php ar"g1 ar'g2
it do no treat argument like I want.
please is there any way to solve this.
I've tried all possible functions : strstr, strpos, ... and even loops.
Thanks | 0debug |
document.location = 'http://evil.com?username=' + user_input; | 1threat |
c# dictionary get all keys with same value : I have a Dictionary with Keys and Values. Is it possible to get all Key who has de same Value?
Exemple 1=456894, 2=548962, 3=548962, 4=654876... and den get de Key 2 and 3 because it has the same value.
```Dictionary<int, int> doublechek = new Dictionary<int, int>();``` | 0debug |
How do you check a checkbox in react-testing-library? : <p>I cant seem to find much/any docs on this really simple thing I'm trying to achieve</p>
<p>I have a dropdown that is <code>display: none</code>. when I click a checkbox it becomes <code>display: block</code>
all I'm trying to assert is when I click the checkbox, it shows the dropdown</p>
<pre><code> expect(getByLabelText('Locale')).toHaveStyle(`
display: none;
`)
getByLabelText('Locale').checked = true
expect(getByLabelText('Locale')).toHaveStyle(`
display: block;
`)
</code></pre>
<p>the code works as expected but the test is failing on the second expect block saying: it should still be <code>display: none</code></p>
<p>is the correct way to assert this?</p>
<p>when I click the checkbox it updates 2 attributes in my object to <code>true</code> which is how it renders in the code. when I manually pass these attributes the test still fails but it fails in the first expectation. </p>
<p>I feel like I need to do something like <code>setProps</code></p>
<p>I have now tried to use <code>renderWithRedux</code> but it doesn't seem to be firing my action creator correctly?</p>
<p>is <code>fireEvent.click(queryByTestId('LocaleCheckbox'))</code> the best thing to try and update a checkbox?</p>
| 0debug |
Is JQuery $.post() asynchronous? : <p>Is $.post asynchronous? So if I did the commands like so below would they all be done at once instead of being synchronous (1 done, wait, then the next, etc.) ?</p>
<pre><code>$(document).ready(function() {
var variable1 = '1';
var variable2 = '2';
var variable3 = '3';
var variable4 = '4';
$.post("process.php", {element1: variable1}, function(data){
$("#area1").html(data);
});
$.post("process.php", {element2: variable2}, function(data){
$("#area3").html(data);
});
$.post("process.php", {element3: variable3}, function(data){
$("#area4").html(data);
});
$.post("process.php", {element4: variable4}, function(data){
$("#area4").html(data);
});
});
</code></pre>
| 0debug |
How to disable textbox focusing C# : <p>i have a application where</p>
<p><strong>Scenario :</strong>
when i click on that textbox the cursor should not point the textbox it should be disabled</p>
<p>how do i achieve this disabling the textbox</p>
<pre><code>textbox1.focus()=false;
textbox1.focused()=false;
</code></pre>
| 0debug |
How to increase max_locks_per_transaction : <p>I've been performing kind of intensive schema dropping and creating over a PostgreSQL server,</p>
<blockquote>
<p>ERROR: out of shared memory</p>
<p>HINT: You might need to increase max_locks_per_transaction.</p>
</blockquote>
<p>I need to increase max_locks_per_transaction but how can i increase it in <strong>MAC OSX</strong> </p>
| 0debug |
JS : Remove all strings which starting with specific character : Have an array contains names. Some of them starting with dot[.](symbol), and some of them have dot in middle or elsewhere. Need to remove all names only starting with dot. Seek help for a better way in JavaScript.
<code>
var myarr = 'ad, ghost, hg, .hi, jk, find.jpg, dam.ark, haji, jive.pdf, .find, home, .war, .milk, raj, .ker';
var refinedArr = ??
</code>
| 0debug |
PHP - access values inside an object : I have a requirement to access value inside an object return from an API response in PHP.
API response
$res = {
"data": {
"first_name": "Dany",
"last_name": "mate",
"id": "1379933133290837510",
"image": {
"60x60": {
"url": "https://s-media-cache-ak0.pinimg.com/avatars/dtest_1438666564_60.jpg",
"width": 60,
"height": 60
}
}
}
}
How to access the parameters "first_name" & "url"? Your help is much appreciated. I have tried to convert the response in to an array but not worked
$array = get_object_vars($res);
I don't know is it the correct way to do this? | 0debug |
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt) {
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AVSubtitle *sub = data;
const uint8_t *buf_end = buf + buf_size;
uint8_t *bitmap;
int w, h, x, y, i, ret;
int64_t packet_time = 0;
GetBitContext gb;
int has_alpha = avctx->codec_tag == MKTAG('D','X','S','A');
if (buf_size < 27 + 7 * 2 + 4 * (3 + has_alpha)) {
av_log(avctx, AV_LOG_ERROR, "coded frame size %d too small\n", buf_size);
return -1;
}
if (buf[0] != '[' || buf[13] != '-' || buf[26] != ']') {
av_log(avctx, AV_LOG_ERROR, "invalid time code\n");
return -1;
}
if (avpkt->pts != AV_NOPTS_VALUE)
packet_time = av_rescale_q(avpkt->pts, AV_TIME_BASE_Q, (AVRational){1, 1000});
sub->start_display_time = parse_timecode(buf + 1, packet_time);
sub->end_display_time = parse_timecode(buf + 14, packet_time);
buf += 27;
w = bytestream_get_le16(&buf);
h = bytestream_get_le16(&buf);
if (av_image_check_size(w, h, 0, avctx) < 0)
return -1;
x = bytestream_get_le16(&buf);
y = bytestream_get_le16(&buf);
bytestream_get_le16(&buf);
bytestream_get_le16(&buf);
bytestream_get_le16(&buf);
sub->rects = av_mallocz(sizeof(*sub->rects));
if (!sub->rects)
return AVERROR(ENOMEM);
sub->rects[0] = av_mallocz(sizeof(*sub->rects[0]));
if (!sub->rects[0]) {
av_freep(&sub->rects);
return AVERROR(ENOMEM);
}
sub->rects[0]->x = x; sub->rects[0]->y = y;
sub->rects[0]->w = w; sub->rects[0]->h = h;
sub->rects[0]->type = SUBTITLE_BITMAP;
sub->rects[0]->linesize[0] = w;
sub->rects[0]->data[0] = av_malloc(w * h);
sub->rects[0]->nb_colors = 4;
sub->rects[0]->data[1] = av_mallocz(AVPALETTE_SIZE);
if (!sub->rects[0]->data[0] || !sub->rects[0]->data[1]) {
av_freep(&sub->rects[0]->data[1]);
av_freep(&sub->rects[0]->data[0]);
av_freep(&sub->rects[0]);
av_freep(&sub->rects);
return AVERROR(ENOMEM);
}
sub->num_rects = 1;
for (i = 0; i < sub->rects[0]->nb_colors; i++)
((uint32_t*)sub->rects[0]->data[1])[i] = bytestream_get_be24(&buf);
if (!has_alpha) {
for (i = 1; i < sub->rects[0]->nb_colors; i++)
((uint32_t *)sub->rects[0]->data[1])[i] |= 0xff000000;
} else {
for (i = 0; i < sub->rects[0]->nb_colors; i++)
((uint32_t *)sub->rects[0]->data[1])[i] |= *buf++ << 24;
}
#if FF_API_AVPICTURE
FF_DISABLE_DEPRECATION_WARNINGS
{
AVSubtitleRect *rect;
int j;
rect = sub->rects[0];
for (j = 0; j < 4; j++) {
rect->pict.data[j] = rect->data[j];
rect->pict.linesize[j] = rect->linesize[j];
}
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if ((ret = init_get_bits8(&gb, buf, buf_end - buf)) < 0)
return ret;
bitmap = sub->rects[0]->data[0];
for (y = 0; y < h; y++) {
if (y == (h + 1) / 2) bitmap = sub->rects[0]->data[0] + w;
for (x = 0; x < w; ) {
int log2 = ff_log2_tab[show_bits(&gb, 8)];
int run = get_bits(&gb, 14 - 4 * (log2 >> 1));
int color = get_bits(&gb, 2);
run = FFMIN(run, w - x);
if (!run) run = w - x;
memset(bitmap, color, run);
bitmap += run;
x += run;
}
bitmap += w;
align_get_bits(&gb);
}
*data_size = 1;
return buf_size;
} | 1threat |
Java getting global date not the system date even if offline : <p>I'm creating custom a licence module for my java application
Every licence have start date and end date, And I validate if the end date is >= the current date
I want to avoid that the client may change his system date by getting a global date even if the client machine have no internet connection</p>
<p>I've tried Joda API, nanoTime with no lick</p>
<p>Is that doable ?</p>
<p>Thanks,</p>
| 0debug |
static inline void gen_op_fcmpd(int fccno, TCGv_i64 r_rs1, TCGv_i64 r_rs2)
{
gen_helper_fcmpd(cpu_env, r_rs1, r_rs2);
}
| 1threat |
static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status)
{
VirtIOBlock *s = VIRTIO_BLK(vdev);
uint32_t features;
if (s->dataplane && !(status & (VIRTIO_CONFIG_S_DRIVER |
VIRTIO_CONFIG_S_DRIVER_OK))) {
virtio_blk_data_plane_stop(s->dataplane);
}
if (!(status & VIRTIO_CONFIG_S_DRIVER_OK)) {
return;
}
features = vdev->guest_features;
if (!(features & (1 << VIRTIO_BLK_F_CONFIG_WCE))) {
aio_context_acquire(bdrv_get_aio_context(s->bs));
bdrv_set_enable_write_cache(s->bs,
!!(features & (1 << VIRTIO_BLK_F_WCE)));
aio_context_release(bdrv_get_aio_context(s->bs));
}
}
| 1threat |
static int add_string_metadata(int count, const char *name,
TiffContext *s)
{
char *value;
if (bytestream2_get_bytes_left(&s->gb) < count || count < 0)
return AVERROR_INVALIDDATA;
value = av_malloc(count + 1);
if (!value)
return AVERROR(ENOMEM);
bytestream2_get_bufferu(&s->gb, value, count);
value[count] = 0;
av_dict_set(avpriv_frame_get_metadatap(&s->picture), name, value, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
| 1threat |
Translate ECMAScript 6's arrow function to a regular function : <p>Im trying to convert the script below to a normal function, but fail to understand how. </p>
<p>The script counts the numbers of instances (model) in a Array (productList.Lockers) and appends it to a target div. </p>
<pre><code>productList.Lockers.forEach(o => $('#' + o.model).siblings('#modelcount').text((i, t) => ( parseInt(t, 10) || 0) + 1 ));
var modelCount = document.getElementById('allcount');
modelCount.innerHTML = productList.Lockers.length;
</code></pre>
| 0debug |
SQL QUERY WITH HAVING CLAUSE SELECTING FROM MULTIPLE TABLES : [this is the tried syntax[\]\[1\]][1]
select cc, sum(a.hours),b.labcost from labour a,othshop b where lab_cd='hs' and a.mon=03 and a.yr=2010 group by a.cc HAVING a.cc=b.occ AND b.mon=03 and b.yr=2010;
I HAVE ALL THE TABLES WELL DEFINED STILL MY SQL SYNTAX IS NOT WORKING. IF ANY GUY CAN SOLVE THIS I WILL BE HIGHLY BENIFITED.
[1]: https://i.stack.imgur.com/uTcx6.jpg | 0debug |
Capitalizing last letter in Java using String methods : <p>how can i capitalize the last letter of a String? Is there a method in the String Class to do this?</p>
<p>I'm practicing with some exercise, and i was asked to do this with a method.</p>
| 0debug |
How to get the beginning and end of the day with moment? : <p>I would like to get the beginning and end of the current day (and accessorily of tomorrow by <code>.add(1, 'day')</code>) using <code>moment</code>.</p>
<p>What I am getting now is </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>now = moment()
console.log('now ' + now.toISOString())
console.log('start ' + now.startOf('day').toISOString())
console.log('end ' + now.endOf('day').toISOString())</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment.js"></script></code></pre>
</div>
</div>
</p>
<p>This outputs right now </p>
<pre><code>now 2018-04-18T21:20:02.010Z
start 2018-04-17T23:00:00.000Z
end 2018-04-18T22:59:59.999Z
</code></pre>
<p>Since the times are shifted by an hour, I believe that this is something related to timezones, though I fail to understand how this can be relevant: no matter the time zone, the day in that timezone begins right after midnight today and ends right before midnight today.</p>
| 0debug |
How to store a symmetric key safely ? Can I use pkcs12 to store symmetric key? : <p>How to store a symmetric key safely? Can I use pkcs12 to store this symmetric key?</p>
| 0debug |
a simple while loop does not read all matches. Reads only the first match and ignores the others : The problem is the code skips the first echo statement no matter what.
$query = mysql_query("SELECT index_no, lesson FROM c8_lessons_list WHERE index_no ='456'");
($row = mysql_fetch_array($query));
if ($row['index_no'] !== '456' && $row['lesson'] !== "Fertilisation process" )
{
echo '<a href="file:///D|/CC-Gate/localhost">Fertilisation process</a>';
}
else
{
echo 'Fertilisation process Completed';
}
| 0debug |
static av_always_inline void idct_mb(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb)
{
int x, y, ch;
if (mb->mode != MODE_I4x4) {
uint8_t *y_dst = dst[0];
for (y = 0; y < 4; y++) {
uint32_t nnz4 = AV_RL32(s->non_zero_count_cache[y]);
if (nnz4) {
if (nnz4&~0x01010101) {
for (x = 0; x < 4; x++) {
if ((uint8_t)nnz4 == 1)
s->vp8dsp.vp8_idct_dc_add(y_dst+4*x, s->block[y][x], s->linesize);
else if((uint8_t)nnz4 > 1)
s->vp8dsp.vp8_idct_add(y_dst+4*x, s->block[y][x], s->linesize);
nnz4 >>= 8;
if (!nnz4)
break;
}
} else {
s->vp8dsp.vp8_idct_dc_add4y(y_dst, s->block[y], s->linesize);
}
}
y_dst += 4*s->linesize;
}
}
for (ch = 0; ch < 2; ch++) {
uint32_t nnz4 = AV_RL32(s->non_zero_count_cache[4+ch]);
if (nnz4) {
uint8_t *ch_dst = dst[1+ch];
if (nnz4&~0x01010101) {
for (y = 0; y < 2; y++) {
for (x = 0; x < 2; x++) {
if ((uint8_t)nnz4 == 1)
s->vp8dsp.vp8_idct_dc_add(ch_dst+4*x, s->block[4+ch][(y<<1)+x], s->uvlinesize);
else if((uint8_t)nnz4 > 1)
s->vp8dsp.vp8_idct_add(ch_dst+4*x, s->block[4+ch][(y<<1)+x], s->uvlinesize);
nnz4 >>= 8;
if (!nnz4)
break;
}
ch_dst += 4*s->uvlinesize;
}
} else {
s->vp8dsp.vp8_idct_dc_add4uv(ch_dst, s->block[4+ch], s->uvlinesize);
}
}
}
}
| 1threat |
Why is 'this' undefined inside class method when using promises? : <p>I have a javascript class, and each method returns a <code>Q</code> promise. I want to know why <code>this</code> is undefined in <code>method2</code> and <code>method3</code>. Is there a more correct way to write this code?</p>
<pre><code>function MyClass(opts){
this.options = opts;
return this.method1()
.then(this.method2)
.then(this.method3);
}
MyClass.prototype.method1 = function(){
// ...q stuff...
console.log(this.options); // logs "opts" object
return deferred.promise;
};
MyClass.prototype.method2 = function(method1resolve){
// ...q stuff...
console.log(this); // logs undefined
return deferred.promise;
};
MyClass.prototype.method3 = function(method2resolve){
// ...q stuff...
console.log(this); // logs undefined
return deferred.promise;
};
</code></pre>
<p>I can fix this by using <code>bind</code>:</p>
<pre><code>function MyClass(opts){
this.options = opts;
return this.method1()
.then(this.method2.bind(this))
.then(this.method3.bind(this));
}
</code></pre>
<p>But not entirely sure why <code>bind</code> is necessary; is <code>.then()</code> killing <code>this</code> off?</p>
| 0debug |
BlockInfoList *qmp_query_block(Error **errp)
{
BlockInfoList *head = NULL, **p_next = &head;
BlockBackend *blk;
Error *local_err = NULL;
for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
BlockInfoList *info = g_malloc0(sizeof(*info));
bdrv_query_info(blk, &info->value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
g_free(info);
qapi_free_BlockInfoList(head);
return NULL;
}
*p_next = info;
p_next = &info->next;
}
return head;
}
| 1threat |
pass test case parameters using nunit console : <p>I am developing tests using <strong>Nunit</strong> and <strong>data driven testing</strong> approach. I have test method with 2 parameters: path to xlsx file and worksheet name.
It works perfect in Visual Studio when I pass parameters in <code>TestCase</code> attribute, for example when I want to run 3 test cases have to write something like this:</p>
<pre><code>[TestCase(@"pathToFile.xlsx", "TestCase1")]
[TestCase(@"pathToFile.xlsx", "TestCase2")]
[TestCase(@"pathToFile.xlsx", "TestCase3")]
public void performActionsByWorksheet(string excelFilePath, string worksheetName)
{
//test code
}
</code></pre>
<p>I would like to run my test cases and pass parameters using <strong>Nunit Console</strong> (not to write parameters in code). </p>
<p>Is it possible to achieve it?</p>
| 0debug |
static MegasasCmd *megasas_lookup_frame(MegasasState *s,
target_phys_addr_t frame)
{
MegasasCmd *cmd = NULL;
int num = 0, index;
index = s->reply_queue_head;
while (num < s->fw_cmds) {
if (s->frames[index].pa && s->frames[index].pa == frame) {
cmd = &s->frames[index];
break;
}
index = megasas_next_index(s, index, s->fw_cmds);
num++;
}
return cmd;
}
| 1threat |
angular-cli build prod "Runtime compiler is not loaded” : <p>I did ng build -prod and met a weird error that is
_zone_symbol__error
:</p>
<pre><code>Error: Uncaught (in promise): Error: Runtime compiler is not loaded Error: Runtime compiler is not loaded at d (http://localhost:4200/polyfills.cd321326a3dfc08ceb46.bund
</code></pre>
<p>I am not using the compiler manually in my app. And the weirdest is that the error seems to come from the polyfills.
How can i solve this?</p>
| 0debug |
void pxa27x_register_keypad(struct pxa2xx_keypad_s *kp, struct keymap *map,
int size)
{
kp->map = (struct keymap *) qemu_mallocz(sizeof(struct keymap) * size);
if(!map || size < 0x80) {
fprintf(stderr, "%s - No PXA keypad map defined\n", __FUNCTION__);
exit(-1);
}
kp->map = map;
qemu_add_kbd_event_handler((QEMUPutKBDEvent *) pxa27x_keyboard_event, kp);
}
| 1threat |
static int parse_object_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
PGSSubContext *ctx = avctx->priv_data;
PGSSubObject *object;
uint8_t sequence_desc;
unsigned int rle_bitmap_len, width, height;
int id;
if (buf_size <= 4)
buf_size -= 4;
id = bytestream_get_be16(&buf);
object = find_object(id, &ctx->objects);
if (!object) {
if (ctx->objects.count >= MAX_EPOCH_OBJECTS) {
av_log(avctx, AV_LOG_ERROR, "Too many objects in epoch\n");
object = &ctx->objects.object[ctx->objects.count++];
object->id = id;
buf += 1;
sequence_desc = bytestream_get_byte(&buf);
if (!(sequence_desc & 0x80)) {
if (buf_size > object->rle_remaining_len)
memcpy(object->rle + object->rle_data_len, buf, buf_size);
object->rle_data_len += buf_size;
object->rle_remaining_len -= buf_size;
return 0;
if (buf_size <= 7)
buf_size -= 7;
rle_bitmap_len = bytestream_get_be24(&buf) - 2*2;
width = bytestream_get_be16(&buf);
height = bytestream_get_be16(&buf);
if (avctx->width < width || avctx->height < height) {
av_log(avctx, AV_LOG_ERROR, "Bitmap dimensions larger than video.\n");
object->w = width;
object->h = height;
av_fast_malloc(&object->rle, &object->rle_buffer_size, rle_bitmap_len);
if (!object->rle)
return AVERROR(ENOMEM);
memcpy(object->rle, buf, buf_size);
object->rle_data_len = buf_size;
object->rle_remaining_len = rle_bitmap_len - buf_size;
return 0; | 1threat |
CPUState *cpu_mb_init (const char *cpu_model)
{
CPUState *env;
static int tcg_initialized = 0;
int i;
env = qemu_mallocz(sizeof(CPUState));
cpu_exec_init(env);
cpu_reset(env);
env->pvr.regs[0] = PVR0_PVR_FULL_MASK \
| PVR0_USE_BARREL_MASK \
| PVR0_USE_DIV_MASK \
| PVR0_USE_HW_MUL_MASK \
| PVR0_USE_EXC_MASK \
| PVR0_USE_ICACHE_MASK \
| PVR0_USE_DCACHE_MASK \
| PVR0_USE_MMU \
| (0xb << 8);
env->pvr.regs[2] = PVR2_D_OPB_MASK \
| PVR2_D_LMB_MASK \
| PVR2_I_OPB_MASK \
| PVR2_I_LMB_MASK \
| PVR2_USE_MSR_INSTR \
| PVR2_USE_PCMP_INSTR \
| PVR2_USE_BARREL_MASK \
| PVR2_USE_DIV_MASK \
| PVR2_USE_HW_MUL_MASK \
| PVR2_USE_MUL64_MASK \
| 0;
env->pvr.regs[10] = 0x0c000000;
env->pvr.regs[11] = PVR11_USE_MMU | (16 << 17);
#if !defined(CONFIG_USER_ONLY)
env->mmu.c_mmu = 3;
env->mmu.c_mmu_tlb_access = 3;
env->mmu.c_mmu_zones = 16;
#endif
if (tcg_initialized)
return env;
tcg_initialized = 1;
cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
env_debug = tcg_global_mem_new(TCG_AREG0,
offsetof(CPUState, debug),
"debug0");
env_iflags = tcg_global_mem_new(TCG_AREG0,
offsetof(CPUState, iflags),
"iflags");
env_imm = tcg_global_mem_new(TCG_AREG0,
offsetof(CPUState, imm),
"imm");
env_btarget = tcg_global_mem_new(TCG_AREG0,
offsetof(CPUState, btarget),
"btarget");
env_btaken = tcg_global_mem_new(TCG_AREG0,
offsetof(CPUState, btaken),
"btaken");
for (i = 0; i < ARRAY_SIZE(cpu_R); i++) {
cpu_R[i] = tcg_global_mem_new(TCG_AREG0,
offsetof(CPUState, regs[i]),
regnames[i]);
}
for (i = 0; i < ARRAY_SIZE(cpu_SR); i++) {
cpu_SR[i] = tcg_global_mem_new(TCG_AREG0,
offsetof(CPUState, sregs[i]),
special_regnames[i]);
}
#define GEN_HELPER 2
#include "helper.h"
return env;
}
| 1threat |
void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size)
{
while (size > 0) {
int len = FFMIN(f->end - f->wptr, size);
memcpy(f->wptr, buf, len);
f->wptr += len;
if (f->wptr >= f->end)
f->wptr = f->buffer;
buf += len;
size -= len;
}
}
| 1threat |
get method in Ruby how it works? : I need someone help me about Ruby on Rail:
I has been saw this function about:
get '/:key' do |key|
.and I want to know what it's use to. Thanks everyone | 0debug |
void pc_cpus_init(PCMachineState *pcms)
{
int i;
CPUClass *cc;
ObjectClass *oc;
const char *typename;
gchar **model_pieces;
X86CPU *cpu = NULL;
MachineState *machine = MACHINE(pcms);
if (machine->cpu_model == NULL) {
#ifdef TARGET_X86_64
machine->cpu_model = "qemu64";
#else
machine->cpu_model = "qemu32";
#endif
}
model_pieces = g_strsplit(machine->cpu_model, ",", 2);
if (!model_pieces[0]) {
error_report("Invalid/empty CPU model name");
exit(1);
}
oc = cpu_class_by_name(TYPE_X86_CPU, model_pieces[0]);
if (oc == NULL) {
error_report("Unable to find CPU definition: %s", model_pieces[0]);
exit(1);
}
typename = object_class_get_name(oc);
cc = CPU_CLASS(oc);
cc->parse_features(typename, model_pieces[1], &error_fatal);
g_strfreev(model_pieces);
pcms->apic_id_limit = x86_cpu_apic_id_from_index(max_cpus - 1) + 1;
if (pcms->apic_id_limit > ACPI_CPU_HOTPLUG_ID_LIMIT) {
error_report("max_cpus is too large. APIC ID of last CPU is %u",
pcms->apic_id_limit - 1);
exit(1);
}
pcms->possible_cpus = g_malloc0(sizeof(CPUArchIdList) +
sizeof(CPUArchId) * max_cpus);
for (i = 0; i < max_cpus; i++) {
pcms->possible_cpus->cpus[i].arch_id = x86_cpu_apic_id_from_index(i);
pcms->possible_cpus->len++;
if (i < smp_cpus) {
cpu = pc_new_cpu(typename, x86_cpu_apic_id_from_index(i),
&error_fatal);
object_unref(OBJECT(cpu));
}
}
smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]);
}
| 1threat |
static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret)
{
IDEState *s = opaque;
int data_offset, n;
if (ret < 0) {
ide_atapi_io_error(s, ret);
goto eot;
}
if (s->io_buffer_size > 0) {
if (s->lba != -1) {
if (s->cd_sector_size == 2352) {
n = 1;
cd_data_to_raw(s->io_buffer, s->lba);
} else {
n = s->io_buffer_size >> 11;
}
s->lba += n;
}
s->packet_transfer_size -= s->io_buffer_size;
if (s->bus->dma->ops->rw_buf(s->bus->dma, 1) == 0)
goto eot;
}
if (s->packet_transfer_size <= 0) {
s->status = READY_STAT | SEEK_STAT;
s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD;
ide_set_irq(s->bus);
goto eot;
}
s->io_buffer_index = 0;
if (s->cd_sector_size == 2352) {
n = 1;
s->io_buffer_size = s->cd_sector_size;
data_offset = 16;
} else {
n = s->packet_transfer_size >> 11;
if (n > (IDE_DMA_BUF_SECTORS / 4))
n = (IDE_DMA_BUF_SECTORS / 4);
s->io_buffer_size = n * 2048;
data_offset = 0;
}
#ifdef DEBUG_AIO
printf("aio_read_cd: lba=%u n=%d\n", s->lba, n);
#endif
s->bus->dma->iov.iov_base = (void *)(s->io_buffer + data_offset);
s->bus->dma->iov.iov_len = n * 4 * 512;
qemu_iovec_init_external(&s->bus->dma->qiov, &s->bus->dma->iov, 1);
s->bus->dma->aiocb = bdrv_aio_readv(s->bs, (int64_t)s->lba << 2,
&s->bus->dma->qiov, n * 4,
ide_atapi_cmd_read_dma_cb, s);
return;
eot:
block_acct_done(bdrv_get_stats(s->bs), &s->acct);
ide_set_inactive(s, false);
}
| 1threat |
calendar app take value date(January 1st, 1970) as default in frontend if device language is english[Hongkong SAR china] : calendar app take value date(January 1st, 1970) as default in frontend if device language is english[Hongkong SAR china] in my website based on magento framework.Is there any solution to get current time? and the problem is only in Internet Explorer.
| 0debug |
static int local_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *stbuf)
{
int err;
char *buffer;
char *path = fs_path->data;
buffer = rpath(fs_ctx, path);
err = lstat(buffer, stbuf);
if (err) {
goto err_out;
}
if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
uid_t tmp_uid;
gid_t tmp_gid;
mode_t tmp_mode;
dev_t tmp_dev;
if (getxattr(buffer, "user.virtfs.uid", &tmp_uid, sizeof(uid_t)) > 0) {
stbuf->st_uid = le32_to_cpu(tmp_uid);
}
if (getxattr(buffer, "user.virtfs.gid", &tmp_gid, sizeof(gid_t)) > 0) {
stbuf->st_gid = le32_to_cpu(tmp_gid);
}
if (getxattr(buffer, "user.virtfs.mode",
&tmp_mode, sizeof(mode_t)) > 0) {
stbuf->st_mode = le32_to_cpu(tmp_mode);
}
if (getxattr(buffer, "user.virtfs.rdev", &tmp_dev, sizeof(dev_t)) > 0) {
stbuf->st_rdev = le64_to_cpu(tmp_dev);
}
} else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {
local_mapped_file_attr(fs_ctx, path, stbuf);
}
err_out:
g_free(buffer);
return err;
}
| 1threat |
Because it curve does not work with histogram? : <p>I have no idea why this simple command does not work?</p>
<pre><code> set.seed(12345)
x<-rnorm(1000,0,10)
hist(x)
curve(dnorm(x,0, 10), add=TRUE, yaxt="n", col="red", log=FALSE)
</code></pre>
| 0debug |
static int proxy_mkdir(FsContext *fs_ctx, V9fsPath *dir_path,
const char *name, FsCred *credp)
{
int retval;
V9fsString fullname;
v9fs_string_init(&fullname);
v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
retval = v9fs_request(fs_ctx->private, T_MKDIR, NULL, "sddd", &fullname,
credp->fc_mode, credp->fc_uid, credp->fc_gid);
v9fs_string_free(&fullname);
if (retval < 0) {
errno = -retval;
retval = -1;
}
v9fs_string_free(&fullname);
return retval;
}
| 1threat |
React ref.current is null : <p>I'm working on an agenda/calendar app with a variable time range. To display a line for the current time and show blocks for appointments that have been made, I need to calculate how many pixels correspond with one minute inside the given time range.</p>
<p>So for example: If the agenda starts at 7 o'clock in the morning and ends at 5 o'clock in the afternoon, the total range is 10 hours. Let's say that the body of the calendar has a height of 1000 pixels. That means that every hour stands for 100 pixels and every minute for 1,66 pixels.</p>
<p>If the current time is 3 o'clock in the afternoon. We are 480 minutes from the start of the agenda. That means that the line to show the current time should be at 796,8 pixels (480 * 1,66) from the top of the calendar body.</p>
<p>No problems with the calculations but with getting the height of the agenda body. I was thinking to use a React Ref to get the height but I'm getting an error: <code>ref.current is null</code></p>
<p>Below some code:</p>
<pre><code>class Calendar extends Component {
calendarBodyRef = React.createRef();
displayCurrentTimeLine = () => {
const bodyHeight = this.calendarBodyRef.current.clientHeight; // current is null
}
render() {
return (
<table>
<thead>{this.displayHeader()}</thead>
<tbody ref={this.calendarBodyRef}>
{this.displayBody()}
{this.displayCurrentTimeLine()}
</tbody>
</table>
);
}
}
</code></pre>
| 0debug |
React-Native, Android, Genymotion: ADB server didn't ACK : <p>I am working with React-Native, Android, and Genymotion on Mac. When I run <code>react-native run-android</code> I get this lines at the end of the launch operation:</p>
<pre><code>...
04:54:40 E/adb: error: could not install *smartsocket* listener: Address already in use
04:54:40 E/adb: ADB server didn't ACK
04:54:40 E/ddms: '/Users/paulbrie/Library/Android/sdk/platform-tools/adb,start-server' failed -- run manually if necessary
04:54:40 E/adb: * failed to start daemon *
04:54:40 E/adb: error: cannot connect to daemon
:app:installDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: Timeout getting device list.
...
</code></pre>
<p>However, <code>adb devices</code> returns this:</p>
<pre><code>List of devices attached
192.168.59.101:5555 device
</code></pre>
<p>So far I've found no solution to run my app on the emulator. Has anyone encountered the same issue?</p>
<p>Thanks,
Paul</p>
| 0debug |
static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink)
{
struct HeadphoneContext *s = ctx->priv;
const int ir_len = s->ir_len;
int nb_irs = s->nb_irs;
int nb_input_channels = ctx->inputs[0]->channels;
float gain_lin = expf((s->gain - 3 * nb_input_channels) / 20 * M_LN10);
FFTComplex *data_hrtf_l = NULL;
FFTComplex *data_hrtf_r = NULL;
FFTComplex *fft_in_l = NULL;
FFTComplex *fft_in_r = NULL;
float *data_ir_l = NULL;
float *data_ir_r = NULL;
int offset = 0;
int n_fft;
int i, j;
s->buffer_length = 1 << (32 - ff_clz(s->ir_len));
s->n_fft = n_fft = 1 << (32 - ff_clz(s->ir_len + inlink->sample_rate));
if (s->type == FREQUENCY_DOMAIN) {
fft_in_l = av_calloc(n_fft, sizeof(*fft_in_l));
fft_in_r = av_calloc(n_fft, sizeof(*fft_in_r));
if (!fft_in_l || !fft_in_r) {
return AVERROR(ENOMEM);
}
av_fft_end(s->fft[0]);
av_fft_end(s->fft[1]);
s->fft[0] = av_fft_init(log2(s->n_fft), 0);
s->fft[1] = av_fft_init(log2(s->n_fft), 0);
av_fft_end(s->ifft[0]);
av_fft_end(s->ifft[1]);
s->ifft[0] = av_fft_init(log2(s->n_fft), 1);
s->ifft[1] = av_fft_init(log2(s->n_fft), 1);
if (!s->fft[0] || !s->fft[1] || !s->ifft[0] || !s->ifft[1]) {
av_log(ctx, AV_LOG_ERROR, "Unable to create FFT contexts of size %d.\n", s->n_fft);
return AVERROR(ENOMEM);
}
}
s->data_ir[0] = av_calloc(FFALIGN(s->ir_len, 16), sizeof(float) * s->nb_irs);
s->data_ir[1] = av_calloc(FFALIGN(s->ir_len, 16), sizeof(float) * s->nb_irs);
s->delay[0] = av_malloc_array(s->nb_irs, sizeof(float));
s->delay[1] = av_malloc_array(s->nb_irs, sizeof(float));
if (s->type == TIME_DOMAIN) {
s->ringbuffer[0] = av_calloc(s->buffer_length, sizeof(float) * nb_input_channels);
s->ringbuffer[1] = av_calloc(s->buffer_length, sizeof(float) * nb_input_channels);
} else {
s->ringbuffer[0] = av_calloc(s->buffer_length, sizeof(float));
s->ringbuffer[1] = av_calloc(s->buffer_length, sizeof(float));
s->temp_fft[0] = av_malloc_array(s->n_fft, sizeof(FFTComplex));
s->temp_fft[1] = av_malloc_array(s->n_fft, sizeof(FFTComplex));
if (!s->temp_fft[0] || !s->temp_fft[1])
return AVERROR(ENOMEM);
}
if (!s->data_ir[0] || !s->data_ir[1] ||
!s->ringbuffer[0] || !s->ringbuffer[1])
return AVERROR(ENOMEM);
s->in[0].frame = ff_get_audio_buffer(ctx->inputs[0], s->size);
if (!s->in[0].frame)
return AVERROR(ENOMEM);
for (i = 0; i < s->nb_irs; i++) {
s->in[i + 1].frame = ff_get_audio_buffer(ctx->inputs[i + 1], s->ir_len);
if (!s->in[i + 1].frame)
return AVERROR(ENOMEM);
}
if (s->type == TIME_DOMAIN) {
s->temp_src[0] = av_calloc(FFALIGN(ir_len, 16), sizeof(float));
s->temp_src[1] = av_calloc(FFALIGN(ir_len, 16), sizeof(float));
data_ir_l = av_calloc(nb_irs * FFALIGN(ir_len, 16), sizeof(*data_ir_l));
data_ir_r = av_calloc(nb_irs * FFALIGN(ir_len, 16), sizeof(*data_ir_r));
if (!data_ir_r || !data_ir_l || !s->temp_src[0] || !s->temp_src[1]) {
av_free(data_ir_l);
av_free(data_ir_r);
return AVERROR(ENOMEM);
}
} else {
data_hrtf_l = av_malloc_array(n_fft, sizeof(*data_hrtf_l) * nb_irs);
data_hrtf_r = av_malloc_array(n_fft, sizeof(*data_hrtf_r) * nb_irs);
if (!data_hrtf_r || !data_hrtf_l) {
av_free(data_hrtf_l);
av_free(data_hrtf_r);
return AVERROR(ENOMEM);
}
}
for (i = 0; i < s->nb_irs; i++) {
int len = s->in[i + 1].ir_len;
int delay_l = s->in[i + 1].delay_l;
int delay_r = s->in[i + 1].delay_r;
int idx = -1;
float *ptr;
for (j = 0; j < inlink->channels; j++) {
if (s->mapping[i] < 0) {
continue;
}
if ((av_channel_layout_extract_channel(inlink->channel_layout, j)) == (1LL << s->mapping[i])) {
idx = j;
break;
}
}
if (idx == -1)
continue;
av_audio_fifo_read(s->in[i + 1].fifo, (void **)s->in[i + 1].frame->extended_data, len);
ptr = (float *)s->in[i + 1].frame->extended_data[0];
if (s->type == TIME_DOMAIN) {
offset = idx * FFALIGN(len, 16);
for (j = 0; j < len; j++) {
data_ir_l[offset + j] = ptr[len * 2 - j * 2 - 2] * gain_lin;
data_ir_r[offset + j] = ptr[len * 2 - j * 2 - 1] * gain_lin;
}
} else {
memset(fft_in_l, 0, n_fft * sizeof(*fft_in_l));
memset(fft_in_r, 0, n_fft * sizeof(*fft_in_r));
offset = idx * n_fft;
for (j = 0; j < len; j++) {
fft_in_l[delay_l + j].re = ptr[j * 2 ] * gain_lin;
fft_in_r[delay_r + j].re = ptr[j * 2 + 1] * gain_lin;
}
av_fft_permute(s->fft[0], fft_in_l);
av_fft_calc(s->fft[0], fft_in_l);
memcpy(data_hrtf_l + offset, fft_in_l, n_fft * sizeof(*fft_in_l));
av_fft_permute(s->fft[0], fft_in_r);
av_fft_calc(s->fft[0], fft_in_r);
memcpy(data_hrtf_r + offset, fft_in_r, n_fft * sizeof(*fft_in_r));
}
}
if (s->type == TIME_DOMAIN) {
memcpy(s->data_ir[0], data_ir_l, sizeof(float) * nb_irs * FFALIGN(ir_len, 16));
memcpy(s->data_ir[1], data_ir_r, sizeof(float) * nb_irs * FFALIGN(ir_len, 16));
av_freep(&data_ir_l);
av_freep(&data_ir_r);
} else {
s->data_hrtf[0] = av_malloc_array(n_fft * s->nb_irs, sizeof(FFTComplex));
s->data_hrtf[1] = av_malloc_array(n_fft * s->nb_irs, sizeof(FFTComplex));
if (!s->data_hrtf[0] || !s->data_hrtf[1]) {
av_freep(&data_hrtf_l);
av_freep(&data_hrtf_r);
av_freep(&fft_in_l);
av_freep(&fft_in_r);
return AVERROR(ENOMEM);
}
memcpy(s->data_hrtf[0], data_hrtf_l,
sizeof(FFTComplex) * nb_irs * n_fft);
memcpy(s->data_hrtf[1], data_hrtf_r,
sizeof(FFTComplex) * nb_irs * n_fft);
av_freep(&data_hrtf_l);
av_freep(&data_hrtf_r);
av_freep(&fft_in_l);
av_freep(&fft_in_r);
}
s->have_hrirs = 1;
return 0;
}
| 1threat |
static void watch_mem_write(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
check_watchpoint(addr & ~TARGET_PAGE_MASK, size, BP_MEM_WRITE);
switch (size) {
case 1:
stb_phys(&address_space_memory, addr, val);
break;
case 2:
stw_phys(&address_space_memory, addr, val);
break;
case 4:
stl_phys(&address_space_memory, addr, val);
break;
default: abort();
}
}
| 1threat |
def get_key(dict):
list = []
for key in dict.keys():
list.append(key)
return list | 0debug |
react native link using expo? : <p>How can I use react-native link or How can I link a third party library manually in IOS and Android using exponent.</p>
<p>I was trying to link <code>react-native-image-crop-picker</code> but unable to use in exponent.</p>
| 0debug |
static void m5206_mbar_writeb(void *opaque, target_phys_addr_t offset,
uint32_t value)
{
m5206_mbar_state *s = (m5206_mbar_state *)opaque;
int width;
offset &= 0x3ff;
if (offset >= 0x200) {
hw_error("Bad MBAR write offset 0x%x", (int)offset);
}
width = m5206_mbar_width[offset >> 2];
if (width > 1) {
uint32_t tmp;
tmp = m5206_mbar_readw(opaque, offset & ~1);
if (offset & 1) {
tmp = (tmp & 0xff00) | value;
} else {
tmp = (tmp & 0x00ff) | (value << 8);
}
m5206_mbar_writew(opaque, offset & ~1, tmp);
return;
}
m5206_mbar_write(s, offset, value, 1);
}
| 1threat |
Regex - Removing 18 characters after a word on each line via Sublime Text : Im trying to figure out the regex I can use via Sublime Text to achieve the following for each line in a document:
Before:
<p begin="00:00:06.933" end="00:00:09.761">- Blah blah
After:
<p begin="00:00:06.933">- Blah blah
My thinking is a command that will match
end="
and then a replace to delete it along with the 18 characters in front.
But Im absolutely new to regex and dont know how to do this. cheers.
| 0debug |
connectedRouter Error: Could not find router reducer in state tree, it must be mounted under "router" : <p>I am new to React.js and was setting up base project at that I was getting one issue that my routing got changed but component doesn't load. After googling I found that I need to use ConnectedRouter. While setting up ConnectedRouter, I am getting console error: <b>Could not find router reducer in state tree, it must be mounted under "router"</b></p>
<pre><code>import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter } from 'react-router-dom';
import { ConnectedRouter, connectRouter, routerMiddleware } from "connected-react-router";
import { Provider } from "react-redux";
import { createStore, combineReducers, applyMiddleware, compose } from 'redux';
import createSagaMiddleware from 'redux-saga';
import loginReducer from "./store/reducers/login";
import { watchLogin} from "./store/sagas";
import { history } from '../src/shared/history';
import { push } from 'react-router-redux';
import './index.css';
import App from './App';
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const rootReducer = combineReducers({
login: loginReducer
});
const routersMiddleware = routerMiddleware(history)
const sagaMiddleware = createSagaMiddleware();
const middlewares = [sagaMiddleware, routersMiddleware];
const store = createStore(
connectRouter(history)(rootReducer),
{},
composeEnhancers(applyMiddleware(...middlewares))
);
sagaMiddleware.run(watchLogin);
const app = (
<Provider store={store}>
<ConnectedRouter history={history}>
<App />
</ConnectedRouter>
</Provider>
);
ReactDOM.render(app, document.getElementById('root'));
</code></pre>
| 0debug |
static void omap_tipb_bridge_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
struct omap_tipb_bridge_s *s = (struct omap_tipb_bridge_s *) opaque;
if (size < 2) {
return omap_badwidth_write16(opaque, addr, value);
}
switch (addr) {
case 0x00:
s->control = value & 0xffff;
break;
case 0x04:
s->alloc = value & 0x003f;
break;
case 0x08:
s->buffer = value & 0x0003;
break;
case 0x0c:
s->width_intr = !(value & 2);
s->enh_control = value & 0x000f;
break;
case 0x10:
case 0x14:
case 0x18:
case 0x1c:
OMAP_RO_REG(addr);
break;
default:
OMAP_BAD_REG(addr);
}
}
| 1threat |
how to hide multiple divs id and class using javascript : I want to hide multiple divs id by using javascript .i am trying to have the 5 divs to be hidden on page load but can not seem to get it to work. I can use JS or JQuery. | 0debug |
static void slirp_cleanup(void)
{
WSACleanup();
}
| 1threat |
Create circular image using picasso : <p>I want load the profilr picture image from web url and from the resourses make it circular using Picasso library. I am doing like,</p>
<pre><code>dependencies {
compile 'com.squareup.picasso:picasso:2.4.0'
}
</code></pre>
<p>Load Image (<code>R.drawable.profile_sample</code>) from resources,</p>
<pre><code>Picasso.with(getApplicationContext()).load(R.drawable.profile_sample).placeholder(setCircularImage(R.drawable.profile_sample)).into(imageView_ProfilePic);
</code></pre>
<p>also from the url like,</p>
<pre><code>Picasso.with(getApplicationContext()).load("http://shidhints.com").placeholder(setCircularImage(R.drawable.profile_sample)).into(imageView_ProfilePic);
</code></pre>
<p>Also I am using setCircularImage() to make the image from resources to circular shape.</p>
<pre><code>private RoundedBitmapDrawable setCircularImage(int id) {
Resources res = getApplicationContext().getResources();
Bitmap src = BitmapFactory.decodeResource(res, id);
RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(res, src);
roundedBitmapDrawable.setCornerRadius(Math.max(src.getWidth(), src.getHeight()) / 2.0f);
return roundedBitmapDrawable;
}
</code></pre>
| 0debug |
How to change an image in Xcode when a score changes : I have been creating an Xcode game in swift using sprite kit, however when I try to change the characters image when the high score goes above 40 it doesn't work.
this is the code:
`if highScore >= 40{
player = SKSpriteNode(imageNamed: "start")
}`
Not too sure where I am going wrong but any advice would be much appreciated! I can also add more bits of code or a link to the source code etc should you wish. Have a great day! | 0debug |
Will it work CSS3 transition property in IE9? : <blockquote>
<p>Please check that and let me know your comments</p>
</blockquote>
| 0debug |
I need the application to detect what operating system is being run on? : <p>I was going over forums yesterday as my issue is that i need my application to detect what operating system it is using and depending on the operating system, the app does a different function.</p>
<p>The best information i found was the Path.PathSeperator. Can anyone confirm if it is correct and tell me how to use it to detect which operating system is being used?</p>
<p>Thank You Very Much! :)</p>
| 0debug |
static void gt_ctl_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value)
{
ARMCPU *cpu = arm_env_get_cpu(env);
int timeridx = ri->crm & 1;
uint32_t oldval = env->cp15.c14_timer[timeridx].ctl;
env->cp15.c14_timer[timeridx].ctl = value & 3;
if ((oldval ^ value) & 1) {
gt_recalc_timer(cpu, timeridx);
} else if ((oldval & value) & 2) {
qemu_set_irq(cpu->gt_timer_outputs[timeridx],
(oldval & 4) && (value & 2));
}
}
| 1threat |
void qemu_system_shutdown_request(void)
{
trace_qemu_system_shutdown_request();
replay_shutdown_request();
shutdown_requested = SHUTDOWN_CAUSE_HOST_ERROR;
qemu_notify_event();
}
| 1threat |
why oom? and first gc why Tenured: 8192K->8961K(10240K)? tks : public class TestJVmRiZHI{
/**
jdk 1.8
-XX:+UseSerialGC
-verbose:gc
-Xms20M
-Xmx20m
-Xmn10M
-XX:+PrintGCDetails
-XX:SurvivorRatio=8
* @param args
*/
private static final int _1mb = 1024 * 1024;
public static void main(String[] args) {
Byte[] allocation1 = new Byte[2*_1mb];
Byte[] allocation2 = new Byte[2*_1mb];
Byte[] allocation3 = new Byte[2*_1mb];
Byte[] allocation4 = new Byte[4*_1mb];
}
}
result:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at controller.TestJVmRiZHI.main(TestJVmRiZHI.java:24)
[GC (Allocation Failure) [DefNew: 2540K->770K(9216K), 0.0034872 secs][Tenured: 8192K->8961K(10240K), 0.0071963 secs] 10732K->8961K(19456K), [Metaspace: 3385K->3385K(1056768K)], 0.0107478 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]
[Full GC (Allocation Failure) [Tenured: 8961K->8943K(10240K), 0.0073261 secs] 8961K->8943K(19456K), [Metaspace: 3385K->3385K(1056768K)], 0.0073536 secs] [Times: user=0.02 sys=0.00, real=0.01 secs]
Heap
def new generation total 9216K, used 410K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)
eden space 8192K, 5% used [0x00000000fec00000, 0x00000000fec66800, 0x00000000ff400000)
from space 1024K, 0% used [0x00000000ff500000, 0x00000000ff500000, 0x00000000ff600000)
to space 1024K, 0% used [0x00000000ff400000, 0x00000000ff400000, 0x00000000ff500000)
tenured generation total 10240K, used 8943K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)
the space 10240K, 87% used [0x00000000ff600000, 0x00000000ffebbd38, 0x00000000ffebbe00, 0x0000000100000000)
Metaspace used 3429K, capacity 4494K, committed 4864K, reserved 1056768K
class space used 382K, capacity 386K, committed 512K, reserved 1048576 | 0debug |
Create model in a custom path in laravel : <p>I want to create a model in a custom path. If i write the php artisan command like the following it will create model inside app.</p>
<pre><code>php artisan make:model core
</code></pre>
<p>But i want to create the model file inside the custom made Models folder. How can i do it ?</p>
| 0debug |
build_srat(GArray *table_data, GArray *linker, MachineState *machine)
{
AcpiSystemResourceAffinityTable *srat;
AcpiSratProcessorAffinity *core;
AcpiSratMemoryAffinity *numamem;
int i;
uint64_t curnode;
int srat_start, numa_start, slots;
uint64_t mem_len, mem_base, next_base;
MachineClass *mc = MACHINE_GET_CLASS(machine);
CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(machine);
PCMachineState *pcms = PC_MACHINE(machine);
ram_addr_t hotplugabble_address_space_size =
object_property_get_int(OBJECT(pcms), PC_MACHINE_MEMHP_REGION_SIZE,
NULL);
srat_start = table_data->len;
srat = acpi_data_push(table_data, sizeof *srat);
srat->reserved1 = cpu_to_le32(1);
for (i = 0; i < apic_ids->len; i++) {
int apic_id = apic_ids->cpus[i].arch_id;
core = acpi_data_push(table_data, sizeof *core);
core->type = ACPI_SRAT_PROCESSOR_APIC;
core->length = sizeof(*core);
core->local_apic_id = apic_id;
curnode = pcms->node_cpu[apic_id];
core->proximity_lo = curnode;
memset(core->proximity_hi, 0, 3);
core->local_sapic_eid = 0;
core->flags = cpu_to_le32(1);
}
next_base = 0;
numa_start = table_data->len;
numamem = acpi_data_push(table_data, sizeof *numamem);
build_srat_memory(numamem, 0, 640 * 1024, 0, MEM_AFFINITY_ENABLED);
next_base = 1024 * 1024;
for (i = 1; i < pcms->numa_nodes + 1; ++i) {
mem_base = next_base;
mem_len = pcms->node_mem[i - 1];
if (i == 1) {
mem_len -= 1024 * 1024;
}
next_base = mem_base + mem_len;
if (mem_base <= pcms->below_4g_mem_size &&
next_base > pcms->below_4g_mem_size) {
mem_len -= next_base - pcms->below_4g_mem_size;
if (mem_len > 0) {
numamem = acpi_data_push(table_data, sizeof *numamem);
build_srat_memory(numamem, mem_base, mem_len, i - 1,
MEM_AFFINITY_ENABLED);
}
mem_base = 1ULL << 32;
mem_len = next_base - pcms->below_4g_mem_size;
next_base += (1ULL << 32) - pcms->below_4g_mem_size;
}
numamem = acpi_data_push(table_data, sizeof *numamem);
build_srat_memory(numamem, mem_base, mem_len, i - 1,
MEM_AFFINITY_ENABLED);
}
slots = (table_data->len - numa_start) / sizeof *numamem;
for (; slots < pcms->numa_nodes + 2; slots++) {
numamem = acpi_data_push(table_data, sizeof *numamem);
build_srat_memory(numamem, 0, 0, 0, MEM_AFFINITY_NOFLAGS);
}
if (hotplugabble_address_space_size) {
numamem = acpi_data_push(table_data, sizeof *numamem);
build_srat_memory(numamem, pcms->hotplug_memory.base,
hotplugabble_address_space_size, 0,
MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED);
}
build_header(linker, table_data,
(void *)(table_data->data + srat_start),
"SRAT",
table_data->len - srat_start, 1, NULL, NULL);
g_free(apic_ids);
}
| 1threat |
static int vhost_net_start_one(struct vhost_net *net,
VirtIODevice *dev,
int vq_index)
{
struct vhost_vring_file file = { };
int r;
if (net->dev.started) {
return 0;
}
net->dev.nvqs = 2;
net->dev.vqs = net->vqs;
net->dev.vq_index = vq_index;
r = vhost_dev_enable_notifiers(&net->dev, dev);
if (r < 0) {
goto fail_notifiers;
}
r = vhost_dev_start(&net->dev, dev);
if (r < 0) {
goto fail_start;
}
if (net->nc->info->poll) {
net->nc->info->poll(net->nc, false);
}
if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP) {
qemu_set_fd_handler(net->backend, NULL, NULL, NULL);
file.fd = net->backend;
for (file.index = 0; file.index < net->dev.nvqs; ++file.index) {
const VhostOps *vhost_ops = net->dev.vhost_ops;
r = vhost_ops->vhost_call(&net->dev, VHOST_NET_SET_BACKEND,
&file);
if (r < 0) {
r = -errno;
goto fail;
}
}
}
return 0;
fail:
file.fd = -1;
if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP) {
while (file.index-- > 0) {
const VhostOps *vhost_ops = net->dev.vhost_ops;
int r = vhost_ops->vhost_call(&net->dev, VHOST_NET_SET_BACKEND,
&file);
assert(r >= 0);
}
}
if (net->nc->info->poll) {
net->nc->info->poll(net->nc, true);
}
vhost_dev_stop(&net->dev, dev);
fail_start:
vhost_dev_disable_notifiers(&net->dev, dev);
fail_notifiers:
return r;
}
| 1threat |
Accessing Google My Business API without login (using service account) : <p>I want to access the locations associated with my account and their reviews, for that I am using the google my business API and I have access to it (it does work on oAuthplayground).</p>
<p>Now I want to access the google my business api without logging into my account, for that I am trying to make it work with the service account. But no luck so far, please advice how to proceed with this. I have enabled the G suite in the service account and I have also tried to give access to the service account email (ID) for the my business manage but it stays in <em>Invited</em> state, as there is no way to actually accept the invite.</p>
<p>When I try to send request using my account as subject.</p>
<pre><code>$client = new Google_Client();
$client->addScope('https://www.googleapis.com/auth/plus.business.manage');
$client->setAuthConfig(dirname(__FILE__) . '/Xyz Review API-service account.json');
$client->setSubject('xyz*****abc@gmail.com');
$business_service_class = new Google_Service_Mybusiness($client);
$result_accounts = $business_service_class->accounts->listAccounts();
echo json_encode($result_accounts);
exit;
</code></pre>
<blockquote>
<p>Response:
{"nextPageToken":null}</p>
</blockquote>
<p>If I use the google service account ID as email id in subject then I get following response.</p>
<pre><code>$client->setSubject('xyz-review-service@xyz-review-api.iam.gserviceaccount.com');
</code></pre>
<blockquote>
<p>Response:
Error 500
{ "error": "unauthorized_client", "error_description": "Unauthorized client or scope in request." }</p>
</blockquote>
<p>If I am doing this completely wrong then please do advice how to proceed with this. Thank you.</p>
| 0debug |
the pointers to some c-strings, declared and defined in a function, are no longer valid when the program retunrs from that function. Why? : <p>I want to initialize a program with some configuration data. It receives them as an url-encoded json via argv[], decodes and deserializes them and hand them to a method inside a class, that is supposed to set the relevant variables to the submitted values.</p>
<p>The variables have the type c-string, so i do the conversion first before assigning the values to the variables declared outside the method.
If reading out those newly set values from the pointers, everything is fine, as long as i am staying inside this method. Upon leaving it, the variables with their values set from the handed configuration data do contain garbage only, while the one filled from the string literal is perfectly ok.</p>
<p>I printed out information about the variables type (typeid().name()). While they are not necessarily human readable, comparison between shows, that they all are of the type they are supposed to be. Next is compared the values of the pointers inside and out side the method - they were the same.</p>
<pre class="lang-cpp prettyprint-override"><code>/* Config.cpp */
using json = nlohmann::json;
const char *Config::DB_HOST;
const char *Config::DB_USER;
const char *Config::DB_PASSWORD;
const char *Config::DB_NAME;
const char *Config::DB_SOCK;
Config::Config() {}
void Config::initDB(json dbConfig) {
string host = dbConfig["host"];
DB_HOST = host.c_str();
string user = dbConfig["user"];
DB_USER = user.c_str();
string pass = dbConfig["pass"];
DB_PASSWORD = pass.c_str();
string name = dbConfig["name"];
DB_NAME = name.c_str();
DB_SOCK = "/var/run/mysqld/mysqld.sock";
}
</code></pre>
<p>I am especially puzzled about the differences between the values set by the variables and the value set by the string literal. The first fails, the latter works. Whats the difference between them? After some reading in the forum i had the understanding, c_str() should return exactly the same data type (a null-terminated pointer to the data) as the literal.</p>
<p>Thanks for your hints!</p>
| 0debug |
how to calculate number of times key occur in json object or array in js : [{"StateID":"42","State_name":"Badakhshan","CountryID":"1"},{"StateID":"43","State_name":"Badgis","CountryID":"1"},{"StateID":"44","State_name":"Baglan","CountryID":"1"},{"StateID":"45","State_name":"Balkh","CountryID":"1"},{"StateID":"46","State_name":"Bamiyan","CountryID":"1"},{"StateID":"47","State_name":"Farah","CountryID":"1"},{"StateID":"48","State_name":"Faryab","CountryID":"1"},{"StateID":"49","State_name":"Gawr","CountryID":"1"},{"StateID":"50","State_name":"Gazni","CountryID":"1"},{"StateID":"51","State_name":"Herat","CountryID":"1"},{"StateID":"52","State_name":"Hilmand","CountryID":"1"},{"StateID":"53","State_name":"Jawzjan","CountryID":"1"},{"StateID":"54","State_name":"Kabul","CountryID":"1"},{"StateID":"55","State_name":"Kapisa","CountryID":"1"},{"StateID":"56","State_name":"Khawst","CountryID":"1"},{"StateID":"57","State_name":"Kunar","CountryID":"1"},{"StateID":"58","State_name":"Lagman","CountryID":"1"},{"StateID":"59","State_name":"Lawghar","CountryID":"1"},{"StateID":"60","State_name":"Nangarhar","CountryID":"1"},{"StateID":"61","State_name":"Nimruz","CountryID":"1"},{"StateID":"62","State_name":"Nuristan","CountryID":"1"},{"StateID":"63","State_name":"Paktika","CountryID":"1"},{"StateID":"64","State_name":"Paktiya","CountryID":"1"},{"StateID":"65","State_name":"Parwan","CountryID":"1"},{"StateID":"66","State_name":"Qandahar","CountryID":"1"},{"StateID":"67","State_name":"Qunduz","CountryID":"1"},{"StateID":"68","State_name":"Samangan","CountryID":"1"},{"StateID":"69","State_name":"Sar-e Pul","CountryID":"1"},{"StateID":"70","State_name":"Takhar","CountryID":"1"},{"StateID":"71","State_name":"Uruzgan","CountryID":"1"},{"StateID":"72","State_name":"Wardag","CountryID":"1"},{"StateID":"73","State_name":"Zabul","CountryID":"1"}]
this is my json object ,i want to calculate how many times key 'StateID' occurred in json object | 0debug |
How to get datas from an URL : I am coding my first nodejs module, it's about Star Trek Online api, i want to get the maximum data possible from the server URL, so i've started to search on the internet and the only data available is the status of the server.
The problem is that as it's my first nodejs module i don't know how to retreive the data from it, if it's possible to give me some advices, here is the code i have
var http = require('http');
var options = {
host: 'http://launcher.startrekonline.com',
port: 80,
path: '/launcher_server_status'
};
var s;
http.get(options, function(resp){
resp.on('data', function(chunk){
//do something with chunk
console.log(chunk);
//s = chunk
});
}).on("error", function(e){
console.log("Got error: " + e.message);
});
exports.status = function(){
return s;
}
The error is :
Got error: getaddrinfo ENOTFOUND http://launcher.startrekonline.com
http://launcher.startrekonline.com:80 | 0debug |
PHP Memory Error error? Installing Flarum : <p>I am getting the following error when I run setup for Flarum</p>
<pre><code>Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 64 bytes) in **[redacted]/flarum/vendor/oyejorge/less.php/lib/Less/Tree/Ruleset.php** on line 497
</code></pre>
<p>This is not making any sense to me... its been a long time sense I used php but this makes no sense doesn't that mean that php has 33554432 bytes available and it tried to use 64 bytes and couldn't...</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.