problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
AEM Package Manager OOTB to filter properties of package filter nodes : <p>Is there any OOTB solution to filter some properties like <code>cq:lastReplicated</code>, <code>cq:lastReplicatedBy</code> , etc, I wanted to migrate some code from lower environments to higher these properties shows the newly moved content in author also as replicated especially on sites content. So planning to create the packages with the filters without these properties.</p>
| 0debug
|
looping through the button always give me 0 answer : <p>Here's the code. Thank you for helping me.</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>/*this code works fine in code snippet and (when I run the code in the chrome console but when I write the code in my file.js, this won't work*/
var btn = document.getElementsByTagName('button');
alert(btn.length);
// it must alert 3, but I always get 0. Please help me. Thank you</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><button>Games</button>
<button>Foods</button>
<button>Movies</button></code></pre>
</div>
</div>
</p>
| 0debug
|
Pushing notifications from one Viewcontroller to another in swift? : i want to push a notification from one(1st) ViewController to (2nd)Another ViewController while this notification takes a function of the first ViewController and prints the result of the function ? how can i do that ? please help i searched all the internet with no result
| 0debug
|
Can I use two or more log levels INFO, ERROR but NOT ALL : <p>How to use 2 or more logging levels in an application but not ALL</p>
| 0debug
|
static int mxf_read_close(AVFormatContext *s)
{
MXFContext *mxf = s->priv_data;
MXFIndexTableSegment *seg;
int i;
av_freep(&mxf->packages_refs);
for (i = 0; i < s->nb_streams; i++)
s->streams[i]->priv_data = NULL;
for (i = 0; i < mxf->metadata_sets_count; i++) {
switch (mxf->metadata_sets[i]->type) {
case MultipleDescriptor:
av_freep(&((MXFDescriptor *)mxf->metadata_sets[i])->sub_descriptors_refs);
break;
case Sequence:
av_freep(&((MXFSequence *)mxf->metadata_sets[i])->structural_components_refs);
break;
case SourcePackage:
case MaterialPackage:
av_freep(&((MXFPackage *)mxf->metadata_sets[i])->tracks_refs);
break;
case IndexTableSegment:
seg = (MXFIndexTableSegment *)mxf->metadata_sets[i];
av_freep(&seg->temporal_offset_entries);
av_freep(&seg->flag_entries);
av_freep(&seg->stream_offset_entries);
break;
default:
break;
}
av_freep(&mxf->metadata_sets[i]);
}
av_freep(&mxf->partitions);
av_freep(&mxf->metadata_sets);
av_freep(&mxf->aesc);
av_freep(&mxf->local_tags);
for (i = 0; i < mxf->nb_index_tables; i++) {
av_freep(&mxf->index_tables[i].segments);
av_freep(&mxf->index_tables[i].ptses);
av_freep(&mxf->index_tables[i].fake_index);
}
av_freep(&mxf->index_tables);
return 0;
}
| 1threat
|
Creating JSON array using Javascript : I have a json object which I need to remodel and create an array of the Json. The initial json looks like {"id":"[ 1, 2, 3]","priority":"High","assignto":"DanTest","comment":"This is a test"}
Expected result:
[{
id: "1"
priority: "High",
assignto: "DanTest"
comment: "This is a test"
},
{
id: "2"
priority: "High",
assignto: "DanTest"
comment: "This is a test"
},
{
id: "3"
priority: "High",
assignto: "DanTest"
comment: "This is a test"
}
]
| 0debug
|
React-Native: Show loading screen till the webview is loaded : <p>I have at the moment a component SplashScreen which I'm rendering first till my state is set. I would like somehow to find a way how to still show this component while my webview is loaded. I added the onLoadEnd to my webview and looks like I get my message back when its finished loading, the problem is that if I load first the splashscreen and wait for the state to be changed onLoadEnd actually will never be changed because the webview is not yet rendered. Is there a good method how to do this?</p>
| 0debug
|
HTML does not respond to the stylesheet : <p>I don't know why my html does not respond to my stylsheet. Please help!
Both html and stylesheet are in same folder.</p>
<pre><code><!DOCTYPE html>
<html>
<head>
<title>First try</title>
<link type=“text/css” rel=“stylesheet” href=“stylesheet.css”/>
</head>
<body>
<h1>My first html </h1>
<p>I wish it works!</p>
</body>
</html>
</code></pre>
| 0debug
|
Cherry-Picking few commits from another branch : <p>I have a scenario where in i dont want to cherry pick a specific commit but a range of git commits from remote.
I can do force pull with hard option but that will get all the commits including latest changes from remote.
Please suggest, how can i get a pick range of commits from remote.</p>
<hr>
<p>For instance, this is what i am trying my head at.</p>
<p>git checkout -b newbranch 62ecb3</p>
<p>git rebase --onto master 76cada, 56qwqw, 46erer, etc</p>
| 0debug
|
How can i make my website zoom out like this website? : Guys i have started learning CSS and HTML therefore i am new to these languages. And i've learnt how parts work such as the meta data attribute "width=device-width,height=device-height,initial-scale=1" which allows for the screen size to be adjusted according to the the device.
Then i began working on my website however i came across the problem which i need help with :
The problem is that i tried to put the content of my webpage into a div and then tried to style it by adding paddings to the left and right side so the effect would be like this website : https://www.merlincycles.com/2
However when i did this and zoomed out, the content of the webpage (the header, logo, form etc) also moved to the edges of the page however what i want to do is create an effect like the website provided so that when the user zooms out the website gets smaller but the content stays in place. Please try to zoom out on the website provided to get an idea.
Thank you
Code:
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,height=device-
height,initial-scale=1">
<title>Bike King </title>
<link rel="stylesheet" href="screen.css" media="screen">
</head>
<body>
<div id="container">
<div id="header">
<a href="index.html"> Sign in/Register</a>
<div>Need Help? : 02080207651</div>
<div>FREE International shipping on<span>Selected Items</span></div>
<!-- #header --></div>
<div id="form-container">
<img src="image/logo.png" alt="logo">
<form action="#">
<input type="text" id="textbox" name="textbox" required placeholder="Search
Bike King...">
<input type="submit" value="Search">
</form>
<!-- #form-container --></div>
</div>
</body>
</html>
* {
padding: 0;
margin: 0;
}
body {
background-color: #f0f0f0;
font: 100%/160% verdana, arial, helvetica, sans-serif;
padding:0em 0em 0em;
}
#container{
padding-right:10em;
padding-left:10em;
}
#header {
padding:0.75em 1em;
background-color: black;
text-align: center;
color:#fff;
}
#header a {
float: left;
color: #fff;
text-decoration: none;
}
#header a:hover {
color: #fcab15;
}
#header div:first-of-type {
float: right;
}
#header div:last-of-type {
display: inline-block;
}
#header div:last-of-type span {
margin-left: 0.5em;
color: #fcab15;
}
#form-container {
padding: 0.75em 1em 3em;
background-color: #065671;
text-align: center;
}
#form-container img{
float:left;
margin-top:-0.75em;
position:relative;
}
#form-container form {
display: inline-block;
vertical-align: middle;
margin-top:2em;
margin-right:20em;
}
#form-container form input[type="text"] {
line-height: 2.5em;
font-size: 1em;
}
#form-container form input[type="submit"] {/*Controls submit box*/
border-color: #008000;
border-style: outset;
background-color: #008000;
line-height: 2.5em;
font-size: 1em;
}
@media ( max-width:50em ) {
#header a,
#header div:first-of-type,
#header div:last-of-type {
float: none;
display: block;
}
}
@media ( max-width:30.5em) {
#form-container img {
display: block;
margin: none;
}
#form-container label {
display: block;
margin: 0.5em 0;
}
}
@media (min-width:90.5em){
#header a,
#header div:first-of-type,
#header div:last-of-type {
float: none;
display: block;
}
}
Thank you!
| 0debug
|
Get YAML for deployed Kubernetes services? : <p>I am trying to deploy my app to <em>Kubernetes</em> running in <em>Google Container
Engine</em>.</p>
<p>The app can be found at: <a href="https://github.com/Industrial/docker-znc" rel="noreferrer">https://github.com/Industrial/docker-znc</a>.</p>
<p>The <em>Dockerfile</em> is built into an image on <em>Google Container Registry</em>.</p>
<p>I have deployed the app in <em>Kubernetes</em> via the + button. I don't have the YAML
for this.</p>
<p>I have inserted a <em>Secret</em> in <em>Kubernetes</em> for the PEM file required by the app.</p>
<ol>
<li>How do I get the YAML for the <em>Deployment</em>, <em>Service</em> and <em>Pod</em> created by
Kubernetes by filling in the form?</li>
<li>How do I get the <em>Secret</em> into my <em>Pod</em> for usage?</li>
</ol>
| 0debug
|
static int vp9_handle_packet(AVFormatContext *ctx, PayloadContext *rtp_vp9_ctx,
AVStream *st, AVPacket *pkt, uint32_t *timestamp,
const uint8_t *buf, int len, uint16_t seq,
int flags)
{
int has_pic_id, has_layer_idc, has_ref_idc, has_ss_data, has_su_data;
av_unused int pic_id = 0, non_key_frame = 0;
av_unused int layer_temporal = -1, layer_spatial = -1, layer_quality = -1;
int ref_fields = 0, has_ref_field_ext_pic_id = 0;
int first_fragment, last_fragment;
int rtp_m;
int res = 0;
if (rtp_vp9_ctx->buf && rtp_vp9_ctx->timestamp != *timestamp)
ffio_free_dyn_buf(&rtp_vp9_ctx->buf);
if (len < RTP_VP9_DESC_REQUIRED_SIZE + 1) {
av_log(ctx, AV_LOG_ERROR, "Too short RTP/VP9 packet, got %d bytes\n", len);
return AVERROR_INVALIDDATA;
}
has_pic_id = !!(buf[0] & 0x80);
has_layer_idc = !!(buf[0] & 0x40);
has_ref_idc = !!(buf[0] & 0x20);
first_fragment = !!(buf[0] & 0x10);
last_fragment = !!(buf[0] & 0x08);
has_ss_data = !!(buf[0] & 0x04);
has_su_data = !!(buf[0] & 0x02);
rtp_m = !!(flags & RTP_FLAG_MARKER);
if (last_fragment != rtp_m) {
av_log(ctx, AV_LOG_ERROR, "Invalid combination of B and M marker (%d != %d)\n", last_fragment, rtp_m);
return AVERROR_INVALIDDATA;
}
buf += RTP_VP9_DESC_REQUIRED_SIZE;
len -= RTP_VP9_DESC_REQUIRED_SIZE;
if (has_pic_id) {
if (len < 1) {
av_log(ctx, AV_LOG_ERROR, "Too short RTP/VP9 packet\n");
return AVERROR_INVALIDDATA;
}
if (buf[0] & 0x80) {
if (len < 2) {
av_log(ctx, AV_LOG_ERROR, "Too short RTP/VP9 packet\n");
return AVERROR_INVALIDDATA;
}
pic_id = AV_RB16(buf) & 0x7fff;
buf += 2;
len -= 2;
} else {
pic_id = buf[0] & 0x7f;
buf++;
len--;
}
}
if (has_layer_idc) {
if (len < 1) {
av_log(ctx, AV_LOG_ERROR, "Too short RTP/VP9 packet\n");
return AVERROR_INVALIDDATA;
}
layer_temporal = buf[0] & 0xC0;
layer_spatial = buf[0] & 0x30;
layer_quality = buf[0] & 0x0C;
if (has_ref_idc) {
ref_fields = buf[0] & 0x03;
if (ref_fields)
non_key_frame = 1;
}
buf++;
len--;
}
if (has_ref_idc) {
while (ref_fields) {
if (len < 1) {
av_log(ctx, AV_LOG_ERROR, "Too short RTP/VP9 packet\n");
return AVERROR_INVALIDDATA;
}
has_ref_field_ext_pic_id = buf[0] & 0x10;
if (has_ref_field_ext_pic_id) {
if (len < 2) {
av_log(ctx, AV_LOG_ERROR, "Too short RTP/VP9 packet\n");
return AVERROR_INVALIDDATA;
}
buf += 2;
len -= 2;
} else {
buf++;
len--;
}
ref_fields--;
}
}
if (has_ss_data) {
avpriv_report_missing_feature(ctx, "VP9 scalability structure data");
return AVERROR(ENOSYS);
}
if (has_su_data) {
avpriv_report_missing_feature(ctx, "VP9 scalability update structure data");
return AVERROR(ENOSYS);
}
if (len < 1) {
av_log(ctx, AV_LOG_ERROR, "Too short RTP/VP9 packet\n");
return AVERROR_INVALIDDATA;
}
if (!rtp_vp9_ctx->buf) {
if (first_fragment) {
res = avio_open_dyn_buf(&rtp_vp9_ctx->buf);
if (res < 0)
return res;
rtp_vp9_ctx->timestamp = *timestamp;
} else {
return AVERROR(EAGAIN);
}
}
avio_write(rtp_vp9_ctx->buf, buf, len);
if (!last_fragment)
return AVERROR(EAGAIN);
res = ff_rtp_finalize_packet(pkt, &rtp_vp9_ctx->buf, st->index);
if (res < 0)
return res;
return 0;
}
| 1threat
|
Xcode 7.2 quits unexpectedly : <p>I am trying to open the lower version of Xcode and suddenly my Xcode got crash and now whenever I am opening any of the Xcode version, I am getting this error that says " Xcode quit Unexpectedly " with three options: Ignore, Report & Reopen but still none of the option is working.</p>
| 0debug
|
Q: javafx fxml jdbc getting database data to ListView : <p>I'm making a program using scene builder to create UI, but I got problem how to load a database to ListView at beginning of the program, I just have no clue how to do it. I created method in Controller class, but I can run it only by button or something like this. My program looks like: <a href="http://pastebin.com/y9VCAVWF" rel="nofollow">http://pastebin.com/y9VCAVWF</a></p>
<p>I would appreciate any help</p>
| 0debug
|
static int append_to_cached_buf(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
DVDSubContext *ctx = avctx->priv_data;
if (ctx->buf_size > 0xffff - buf_size) {
av_log(avctx, AV_LOG_WARNING, "Attempt to reconstruct "
"too large SPU packets aborted.\n");
av_freep(&ctx->buf);
return AVERROR_INVALIDDATA;
}
ctx->buf = av_realloc(ctx->buf, ctx->buf_size + buf_size);
if (!ctx->buf)
return AVERROR(ENOMEM);
memcpy(ctx->buf + ctx->buf_size, buf, buf_size);
ctx->buf_size += buf_size;
return 0;
}
| 1threat
|
static void spr_write_dbatl_h (void *opaque, int sprn)
{
DisasContext *ctx = opaque;
gen_op_store_dbatl((sprn - SPR_DBAT4L) / 2);
RET_STOP(ctx);
}
| 1threat
|
static void macio_nvram_writeb(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
MacIONVRAMState *s = opaque;
addr = (addr >> s->it_shift) & (s->size - 1);
s->data[addr] = value;
NVR_DPRINTF("writeb addr %04" PHYS_PRIx " val %" PRIx64 "\n", addr, value);
}
| 1threat
|
Load S3 Data into AWS SageMaker Notebook : <p>I've just started to experiment with AWS SageMaker and would like to load data from an S3 bucket into a pandas dataframe in my SageMaker python jupyter notebook for analysis.</p>
<p>I could use boto to grab the data from S3, but I'm wondering whether there is a more elegant method as part of the SageMaker framework to do this in my python code?</p>
<p>Thanks in advance for any advice.</p>
| 0debug
|
static void vmsvga_init(struct vmsvga_state_s *s, DisplayState *ds,
uint8_t *vga_ram_base, unsigned long vga_ram_offset,
int vga_ram_size)
{
s->ds = ds;
s->vram = vga_ram_base;
s->vram_size = vga_ram_size;
s->vram_offset = vga_ram_offset;
s->scratch_size = SVGA_SCRATCH_SIZE;
s->scratch = (uint32_t *) qemu_malloc(s->scratch_size * 4);
vmsvga_reset(s);
s->console = graphic_console_init(ds, vmsvga_update_display,
vmsvga_invalidate_display,
vmsvga_screen_dump,
vmsvga_text_update, s);
#ifdef EMBED_STDVGA
vga_common_init((VGAState *) s, ds,
vga_ram_base, vga_ram_offset, vga_ram_size);
vga_init((VGAState *) s);
#endif
}
| 1threat
|
what is the best way to compare strings from two arrays in javascript? : <pre><code>var job = ['javascript','nodejs','angularjs','css','html','graphql'];
var candidate= ['javascript','node', 'css', 'html', 'postgres', 'sql', 'express', 'python', 'c#'];
</code></pre>
<p>Hi everyone,
I have these two arrays, I would like to find how many matches candidate has with job description, so in this case javascript, node, css, html = 4 matches. I am just trying to find the best way to check and make sure to count same languages and frameworks.
thank you guys</p>
| 0debug
|
static void ehci_execute_complete(EHCIQueue *q)
{
EHCIPacket *p = QTAILQ_FIRST(&q->packets);
assert(p != NULL);
assert(p->qtdaddr == q->qtdaddr);
assert(p->async != EHCI_ASYNC_INFLIGHT);
p->async = EHCI_ASYNC_NONE;
DPRINTF("execute_complete: qhaddr 0x%x, next %x, qtdaddr 0x%x, status %d\n",
q->qhaddr, q->qh.next, q->qtdaddr, q->usb_status);
if (p->usb_status < 0) {
switch (p->usb_status) {
case USB_RET_IOERROR:
case USB_RET_NODEV:
q->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_XACTERR);
set_field(&q->qh.token, 0, QTD_TOKEN_CERR);
ehci_record_interrupt(q->ehci, USBSTS_ERRINT);
break;
case USB_RET_STALL:
q->qh.token |= QTD_TOKEN_HALT;
ehci_record_interrupt(q->ehci, USBSTS_ERRINT);
break;
case USB_RET_NAK:
set_field(&q->qh.altnext_qtd, 0, QH_ALTNEXT_NAKCNT);
return;
case USB_RET_BABBLE:
q->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_BABBLE);
ehci_record_interrupt(q->ehci, USBSTS_ERRINT);
break;
default:
fprintf(stderr, "USB invalid response %d\n", p->usb_status);
assert(0);
break;
}
} else if ((p->usb_status > p->tbytes) && (p->pid == USB_TOKEN_IN)) {
p->usb_status = USB_RET_BABBLE;
q->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_BABBLE);
ehci_record_interrupt(q->ehci, USBSTS_ERRINT);
} else {
if (p->tbytes && p->pid == USB_TOKEN_IN) {
p->tbytes -= p->usb_status;
} else {
p->tbytes = 0;
}
DPRINTF("updating tbytes to %d\n", p->tbytes);
set_field(&q->qh.token, p->tbytes, QTD_TOKEN_TBYTES);
}
ehci_finish_transfer(q, p->usb_status);
qemu_sglist_destroy(&p->sgl);
usb_packet_unmap(&p->packet);
q->qh.token ^= QTD_TOKEN_DTOGGLE;
q->qh.token &= ~QTD_TOKEN_ACTIVE;
if (q->qh.token & QTD_TOKEN_IOC) {
ehci_record_interrupt(q->ehci, USBSTS_INT);
}
}
| 1threat
|
What does b stand for, and what is the syntax behind b+sr+Latn? : <p>By default, Android has always displayed Serbian in Cyrillic, but since 7.0, users can choose between Cyrillic and Latin script. Apps (mostly from Google) ususally puts the Cyrillic strings in <code>sr</code> and the Latin strings in <code>b+sr+Latn</code>. However, <code>b+sr+Latn</code> is very different from the usual convention of using dashes (e.g. <code>sr-rRS-port</code>).</p>
<p>What does b stand for? What is the syntax, and what more can I specify with this?</p>
| 0debug
|
I m getting nothing here in main activity. plz help me out : [**enter image description here**][1]
[1]: https://i.stack.imgur.com/iGOP3.jpg
I m doing it as a college project using Card View and List View.
Meta Stack Exchange is a question and answer site for meta-discussion of the Stack Exchange family of Q&A websites. Join them; it only takes a minute:
The RecyclerView widget is a more advanced and flexible version of ListView. This widget is a container for displaying large data sets that can be scrolled very efficiently by maintaining a limited number of views. Use the RecyclerView widget when you have data collections whose elements change at runtime based on user action or network events.
The RecyclerView class simplifies the display and handling of large data sets by providing:
Layout managers for positioning items
Default animations for common item operations, such as removal or addition of items
You also have the flexibility to define custom layout managers and animations for RecyclerView widgets.
my main_activity.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="sonu.myapplication.MainActivity">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@color/colorPrimary"
android:id="@+id/ToolbarMain">
</android.support.v7.widget.Toolbar>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:dividerHeight="10dp"
android:id="@+id/lvMain"
android:layout_below="@id/ToolbarMain"
android:divider="@null">
</ListView>
</RelativeLayout>
enter code here
<android.support.v7.widget.CardView android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="@color/colorAccent"
android:elevation="4dp"
xmlns:android="http://schemas.android.com/apk/res/android" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="80dp"
android:layout_height="105dp"
android:id="@+id/ivMain"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginStart="11dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvMain"
android:text="Timetable"
android:layout_marginLeft="6dp"
android:textStyle="bold"
android:layout_toRightOf="@id/ivMain"
android:textSize="24sp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvDescription"
android:text="Description"
android:layout_marginLeft="6dp"
android:layout_below="@id/tvMain"
android:layout_toRightOf="@id/ivMain"
android:textSize="16dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvClick"
android:textSize="12dp"
android:text="Click here"
android:layout_alignParentRight="true"
android:layout_marginTop="7dp"
android:layout_below="@id/tvDescription"
android:layout_alignBottom="@id/ivMain"
/>
</RelativeLayout>
</android.support.v7.widget.CardView>
package sonu.myapplication;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private Toolbar toolbar;
private ListView listView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setupUiViews();
initToolbar();
}
private void setupUiViews(){
toolbar=(Toolbar)findViewById(R.id.ToolbarMain);
listView=(ListView)findViewById(R.id.lvMain);
}
private void initToolbar(){
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("TimeTable App");
}
private void setUpListView(){
String[] title = getResources().getStringArray(R.array.Main);
String[] description = getResources().getStringArray(R.array.Description);
SimpleAdapter simpleAdapter=new SimpleAdapter(this, title, description);
listView.setAdapter(simpleAdapter);
}
public class SimpleAdapter extends BaseAdapter{
private Context myContext;
private LayoutInflater layoutInflater;
private TextView title, description;
private String[] titleArray;
private String[] descriptionArray;
private ImageView imageView;
public SimpleAdapter(Context myContext, String[] titleArray, String[] descriptionArray){
this.myContext=myContext;
this.titleArray=titleArray;
this.descriptionArray=descriptionArray;
layoutInflater=LayoutInflater.from(myContext);
}
@Override
public int getCount() {
return titleArray.length;
}
@Override
public Object getItem(int position) {
return titleArray[position];
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView==null){
convertView=layoutInflater.inflate(R.layout.main_activity_single_item, null);
}
title=(TextView)convertView.findViewById(R.id.tvMain);
description=(TextView)convertView.findViewById(R.id.tvDescription);
imageView=(ImageView)convertView.findViewById(R.id.ivMain);
title.setText(titleArray[position]);
description.setText(descriptionArray[position]);
if (titleArray[position].equalsIgnoreCase("Timetable")){
imageView.setImageResource(R.drawable.timetable);
}else if (titleArray[position].equalsIgnoreCase("Subjects")){
imageView.setImageResource(R.drawable.subjects);
}else if (titleArray[position].equalsIgnoreCase("Faculty")){
imageView.setImageResource(R.drawable.teachers);
}else if (titleArray[position].equalsIgnoreCase("resource")){
imageView.setImageResource(R.drawable.resource);
}
return convertView;
}
}
}
and now my strings.xml
<resources>
<string name="app_name">My Application</string>
<string-array name="Main">
<item> Timetable </item>
<item> Subjects </item>
<item> Faculty </item>
<item> Resources </item>
</string-array>
<string-array name="Description">
<item> Description 1</item>
<item> Description 2</item>
<item> Description 3</item>
<item> Description 4</item>
</string-array>
</resources>
| 0debug
|
How do I convert a list in quotes ( '[1,2,3]' ) to a proper list ( [1,2,3] ) in python? : <p>The problem is very fundamental. All I want to know is if there is a function to perform the task without appending to a new list.</p>
<p>I tried using loop but it will become a little complex for cases like...
'[1,2,3],[4,5,6]'</p>
| 0debug
|
static void flush_packet(AVFormatContext *ctx, int stream_index,
int64_t pts, int64_t dts, int64_t scr)
{
MpegMuxContext *s = ctx->priv_data;
StreamInfo *stream = ctx->streams[stream_index]->priv_data;
uint8_t *buf_ptr;
int size, payload_size, startcode, id, len, stuffing_size, i, header_len;
uint8_t buffer[128];
id = stream->id;
#if 0
printf("packet ID=%2x PTS=%0.3f\n",
id, pts / 90000.0);
#endif
buf_ptr = buffer;
if (((s->packet_number % s->pack_header_freq) == 0)) {
size = put_pack_header(ctx, buf_ptr, scr);
buf_ptr += size;
if ((s->packet_number % s->system_header_freq) == 0) {
size = put_system_header(ctx, buf_ptr);
buf_ptr += size;
}
}
size = buf_ptr - buffer;
put_buffer(&ctx->pb, buffer, size);
if (s->is_mpeg2) {
header_len = 3;
} else {
header_len = 0;
}
if (pts != AV_NOPTS_VALUE) {
if (dts != AV_NOPTS_VALUE)
header_len += 5 + 5;
else
header_len += 5;
} else {
if (!s->is_mpeg2)
header_len++;
}
payload_size = s->packet_size - (size + 6 + header_len);
if (id < 0xc0) {
startcode = PRIVATE_STREAM_1;
payload_size -= 4;
} else {
startcode = 0x100 + id;
}
stuffing_size = payload_size - stream->buffer_ptr;
if (stuffing_size < 0)
stuffing_size = 0;
put_be32(&ctx->pb, startcode);
put_be16(&ctx->pb, payload_size + header_len);
for(i=0;i<stuffing_size;i++)
put_byte(&ctx->pb, 0xff);
if (s->is_mpeg2) {
put_byte(&ctx->pb, 0x80);
if (pts != AV_NOPTS_VALUE) {
if (dts != AV_NOPTS_VALUE) {
put_byte(&ctx->pb, 0xc0);
put_byte(&ctx->pb, header_len - 3);
put_timestamp(&ctx->pb, 0x03, pts);
put_timestamp(&ctx->pb, 0x01, dts);
} else {
put_byte(&ctx->pb, 0x80);
put_byte(&ctx->pb, header_len - 3);
put_timestamp(&ctx->pb, 0x02, pts);
}
} else {
put_byte(&ctx->pb, 0x00);
put_byte(&ctx->pb, header_len - 3);
}
} else {
if (pts != AV_NOPTS_VALUE) {
if (dts != AV_NOPTS_VALUE) {
put_timestamp(&ctx->pb, 0x03, pts);
put_timestamp(&ctx->pb, 0x01, dts);
} else {
put_timestamp(&ctx->pb, 0x02, pts);
}
} else {
put_byte(&ctx->pb, 0x0f);
}
}
if (startcode == PRIVATE_STREAM_1) {
put_byte(&ctx->pb, id);
if (id >= 0x80 && id <= 0xbf) {
put_byte(&ctx->pb, 1);
put_byte(&ctx->pb, 0);
put_byte(&ctx->pb, 2);
}
}
put_buffer(&ctx->pb, stream->buffer, payload_size - stuffing_size);
put_flush_packet(&ctx->pb);
len = stream->buffer_ptr - payload_size;
if (len < 0)
len = 0;
memmove(stream->buffer, stream->buffer + stream->buffer_ptr - len, len);
stream->buffer_ptr = len;
s->packet_number++;
stream->packet_number++;
}
| 1threat
|
Chnage state in JSON file : I have trouble in school to change a state in my json file,
i must do a game with HTML and javascript, i start with a "Guess who?" game, in my json i have players with attributs like name,password and state.
all my request only look the number of state and change it if he must.
how i can write a code that change only player.state like 1 to 3 ?
thanks
this is my json file :
`[
{"pseudo":"player1","password":"player","state":"1"},
{"pseudo":"player2","password":"player","state":"0"}
]
`
| 0debug
|
Why isn't this action abstract? : <p>I am having a hard time understanding why one of the Actions in a class is abstract and the Action in the other class not.</p>
<p>Source code 1: (Error when compiling: <a href="https://gyazo.com/cd3c21a8562589451814903febaf89fe" rel="nofollow">https://gyazo.com/cd3c21a8562589451814903febaf89fe</a>)</p>
<pre><code>import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Play extends JFrame{
Engine drawPanel = new Engine();
private int x = 0;
private int y = 0;
public int getX(){
return x;
}
public int getY(){
return y;
}
public Play(){
Action rightAction = new AbstractAction(){
public void actionPreformed(ActionEvent e){
x+=10;
drawPanel.repaint();
}
};
Action leftAction = new AbstractAction(){
public void actionPreformed(ActionEvent e){
x-=10;
drawPanel.repaint();
}
};
InputMap inputMap = drawPanel.getInputMap(JPanel.WHEN_IN_FOCUSED_WINDOW);
ActionMap actionMap = drawPanel.getActionMap();
inputMap.put(KeyStroke.getKeyStroke("RIGHT"), "rightAction");
actionMap.put("rightAction", rightAction);
inputMap.put(KeyStroke.getKeyStroke("LEFT"), "leftAction");
actionMap.put("leftAction", leftAction);
add(drawPanel);
pack();
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(640, 480);
setTitle("Game");
setLocationRelativeTo(null);
setVisible(true);
}
public static void main(String[] args){
EventQueue.invokeLater(new Runnable(){
@Override
public void run(){
new Play();
}
});
}
}
</code></pre>
<p>Source code 2:(The code that compiles just fine)</p>
<pre><code>import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class KeyBidings extends JFrame {
int x = 0;
int y = 0;
DrawPanel drawPanel = new DrawPanel();
public KeyBidings(){
Action rightAction = new AbstractAction(){
public void actionPerformed(ActionEvent e) {
x +=10;
drawPanel.repaint();
}
};
InputMap inputMap = drawPanel.getInputMap(JPanel.WHEN_IN_FOCUSED_WINDOW);
ActionMap actionMap = drawPanel.getActionMap();
inputMap.put(KeyStroke.getKeyStroke("RIGHT"), "rightAction");
actionMap.put("rightAction", rightAction);
add(drawPanel);
pack();
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setVisible(true);
}
private class DrawPanel extends JPanel {
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.GRAY);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.GREEN);
g.fillRect(x, y, 50, 50);
}
public Dimension getPreferredSize() {
return new Dimension(400, 200);
}
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable(){
public void run(){
new KeyBidings();
}
});
}
}
</code></pre>
| 0debug
|
android programming broadcastreceiver : I have taken some item as `spinner` in strings.xml file.and saving selected data in `sharedpreferrence`.Now i want to face the saving data from my `Broadcast receiver` class and want to make a text like "u need to contact with mr.x" and want to show as a notification text.how can i do it.my preferrence code is :
> Blockquote
public void saveinfo(View view) {
SharedPreferences sp = getSharedPreferences("alarmatspecifictime", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.putString("name", nameinput.getText().toString());
// editor.putString("purpose", spinner.getText().toString());
editor.putString("purpose",spinner.getSelectedItem().toString());
editor.apply();
makeText(this, "saved", LENGTH_LONG).show();
and broadcast receiver class is
public class AlarmReceiver extends BroadcastReceiver {
private String Birthday, MarriageDay, Email, Contact, Visit, Meeting;
@Override
public void onReceive(Context context, Intent intent) {
//Toast.makeText(context, "Your Time is up!!!!!", Toast.LENGTH_LONG).show();
add_Notification(context);
}
public void add_Notification(Context context) {
Log.d("ME", "Notification started");
NotificationCompat.Builder mBuilder;
mBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("This is showing My notification")
.setContentText("hello")
.addAction(R.drawable.ic_prev, "Yes", null)
.addAction(R.drawable.ic_prev, "No", null);
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1, mBuilder.build());
}
//fetch data from sharedpreferrences
public void get_pref(Context context) {
SharedPreferences sp = context.getSharedPreferences("alarmatspecifictime", context.MODE_PRIVATE);
String restoredText = sp.getString("purpose", "");
String restoredname = sp.getString("name", "");
// Log.i("TAG", "data from shared prefs: " + restoredText);
| 0debug
|
When downloading and installing symfony 3, I had an issue "SSL certificate" as shown in the capture : [enter image description here][1][please How to solve this problem ?
thanks ..][2]
[1]: https://i.stack.imgur.com/0X12w.png
[2]: https://i.stack.imgur.com/rzTku.png
| 0debug
|
How to Rename Files in Linux : <p>I want to rename all files in selected directory using rename command or move command from :</p>
<pre><code>_02_mp3_cbr_320.m4a?anghakamitoken=sc245ae5a454547.5
_02_mp3_fsgsfsdfsfdfdsfcbr_320.m4a?anghakamitoken=sc245.ae5a
</code></pre>
<p>to</p>
<pre><code>1.m4a
2.m4a
</code></pre>
| 0debug
|
My HTML form sensd email but does not does not send from data. What could be the proplem? : As an intermediate web developer, I have a problem with my form not send inserted data(the email goes through but form data does not), I don't know if it is form or PHP script.
**HTML**
<form id="main-contact-form" name="contact-form" method="POST" action="sendemail.php">
<fieldset>
<div class="row wow fadeInUp" data-wow-duration="1000ms" data-wow-delay="300ms">
<div class="col-sm-6">
<div class="form-group">
<input type="text" name="name" class="form-control" placeholder="Name" required="required">
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input type="email" name="email" class="form-control" placeholder="Email Address" required="required">
</div>
</div>
</div>
<div class="form-group">
<input type="text" name="subject" class="form-control" placeholder="Subject" required="required">
</div>
<div class="form-group">
<textarea name="message" id="message" class="form-control" rows="4" placeholder="Enter your message" required="required"></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn-submit">Send Now</button>
</div>
</fieldset>
</form>
**JS**
// Contact form
var form = $('#main-contact-form');
form.submit(function(event){
event.preventDefault();
var form_status = $('<div class="form_status"></div>');
$.ajax({
url: $(this).attr('action'),
beforeSend: function(){
form.prepend( form_status.html('<p><i class="fa fa-spinner fa-spin"></i> Email is sending...</p>').fadeIn() );
}
}).done(function(data){
form_status.html('<p class="text-success">Thank you for contacting us. We will respond to you as soon as possible</p>').delay(5000).fadeOut();
});
});
**PHP**
<?php
$name = @trim(stripslashes($_POST['name']));
$from = @trim(stripslashes($_POST['email']));
$subject = @trim(stripslashes($_POST['subject']));
$message = @trim(stripslashes($_POST['message']));
$to = 'daniel.vusi696@gmail.com';
$headers .= "MIME-Version: 1.0";
$headers .= "Content-type: text/plain; charset=iso-8859-1";
$headers .= "From: {$name} <{$from}>";
$headers .= "Reply-To: <{$from}>";
$headers .= "Subject: {$subject}";
$headers .= "X-Mailer: PHP/".phpversion();
mail($to, $subject, $message, $headers);die;
?>
Please help as I am stuch here.
| 0debug
|
creating self-signed certificates with open ssl on windows : <p>I am following <a href="https://jamielinux.com/docs/openssl-certificate-authority/create-the-intermediate-pair.html" rel="noreferrer">these guidelines</a> to generate self-signed certificates with OpenSSL.</p>
<p>I am under Windows 10. My working directory is as follows:</p>
<pre><code>PS E:\Certificats\predix\root\ca> ls
Directory: E:\Certificats\predix\root\ca
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 9/1/2016 11:57 AM certs
d----- 9/1/2016 11:55 AM crl
d----- 9/1/2016 12:00 PM intermediate
d----- 9/1/2016 11:55 AM newcerts
d----- 9/1/2016 11:56 AM private
-a---- 9/1/2016 11:55 AM 2 index.txt
-a---- 9/1/2016 11:56 AM 4306 openssl.cnf
-a---- 9/1/2016 11:55 AM 14 serial
</code></pre>
<p>After several steps in the guideline, when I type</p>
<pre><code>openssl ca -config openssl.cnf -extensions v3_intermediate_ca -days 3650 -notext -md s
</code></pre>
<p>I get the following error</p>
<pre><code>Using configuration from openssl.cnf
Enter pass phrase for ./private/ca.key.pem:
unable to load number from ./serial
error while loading serial number
12944:error:0D066096:asn1 encoding routines:a2i_ASN1_INTEGER:short line:.\crypto\asn1\f_int.c:212:
PS E:\Certificats\predix\root\ca> openssl ca -config openssl.cnf -extensions v3_intermediate_ca -days 3650 -notext -md sha256 -in intermediate/csr/intermediate.csr.pem -out intermediate/certs/intermediate.cert.pem
Using configuration from openssl.cnf
</code></pre>
<p>telling me that it has some issue reading the serial file.</p>
<p>The content of serial is</p>
<pre><code>1000
</code></pre>
<p>Does anyone have a fix for this ? The file exists and its pathname in the conf file is the correct...</p>
| 0debug
|
have to make algo of this functiionality in php : i have a string -
<b>Hello, How Are You.</b>
i want this output ->
<b>eHllo, oHw rAe oYu.</b>
it doesnot matter whether there is any special character , i just want to reverse the two alphabets cosecutively in a word.
| 0debug
|
void ram_control_after_iterate(QEMUFile *f, uint64_t flags)
{
int ret = 0;
if (f->ops->after_ram_iterate) {
ret = f->ops->after_ram_iterate(f, f->opaque, flags);
if (ret < 0) {
qemu_file_set_error(f, ret);
}
}
}
| 1threat
|
Time delays without using Thread.sleep() : <p>I wrote a client application where I am using two threads other than the main thread.The Background thread is used to receive data through TCP IP,while after receiving I am calling another thread that will show the received data continuously using a for loop.But after every iteration the for loop needs to wait for 30 seconds.I have used Thread.sleep(30000) but the dont know why its not working,sometimes it wakes up from sleep mode before 30 seconds.I am using dot net framework 4.Please suggest some other alternatives.</p>
<pre><code> for(n=0;n<=m;n++)
{
//show data;
//wait for 30 seconds
}
</code></pre>
| 0debug
|
static ioreq_t *cpu_get_ioreq_from_shared_memory(XenIOState *state, int vcpu)
{
ioreq_t *req = xen_vcpu_ioreq(state->shared_page, vcpu);
if (req->state != STATE_IOREQ_READY) {
DPRINTF("I/O request not ready: "
"%x, ptr: %x, port: %"PRIx64", "
"data: %"PRIx64", count: %" FMT_ioreq_size ", size: %" FMT_ioreq_size "\n",
req->state, req->data_is_ptr, req->addr,
req->data, req->count, req->size);
return NULL;
}
xen_rmb();
req->state = STATE_IOREQ_INPROCESS;
return req;
}
| 1threat
|
static void musicpal_lcd_init(DisplayState *ds, uint32_t base)
{
musicpal_lcd_state *s;
int iomemtype;
s = qemu_mallocz(sizeof(musicpal_lcd_state));
if (!s)
return;
s->base = base;
s->ds = ds;
iomemtype = cpu_register_io_memory(0, musicpal_lcd_readfn,
musicpal_lcd_writefn, s);
cpu_register_physical_memory(base, MP_LCD_SIZE, iomemtype);
graphic_console_init(ds, lcd_refresh, NULL, NULL, NULL, s);
dpy_resize(ds, 128*3, 64*3);
}
| 1threat
|
How to get/set Trello custom fields using the API? : <p>I'm already in love with the <a href="https://blog.trello.com/trello-custom-fields/" rel="noreferrer">Custom Fields</a> feature in Trello. Is there a way to get and set custom fields via the API?</p>
<p>I tried using the <a href="https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink-field" rel="noreferrer">get field</a> API call to get a field (on a board with a custom field defined called "MyCustomField"):</p>
<p><code>curl "https://api.trello.com/1/cards/57c473503a5ef0b76fddd0e5/MyCustomField?key=${TRELLO_API_KEY}&token=${TRELLO_OAUTH_TOKEN}"
</code></p>
<p>to no avail. </p>
| 0debug
|
Xcode 9.0 simulators "disappeared" : <p>I recently installed Xcode 9.0 GM on my machine. I fired it up to play around and the only simulators I see in the scheme are iPhone 8, iPHone 8 Plus, and iPhone X. I clicked "Download Additional Simulators" thinking the solution would lie there.</p>
<p><a href="https://i.stack.imgur.com/170tT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/170tT.png" alt="enter image description here"></a></p>
<p>I'm greeted with this screen, which is everything I previously had installed.</p>
<p><a href="https://i.stack.imgur.com/IxDvY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IxDvY.png" alt="enter image description here"></a></p>
<p>I dug around on the Apple Developer forum and found <a href="https://forums.developer.apple.com/thread/63420" rel="noreferrer">this post</a> discussing a similar problem with a prior version of iOS. At the suggestion of one of the posters, I powered down my machine and booted it cold. I opened up Xcode 9.0 again and I have the same issue.</p>
<p>Any suggestions what I can get additional hardware to appear in my Xcode scheme? Thank you for reading.</p>
| 0debug
|
static void ini_print_section_header(WriterContext *wctx)
{
INIContext *ini = wctx->priv;
AVBPrint buf;
int i;
const struct section *section = wctx->section[wctx->level];
const struct section *parent_section = wctx->level ?
wctx->section[wctx->level-1] : NULL;
av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
if (wctx->level == 0) {
printf("# ffprobe output\n\n");
return;
}
if (wctx->nb_item[wctx->level-1])
printf("\n");
for (i = 1; i <= wctx->level; i++) {
if (ini->hierarchical ||
!(section->flags & (SECTION_FLAG_IS_ARRAY|SECTION_FLAG_IS_WRAPPER)))
av_bprintf(&buf, "%s%s", i>1 ? "." : "", wctx->section[i]->name);
}
if (parent_section->flags & SECTION_FLAG_IS_ARRAY) {
int n = parent_section->id == SECTION_ID_PACKETS_AND_FRAMES ?
wctx->nb_section_packet_frame : wctx->nb_item[wctx->level-1];
av_bprintf(&buf, ".%d", n);
}
if (!(section->flags & (SECTION_FLAG_IS_ARRAY|SECTION_FLAG_IS_WRAPPER)))
printf("[%s]\n", buf.str);
av_bprint_finalize(&buf, NULL);
}
| 1threat
|
How to make links follow the cursor for a defined distance on hover state? : <p>I want to reproduce the link "attraction" effect as shown in the following theme : <a href="http://preview.themeforest.net/item/grenada-creative-ajax-portfolio-showcase-slider-theme/full_screen_preview/22712618?_ga=2.243139466.922598619.1568038769-663244003.1563974355" rel="nofollow noreferrer">http://preview.themeforest.net/item/grenada-creative-ajax-portfolio-showcase-slider-theme/full_screen_preview/22712618?_ga=2.243139466.922598619.1568038769-663244003.1563974355</a></p>
<p>Hover "follow us" on the bottom right of the page to see it in action.</p>
<p>Thanks a lot for your help !</p>
| 0debug
|
Two arrays are called similar if one can be obtained from another by swapping at most one pair of elements in one of the arrays : # I Solved the Problem but i need to make it run in 4 seconds(Python3) for all inputs,being a python newbie, i have no clue...any ideas for making this more efficient..Here is my Solution...
def areSimilar (a,b):
counter=0
for i in range(len(a)):
for j in range(len(b)):
if counter < 1 and a[i]!=b[i]:
if a[i]==b[j]:
temp=b[j]
b[j]=b[i]
b[i]=temp
counter+=1
else:
flag=False
if a == b:
flag=True
else:
flag = False
return flag
a= [832, 998, 148, 570, 533, 561, 894, 147, 455, 279]
b= [832, 998, 148, 570, 533, 561, 455, 147, 894, 279]
p=areSimilar(a,b)
# I think the nested loops are the Problem
| 0debug
|
static int write_f(BlockBackend *blk, int argc, char **argv)
{
struct timeval t1, t2;
bool Cflag = false, qflag = false, bflag = false;
bool Pflag = false, zflag = false, cflag = false;
int flags = 0;
int c, cnt;
char *buf = NULL;
int64_t offset;
int64_t count;
int64_t total = 0;
int pattern = 0xcd;
while ((c = getopt(argc, argv, "bcCfpP:quz")) != -1) {
switch (c) {
case 'b':
bflag = true;
break;
case 'c':
cflag = true;
break;
case 'C':
Cflag = true;
break;
case 'f':
flags |= BDRV_REQ_FUA;
break;
case 'p':
break;
case 'P':
Pflag = true;
pattern = parse_pattern(optarg);
if (pattern < 0) {
return 0;
}
break;
case 'q':
qflag = true;
break;
case 'u':
flags |= BDRV_REQ_MAY_UNMAP;
break;
case 'z':
zflag = true;
break;
default:
return qemuio_command_usage(&write_cmd);
}
}
if (optind != argc - 2) {
return qemuio_command_usage(&write_cmd);
}
if (bflag && zflag) {
printf("-b and -z cannot be specified at the same time\n");
return 0;
}
if ((flags & BDRV_REQ_FUA) && (bflag || cflag)) {
printf("-f and -b or -c cannot be specified at the same time\n");
return 0;
}
if ((flags & BDRV_REQ_MAY_UNMAP) && !zflag) {
printf("-u requires -z to be specified\n");
return 0;
}
if (zflag && Pflag) {
printf("-z and -P cannot be specified at the same time\n");
return 0;
}
offset = cvtnum(argv[optind]);
if (offset < 0) {
print_cvtnum_err(offset, argv[optind]);
return 0;
}
optind++;
count = cvtnum(argv[optind]);
if (count < 0) {
print_cvtnum_err(count, argv[optind]);
return 0;
} else if (count > SIZE_MAX) {
printf("length cannot exceed %" PRIu64 ", given %s\n",
(uint64_t) SIZE_MAX, argv[optind]);
return 0;
}
if (bflag || cflag) {
if (offset & 0x1ff) {
printf("offset %" PRId64 " is not sector aligned\n",
offset);
return 0;
}
if (count & 0x1ff) {
printf("count %"PRId64" is not sector aligned\n",
count);
return 0;
}
}
if (!zflag) {
buf = qemu_io_alloc(blk, count, pattern);
}
gettimeofday(&t1, NULL);
if (bflag) {
cnt = do_save_vmstate(blk, buf, offset, count, &total);
} else if (zflag) {
cnt = do_co_pwrite_zeroes(blk, offset, count, flags, &total);
} else if (cflag) {
cnt = do_write_compressed(blk, buf, offset, count, &total);
} else {
cnt = do_pwrite(blk, buf, offset, count, flags, &total);
}
gettimeofday(&t2, NULL);
if (cnt < 0) {
printf("write failed: %s\n", strerror(-cnt));
goto out;
}
if (qflag) {
goto out;
}
t2 = tsub(t2, t1);
print_report("wrote", &t2, offset, count, total, cnt, Cflag);
out:
if (!zflag) {
qemu_io_free(buf);
}
return 0;
}
| 1threat
|
static void cirrus_linear_bitblt_write(void *opaque,
target_phys_addr_t addr,
uint64_t val,
unsigned size)
{
CirrusVGAState *s = opaque;
if (s->cirrus_srcptr != s->cirrus_srcptr_end) {
*s->cirrus_srcptr++ = (uint8_t) val;
if (s->cirrus_srcptr >= s->cirrus_srcptr_end) {
cirrus_bitblt_cputovideo_next(s);
}
}
}
| 1threat
|
static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
{
MpegTSWrite *ts = s->priv_data;
uint8_t data[SECTION_LENGTH], *q, *desc_length_ptr, *program_info_length_ptr;
int val, stream_type, i;
q = data;
put16(&q, 0xe000 | service->pcr_pid);
program_info_length_ptr = q;
q += 2;
val = 0xf000 | (q - program_info_length_ptr - 2);
program_info_length_ptr[0] = val >> 8;
program_info_length_ptr[1] = val;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
MpegTSWriteStream *ts_st = st->priv_data;
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
switch (st->codec->codec_id) {
case AV_CODEC_ID_MPEG1VIDEO:
case AV_CODEC_ID_MPEG2VIDEO:
stream_type = STREAM_TYPE_VIDEO_MPEG2;
break;
case AV_CODEC_ID_MPEG4:
stream_type = STREAM_TYPE_VIDEO_MPEG4;
break;
case AV_CODEC_ID_H264:
stream_type = STREAM_TYPE_VIDEO_H264;
break;
case AV_CODEC_ID_HEVC:
stream_type = STREAM_TYPE_VIDEO_HEVC;
break;
case AV_CODEC_ID_CAVS:
stream_type = STREAM_TYPE_VIDEO_CAVS;
break;
case AV_CODEC_ID_DIRAC:
stream_type = STREAM_TYPE_VIDEO_DIRAC;
break;
case AV_CODEC_ID_MP2:
case AV_CODEC_ID_MP3:
stream_type = STREAM_TYPE_AUDIO_MPEG1;
break;
case AV_CODEC_ID_AAC:
stream_type = (ts->flags & MPEGTS_FLAG_AAC_LATM)
? STREAM_TYPE_AUDIO_AAC_LATM
: STREAM_TYPE_AUDIO_AAC;
break;
case AV_CODEC_ID_AAC_LATM:
stream_type = STREAM_TYPE_AUDIO_AAC_LATM;
break;
case AV_CODEC_ID_AC3:
stream_type = STREAM_TYPE_AUDIO_AC3;
break;
default:
stream_type = STREAM_TYPE_PRIVATE_DATA;
break;
}
*q++ = stream_type;
put16(&q, 0xe000 | ts_st->pid);
desc_length_ptr = q;
q += 2;
switch (st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if (lang) {
char *p;
char *next = lang->value;
uint8_t *len_ptr;
*q++ = 0x0a;
len_ptr = q++;
*len_ptr = 0;
for (p = lang->value; next && *len_ptr < 255 / 4 * 4; p = next + 1) {
next = strchr(p, ',');
if (strlen(p) != 3 && (!next || next != p + 3))
continue;
*q++ = *p++;
*q++ = *p++;
*q++ = *p++;
if (st->disposition & AV_DISPOSITION_CLEAN_EFFECTS)
*q++ = 0x01;
else if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED)
*q++ = 0x02;
else if (st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED)
*q++ = 0x03;
else
*q++ = 0;
*len_ptr += 4;
}
if (*len_ptr == 0)
q -= 2;
}
break;
case AVMEDIA_TYPE_SUBTITLE:
{
const char *language;
language = lang && strlen(lang->value) == 3 ? lang->value : "eng";
*q++ = 0x59;
*q++ = 8;
*q++ = language[0];
*q++ = language[1];
*q++ = language[2];
*q++ = 0x10;
if (st->codec->extradata_size == 4) {
memcpy(q, st->codec->extradata, 4);
q += 4;
} else {
put16(&q, 1);
put16(&q, 1);
}
}
break;
case AVMEDIA_TYPE_VIDEO:
if (stream_type == STREAM_TYPE_VIDEO_DIRAC) {
*q++ = 0x05;
*q++ = 4;
*q++ = 'd';
*q++ = 'r';
*q++ = 'a';
*q++ = 'c';
}
break;
}
val = 0xf000 | (q - desc_length_ptr - 2);
desc_length_ptr[0] = val >> 8;
desc_length_ptr[1] = val;
}
mpegts_write_section1(&service->pmt, PMT_TID, service->sid, 0, 0, 0,
data, q - data);
}
| 1threat
|
Content beneath fixed AppBar : <p>Probably a basic question, but I couldn't find any example in the documentation. Using <code>material-ui-next</code> <em>beta.30</em>. I have the following:</p>
<pre><code>import * as React from 'react';
import * as ReactDOM from 'react-dom';
import * as mui from 'material-ui';
import 'typeface-roboto';
function App() {
return (
<div>
<mui.Reboot />
<mui.AppBar color="primary" position="fixed">
<mui.Toolbar>
<mui.Typography color="inherit" type="title">
My Title
</mui.Typography>
</mui.Toolbar>
</mui.AppBar>
<mui.Paper>
My Content
</mui.Paper>
</div>
);
}
ReactDOM.render(
<App />,
document.getElementById('container')
);
</code></pre>
<p>And I want the <code>mui.Paper</code> content appear <em>beneath</em> the <em>AppBar</em>, and not hidden by it. Is there a component I'm missing somewhere?</p>
| 0debug
|
Setting text to a TextView in Fragment A after adding and removing Fragment B : <p>I have fragment A, on TextView click I add another Fragment B, I want to update the TextView of Fragment A when I remove Fragment B, any ideas on how to do that?</p>
| 0debug
|
static int ff_asf_parse_packet(AVFormatContext *s, ByteIOContext *pb, AVPacket *pkt)
{
ASFContext *asf = s->priv_data;
ASFStream *asf_st = 0;
for (;;) {
if(url_feof(pb))
return AVERROR_EOF;
if (asf->packet_size_left < FRAME_HEADER_SIZE
|| asf->packet_segments < 1) {
int ret = asf->packet_size_left + asf->packet_padsize;
assert(ret>=0);
url_fskip(pb, ret);
asf->packet_pos= url_ftell(pb);
if (asf->data_object_size != (uint64_t)-1 &&
(asf->packet_pos - asf->data_object_offset >= asf->data_object_size))
return AVERROR_EOF;
return 1;
}
if (asf->packet_time_start == 0) {
if(asf_read_frame_header(s, pb) < 0){
asf->packet_segments= 0;
continue;
}
if (asf->stream_index < 0
|| s->streams[asf->stream_index]->discard >= AVDISCARD_ALL
|| (!asf->packet_key_frame && s->streams[asf->stream_index]->discard >= AVDISCARD_NONKEY)
) {
asf->packet_time_start = 0;
url_fskip(pb, asf->packet_frag_size);
asf->packet_size_left -= asf->packet_frag_size;
if(asf->stream_index < 0)
av_log(s, AV_LOG_ERROR, "ff asf skip %d (unknown stream)\n", asf->packet_frag_size);
continue;
}
asf->asf_st = s->streams[asf->stream_index]->priv_data;
}
asf_st = asf->asf_st;
if (asf->packet_replic_size == 1) {
asf->packet_frag_timestamp = asf->packet_time_start;
asf->packet_time_start += asf->packet_time_delta;
asf->packet_obj_size = asf->packet_frag_size = get_byte(pb);
asf->packet_size_left--;
asf->packet_multi_size--;
if (asf->packet_multi_size < asf->packet_obj_size)
{
asf->packet_time_start = 0;
url_fskip(pb, asf->packet_multi_size);
asf->packet_size_left -= asf->packet_multi_size;
continue;
}
asf->packet_multi_size -= asf->packet_obj_size;
}
if(
asf_st->frag_offset + asf->packet_frag_size <= asf_st->pkt.size
&& asf_st->frag_offset + asf->packet_frag_size > asf->packet_obj_size){
av_log(s, AV_LOG_INFO, "ignoring invalid packet_obj_size (%d %d %d %d)\n",
asf_st->frag_offset, asf->packet_frag_size,
asf->packet_obj_size, asf_st->pkt.size);
asf->packet_obj_size= asf_st->pkt.size;
}
if ( asf_st->pkt.size != asf->packet_obj_size
|| asf_st->frag_offset + asf->packet_frag_size > asf_st->pkt.size) {
if(asf_st->pkt.data){
av_log(s, AV_LOG_INFO, "freeing incomplete packet size %d, new %d\n", asf_st->pkt.size, asf->packet_obj_size);
asf_st->frag_offset = 0;
av_free_packet(&asf_st->pkt);
}
av_new_packet(&asf_st->pkt, asf->packet_obj_size);
asf_st->seq = asf->packet_seq;
asf_st->pkt.dts = asf->packet_frag_timestamp;
asf_st->pkt.stream_index = asf->stream_index;
asf_st->pkt.pos =
asf_st->packet_pos= asf->packet_pos;
if (s->streams[asf->stream_index]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
asf->packet_key_frame = 1;
if (asf->packet_key_frame)
asf_st->pkt.flags |= AV_PKT_FLAG_KEY;
}
asf->packet_size_left -= asf->packet_frag_size;
if (asf->packet_size_left < 0)
continue;
if( asf->packet_frag_offset >= asf_st->pkt.size
|| asf->packet_frag_size > asf_st->pkt.size - asf->packet_frag_offset){
av_log(s, AV_LOG_ERROR, "packet fragment position invalid %u,%u not in %u\n",
asf->packet_frag_offset, asf->packet_frag_size, asf_st->pkt.size);
continue;
}
get_buffer(pb, asf_st->pkt.data + asf->packet_frag_offset,
asf->packet_frag_size);
if (s->key && s->keylen == 20)
ff_asfcrypt_dec(s->key, asf_st->pkt.data + asf->packet_frag_offset,
asf->packet_frag_size);
asf_st->frag_offset += asf->packet_frag_size;
if (asf_st->frag_offset == asf_st->pkt.size) {
if( s->streams[asf->stream_index]->codec->codec_id == CODEC_ID_MPEG2VIDEO
&& asf_st->pkt.size > 100){
int i;
for(i=0; i<asf_st->pkt.size && !asf_st->pkt.data[i]; i++);
if(i == asf_st->pkt.size){
av_log(s, AV_LOG_DEBUG, "discarding ms fart\n");
asf_st->frag_offset = 0;
av_free_packet(&asf_st->pkt);
continue;
}
}
if (asf_st->ds_span > 1) {
if(asf_st->pkt.size != asf_st->ds_packet_size * asf_st->ds_span){
av_log(s, AV_LOG_ERROR, "pkt.size != ds_packet_size * ds_span (%d %d %d)\n", asf_st->pkt.size, asf_st->ds_packet_size, asf_st->ds_span);
}else{
uint8_t *newdata = av_malloc(asf_st->pkt.size + FF_INPUT_BUFFER_PADDING_SIZE);
if (newdata) {
int offset = 0;
memset(newdata + asf_st->pkt.size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
while (offset < asf_st->pkt.size) {
int off = offset / asf_st->ds_chunk_size;
int row = off / asf_st->ds_span;
int col = off % asf_st->ds_span;
int idx = row + col * asf_st->ds_packet_size / asf_st->ds_chunk_size;
assert(offset + asf_st->ds_chunk_size <= asf_st->pkt.size);
assert(idx+1 <= asf_st->pkt.size / asf_st->ds_chunk_size);
memcpy(newdata + offset,
asf_st->pkt.data + idx * asf_st->ds_chunk_size,
asf_st->ds_chunk_size);
offset += asf_st->ds_chunk_size;
}
av_free(asf_st->pkt.data);
asf_st->pkt.data = newdata;
}
}
}
asf_st->frag_offset = 0;
*pkt= asf_st->pkt;
asf_st->pkt.size = 0;
asf_st->pkt.data = 0;
break;
}
}
return 0;
}
| 1threat
|
Microsoft.Extensions.Logging Vs. NLog : <p>I see a lot of posts mentioning usage of Microsoft.Extensions.Logging together with NLog. </p>
<p>I'd like to better understand what Microsoft.Extensions.Logging is used for? </p>
<p>And specifically why is it needed or what's the benefit of using it together with NLog?</p>
| 0debug
|
CAN I USE BOTH PYRHON2 AND PYTHON3 TO DEBUG IN PYCHARM : I'v already install python3 in my windows, but recently i need to use python 2 for a project. I created a new environment in my anaconda, but in pycharm I when wanted to debug the python2 code, a problem occured:
*(Connection to Python debugger failed
Socket operation on nonsocket: configure Blocking)*
I can and only can debug python 3 code in pycharm in another environment ,there's no problem, because python3 is in my windows path with a name python(am I right?), and I add python2 to my windows path too, but I renamed it python2 not python to avoid th same path names. Is this the problem why pycharm can't recognize python2 and to debug my python2 code? If it is , how can I solve it to make pycharm can debug both python2 and python3 . Or If it isn't , what's the problem? Thank you guys!!
| 0debug
|
static int update_size(AVCodecContext *ctx, int w, int h, enum AVPixelFormat fmt)
{
VP9Context *s = ctx->priv_data;
uint8_t *p;
int bytesperpixel = s->bytesperpixel;
av_assert0(w > 0 && h > 0);
if (s->intra_pred_data[0] && w == ctx->width && h == ctx->height && ctx->pix_fmt == fmt)
return 0;
ctx->width = w;
ctx->height = h;
ctx->pix_fmt = fmt;
s->sb_cols = (w + 63) >> 6;
s->sb_rows = (h + 63) >> 6;
s->cols = (w + 7) >> 3;
s->rows = (h + 7) >> 3;
#define assign(var, type, n) var = (type) p; p += s->sb_cols * (n) * sizeof(*var)
av_freep(&s->intra_pred_data[0]);
p = av_malloc(s->sb_cols * (128 + 192 * bytesperpixel +
sizeof(*s->lflvl) + 16 * sizeof(*s->above_mv_ctx)));
if (!p)
return AVERROR(ENOMEM);
assign(s->intra_pred_data[0], uint8_t *, 64 * bytesperpixel);
assign(s->intra_pred_data[1], uint8_t *, 64 * bytesperpixel);
assign(s->intra_pred_data[2], uint8_t *, 64 * bytesperpixel);
assign(s->above_y_nnz_ctx, uint8_t *, 16);
assign(s->above_mode_ctx, uint8_t *, 16);
assign(s->above_mv_ctx, VP56mv(*)[2], 16);
assign(s->above_uv_nnz_ctx[0], uint8_t *, 16);
assign(s->above_uv_nnz_ctx[1], uint8_t *, 16);
assign(s->above_partition_ctx, uint8_t *, 8);
assign(s->above_skip_ctx, uint8_t *, 8);
assign(s->above_txfm_ctx, uint8_t *, 8);
assign(s->above_segpred_ctx, uint8_t *, 8);
assign(s->above_intra_ctx, uint8_t *, 8);
assign(s->above_comp_ctx, uint8_t *, 8);
assign(s->above_ref_ctx, uint8_t *, 8);
assign(s->above_filter_ctx, uint8_t *, 8);
assign(s->lflvl, struct VP9Filter *, 1);
#undef assign
av_freep(&s->b_base);
av_freep(&s->block_base);
if (s->bpp != s->last_bpp) {
ff_vp9dsp_init(&s->dsp, s->bpp);
ff_videodsp_init(&s->vdsp, s->bpp);
s->last_bpp = s->bpp;
}
return 0;
}
| 1threat
|
Data massaging in json response : <p>I have written the following code for in angular for a $http get service call</p>
<pre><code> var country = "http://localhost:3000/json/country.json";
$http.get(timeZoneUrl).then(function (response) {
$ctrl.timezone = response.data;
console.log(response.data);
});
</code></pre>
<p>Everything works fine and i am getting response as below.</p>
<pre><code> [{
"region": "Africa",
"country": "South Africa"
},
{
"region": "Europe",
"country": "Spain"
}];
</code></pre>
<p>I would like to have the json response massaged and to update the key from the UI. i want the response to be in the following format</p>
<pre><code> [{
"value": "Africa",
"label": "South Africa"
},
{
"value": "Europe",
"label": "Spain"
}];
</code></pre>
| 0debug
|
es6 - import all named module without alias : <p>I know that we can import all named modules with alias as below, </p>
<pre><code>import * as name from "module-name";
</code></pre>
<p>Ref: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import" rel="noreferrer">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import</a></p>
<p>Actually, I have re-exported my modules in A.js and the same is inherited in B.js. PFB. Now, it's two level of inheritance, so it's not a big deal to import the named modules. But, when I'm taking this to 5 level of inheritance (A -> B -> C -> D -> E), I need to import all named modules in all files and need to do the (re)export the same in all. Instead of doing this, </p>
<ul>
<li>Is there any other way to copy scope of all named modules into all level without reiterating the wheel (Import and Export)</li>
<li>Behind the scene of this design is to make them to follow Opps concept and to avoid the redeclaration of the same modules.</li>
</ul>
<p><strong>A.js</strong> </p>
<pre><code>import React from 'react';
import I18n from 'i18n-js';
import m1 from 'module1';
import m2 from 'module2';
export default class A extends React.Component {}
export {React, I18n, m1, m2)
</code></pre>
<p><strong>B.js</strong></p>
<pre><code>import BaseComponent from './A';
import {React, I18n, m1, m2) from './A;
export default class B extends A {}
</code></pre>
<p>Is there any way to import all named modules without alias like <code>import {*} from './A'</code> (instead of 2nd in B.js) </p>
| 0debug
|
Json data reading using jquery : <p>how can i get the value of User[keywords][] using jquery ? i tried to get like console.log(User[keywords]); but it does not work</p>
<pre><code>{
"User[firstName]": "",
"User[lastName]": "",
"User[city]": "",
"User[countryCode]": "",
"User[gender]": "",
"User[userType]": "",
"User[zip]": "",
"User[email]": "",
"User[age]": "",
"User[fullAddress]": "",
"CustomValue[11][fieldValue]": "",
"CustomValue[5][fieldValue]": "",
"CustomValue[1][fieldValue]": "",
"CustomValue[6][fieldValue]": "",
"CustomValue[7][fieldValue]": "",
"CustomValue[2][fieldValue]": "",
"CustomValue[8][fieldValue]": "",
"CustomValue[9][fieldValue]": "",
"CustomValue[4][fieldValue]": "",
"CustomValue[10][fieldValue]": "",
"CustomValue[3][fieldValue]": "",
"User[teams][]": null,
"": "",
"User[keywords][]": [
"52",
"53",
"54"
],
"User[searchType]": "1",
"User[keywordsExclude][]": null,
"User[id]": "",
"yt1": ""
}
</code></pre>
| 0debug
|
SQL - structure query language : I have this table
SECTION
Which consist of feild called
Semester
2
1
1
1
2
1
1
2
2
2
1
2
I need sql to count how many 1's and how many 2's are there
And out put like this
semester 1 | semester 2
6 | 6
| 0debug
|
What's the command to "reset" a bokeh plot? : <p>I have a bokeh figure that has a reset button in the toolbar. Basically, I want to "reset" the figure when I update the data that I'm plotting in the figure. How can I do that?</p>
| 0debug
|
The JSON sent by firebase is invalid : { name: 'anonymous', text: 'Hello' }
{ name: 'anonymous', text: 'How are you' }
{ name: 'anonymous', text: 'I am fine' }
This code is returned by firebase, and I'm getting the error "No JSON object could be decoded". I think this has to do something with the validity of json format.
<br>
I'm getting this json data using the firebase node.js SDK. Then I'm passig it to python using pyshell. When I use the `json.loads` in python. It says :<br><br>
C:\Python27>node firebase2.js
{ name: 'anonymous', text: 'Hello' }
{ name: 'anonymous', text: 'How are you' }
{ name: 'anonymous', text: 'I am fine' }
C:\Python27\firebase2.js:40
if (err) throw err;
^
Error: ValueError: No JSON object could be decoded
at PythonShell.parseError (C:\Python27\node_modules\python-shell\index.js:183:17)
at terminateIfNeeded (C:\Python27\node_modules\python-shell\index.js:98:28)
at ChildProcess.<anonymous> (C:\Python27\node_modules\python-shell\index.js:88:9)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
----- Python Traceback -----
File "my_script.py", line 3, in <module>
myjson = json.loads(myinput)
File "C:\Python27\lib\json\__init__.py", line 339, in loads
return _default_decoder.decode(s)
File "C:\Python27\lib\json\decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Python27\lib\json\decoder.py", line 382, in raw_decode
raise ValueError("No JSON object could be decoded")
| 0debug
|
how to calculate circumference when given the diameter : I have to write a code that will give me the circumference when I am given the diameter of 2 meters
My code is written like this:
Sub WorksheetFunctionDemo3()
Debug.Print WorksheetFunction. Pi(2)
End sub
but it is coming up with an error. I know without the (2) it'll give me the value of pi, but i can't figure out how to multiply it by 2
| 0debug
|
Kotlin - Form feed character - Illegal escape: '\f' : <p><code>Kotlin</code> does not support the escape <code>"\f"</code> (Form Feed Character). So what is the proper way port <code>"\f"</code> from <code>java</code> to <code>Kotlin</code>? </p>
<p>Java: </p>
<pre><code>String str = "\f"; // OK
</code></pre>
<p>Kotlin:</p>
<pre><code>var str = "\f" // Illegal escape: '\f'
</code></pre>
<p>Anyway, that looked like a bug to me because Kotlin and java should work well together. </p>
| 0debug
|
Can you change .git folder location : <p>All git repos create .git folder inside working directory can you change this folder location.</p>
| 0debug
|
How to exclude/disable a specific auto-configuration in Spring boot 1.4.0 for @DataJpaTest? : <p>I am using the @DataJpaTest from Spring for my test which will then use H2 as in memory database as <a href="https://spring.io/blog/2016/04/15/testing-improvements-in-spring-boot-1-4#testing-the-jpa-slice" rel="noreferrer">described here</a> . I'm also using Flyway for production. However once the test starts FLyway kicks in and reads the SQL file. How can I exclude the FlywayAutoConfiguration and keep the rest as described <a href="http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#test-auto-configuration" rel="noreferrer">here in spring documentation</a> in order to let Hibernate create the tables in H2 for me? </p>
<pre><code>@RunWith(SpringRunner.class)
@DataJpaTest
public class MyRepositoryTest {
@Autowired
private TestEntityManager entityManager;
@Autowired
private MyRepository triggerRepository;
}
</code></pre>
| 0debug
|
Chrome Service Worker iOS Support : <p>As Apple announced Service Worker support for iOS 11.3 a few months ago, I recently started trying to get a service worker to work on iOS. On Safari it works as expected, after vising the website, it works offline. However, when trying to use the same feature in Chrome, I had intermittent results. Specifically, the service worker would only work every other page refresh, with the original refresh after going offline being one of the ones <strong>not</strong> working.</p>
<p>I know that Chrome on iOS is built on a version of Safari, therefore I am confused about this behavior.</p>
<p>Is this due to incomplete support from Chrome iOS for Service Workers? Because it is Chrome on iOS, I'm not sure of any easy way to debug it either, so any other tips to help track down the problem would be appreciated. Thank you!</p>
| 0debug
|
static int decode_mb_info(IVI5DecContext *ctx, IVIBandDesc *band,
IVITile *tile, AVCodecContext *avctx)
{
int x, y, mv_x, mv_y, mv_delta, offs, mb_offset,
mv_scale, blks_per_mb;
IVIMbInfo *mb, *ref_mb;
int row_offset = band->mb_size * band->pitch;
mb = tile->mbs;
ref_mb = tile->ref_mbs;
offs = tile->ypos * band->pitch + tile->xpos;
if (!ref_mb &&
((band->qdelta_present && band->inherit_qdelta) || band->inherit_mv))
return AVERROR_INVALIDDATA;
mv_scale = (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3);
mv_x = mv_y = 0;
for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {
mb_offset = offs;
for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {
mb->xpos = x;
mb->ypos = y;
mb->buf_offs = mb_offset;
if (get_bits1(&ctx->gb)) {
if (ctx->frame_type == FRAMETYPE_INTRA) {
av_log(avctx, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n");
return -1;
}
mb->type = 1;
mb->cbp = 0;
mb->q_delta = 0;
if (!band->plane && !band->band_num && (ctx->frame_flags & 8)) {
mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
}
mb->mv_x = mb->mv_y = 0;
if (band->inherit_mv && ref_mb){
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
} else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
}
}
} else {
if (band->inherit_mv && ref_mb) {
mb->type = ref_mb->type;
} else if (ctx->frame_type == FRAMETYPE_INTRA) {
mb->type = 0;
} else {
mb->type = get_bits1(&ctx->gb);
}
blks_per_mb = band->mb_size != band->blk_size ? 4 : 1;
mb->cbp = get_bits(&ctx->gb, blks_per_mb);
mb->q_delta = 0;
if (band->qdelta_present) {
if (band->inherit_qdelta) {
if (ref_mb) mb->q_delta = ref_mb->q_delta;
} else if (mb->cbp || (!band->plane && !band->band_num &&
(ctx->frame_flags & 8))) {
mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
}
}
if (!mb->type) {
mb->mv_x = mb->mv_y = 0;
} else {
if (band->inherit_mv && ref_mb){
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
} else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
}
} else {
mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mv_y += IVI_TOSIGNED(mv_delta);
mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mv_x += IVI_TOSIGNED(mv_delta);
mb->mv_x = mv_x;
mb->mv_y = mv_y;
}
}
}
mb++;
if (ref_mb)
ref_mb++;
mb_offset += band->mb_size;
}
offs += row_offset;
}
align_get_bits(&ctx->gb);
return 0;
}
| 1threat
|
Stop Pulse Secure from opening at startup Mac : <p>I have installed Pulse Secure VPN utility version 5.2.5 and it automatically opens at startup. Unfortunately, the app doesn't behave like any other, i.e., I cannot disable it through:</p>
<pre><code>System Preferences → Users & Groups → Login Items
</code></pre>
<p>I've done some research on the Internet and I found that the file that is responsible for the startup opening is:</p>
<pre><code>/Library/LaunchAgents/net.pulsesecure.pulsetray.plist
</code></pre>
<p>If I delete the file, Pulse Secure doesn't open at startup, but whenever I open it, it won't work as expected (won't connect to any VPN).</p>
<p>Does anyone know how to prevent it from opening at startup AND make it work at the same time?</p>
<p>I attach the content of the file if it's of some aid:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>net.pulsesecure.pulsetray</string>
<key>LimitLoadToSessionType</key>
<array>
<string>Aqua</string>
</array>
<key>ProgramArguments</key>
<array>
<string>/Applications/Pulse Secure.app/Contents/Plugins/JamUI/PulseTray.app/Contents/MacOS/PulseTray</string>
</array>
<key>KeepAlive</key>
<true/>
<key>Disabled</key>
<false/>
</dict>
</plist>
</code></pre>
| 0debug
|
How to do a git commit with a subject line and message body? : <p>I want to improve the way I do git commits and I've been reading around the web. I followed the site here <a href="http://chris.beams.io/posts/git-commit/" rel="noreferrer">http://chris.beams.io/posts/git-commit/</a> and this lead me to <a href="https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration" rel="noreferrer">https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration</a> where I can set my default editor, but I still don't understand how I edit the subject line separately from the body of the commit.</p>
<p>I'm used to doing:</p>
<pre><code>git commit -am "message here"
</code></pre>
<p>but as I understand it for longer commits, I should use an editor like vim (on my mac)</p>
| 0debug
|
Pipe a stream to s3.upload() : <p>I'm currently making use of a node.js plugin called <a href="https://github.com/nathanpeck/s3-upload-stream">s3-upload-stream</a> to stream very large files to Amazon S3. It uses the multipart API and for the most part it works very well.</p>
<p>However, this module is showing its age and I've already had to make modifications to it (the author has deprecated it as well). Today I ran into another issue with Amazon, and I would really like to take the author's recommendation and start using the official aws-sdk to accomplish my uploads.</p>
<p>BUT.</p>
<p>The official SDK does not seem to support piping to <code>s3.upload()</code>. The nature of s3.upload is that you have to pass the readable stream as an argument to the S3 constructor.</p>
<p>I have roughly 120+ user code modules that do various file processing, and they are agnostic to the final destination of their output. The engine hands them a pipeable writeable output stream, and they pipe to it. I cannot hand them an <code>AWS.S3</code> object and ask them to call <code>upload()</code> on it without adding code to all the modules. The reason I used <code>s3-upload-stream</code> was because it supported piping.</p>
<p>Is there a way to make aws-sdk <code>s3.upload()</code> something I can pipe the stream to?</p>
| 0debug
|
How to save folder of images to iOS app : <p>I have a folder in my computer which contains 223 png files, representing country flags. Which would be the most recommended way to store them inside an iOS app? I am thinking about dragging the folder to the app location inside xcodeproject but I have no idea on how to access it through code? Are there any recommendations, official way of how one should do it?</p>
| 0debug
|
how to get list of apps with detail (icon,display name,etc..) installed on iphone device ios 9 programmatically : i want to get all installed app icon and it's detail perameter how can i get it and open that app via my app page.
i can get list of installed app using this code
-------------------------------
Class LSApplicationWorkspace_class = objc_getClass("LSApplicationWorkspace");
NSObject* workspace = [LSApplicationWorkspace_class performSelector:NSSelectorFromString(@"defaultWorkspace")];
NSMutableArray *array = [workspace performSelector:NSSelectorFromString(@"allApplications")];
NSMutableArray *Applist = [[NSMutableArray alloc] init];
for (id lsApplicationProxy in array) {
if(nil != [lsApplicationProxy performSelector:NSSelectorFromString(@"itemName")]){
[Applist addObject:[lsApplicationProxy performSelector:NSSelectorFromString(@"itemName")]];
}
}
NSLog(@" Applications List : \n %@",Applist);
| 0debug
|
What type of weather chart is this? : <p>I like the look of this chart for weather data but I do not know the name of the chart type.</p>
<p>I may try to render my own version but I would like to know if any chart libraries (Javscript Based) support it but I need to know its name.</p>
<p>Maybe someone has written it for D3.js ?</p>
<p><a href="https://i.stack.imgur.com/Imvb6.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Imvb6.jpg" alt="enter image description here"></a></p>
| 0debug
|
void acpi_build(AcpiBuildTables *tables)
{
PCMachineState *pcms = PC_MACHINE(qdev_get_machine());
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
GArray *table_offsets;
unsigned facs, dsdt, rsdt, fadt;
AcpiCpuInfo cpu;
AcpiPmInfo pm;
AcpiMiscInfo misc;
AcpiMcfgInfo mcfg;
PcPciInfo pci;
uint8_t *u;
size_t aml_len = 0;
GArray *tables_blob = tables->table_data;
AcpiSlicOem slic_oem = { .id = NULL, .table_id = NULL };
acpi_get_cpu_info(&cpu);
acpi_get_pm_info(&pm);
acpi_get_misc_info(&misc);
acpi_get_pci_info(&pci);
acpi_get_slic_oem(&slic_oem);
table_offsets = g_array_new(false, true ,
sizeof(uint32_t));
ACPI_BUILD_DPRINTF("init ACPI tables\n");
bios_linker_loader_alloc(tables->linker, ACPI_BUILD_TABLE_FILE,
64 ,
false );
facs = tables_blob->len;
build_facs(tables_blob, tables->linker);
dsdt = tables_blob->len;
build_dsdt(tables_blob, tables->linker, &cpu, &pm, &misc, &pci);
aml_len += tables_blob->len - dsdt;
fadt = tables_blob->len;
acpi_add_table(table_offsets, tables_blob);
build_fadt(tables_blob, tables->linker, &pm, facs, dsdt,
slic_oem.id, slic_oem.table_id);
aml_len += tables_blob->len - fadt;
acpi_add_table(table_offsets, tables_blob);
build_madt(tables_blob, tables->linker, &cpu);
if (misc.has_hpet) {
acpi_add_table(table_offsets, tables_blob);
build_hpet(tables_blob, tables->linker);
}
if (misc.tpm_version != TPM_VERSION_UNSPEC) {
acpi_add_table(table_offsets, tables_blob);
build_tpm_tcpa(tables_blob, tables->linker, tables->tcpalog);
if (misc.tpm_version == TPM_VERSION_2_0) {
acpi_add_table(table_offsets, tables_blob);
build_tpm2(tables_blob, tables->linker);
}
}
if (pcms->numa_nodes) {
acpi_add_table(table_offsets, tables_blob);
build_srat(tables_blob, tables->linker);
}
if (acpi_get_mcfg(&mcfg)) {
acpi_add_table(table_offsets, tables_blob);
build_mcfg_q35(tables_blob, tables->linker, &mcfg);
}
if (acpi_has_iommu()) {
acpi_add_table(table_offsets, tables_blob);
build_dmar_q35(tables_blob, tables->linker);
}
if (acpi_has_nvdimm()) {
nvdimm_build_acpi(table_offsets, tables_blob, tables->linker);
}
for (u = acpi_table_first(); u; u = acpi_table_next(u)) {
unsigned len = acpi_table_len(u);
acpi_add_table(table_offsets, tables_blob);
g_array_append_vals(tables_blob, u, len);
}
rsdt = tables_blob->len;
build_rsdt(tables_blob, tables->linker, table_offsets,
slic_oem.id, slic_oem.table_id);
build_rsdp(tables->rsdp, tables->linker, rsdt);
if (pcmc->legacy_acpi_table_size) {
int legacy_aml_len =
pcmc->legacy_acpi_table_size +
ACPI_BUILD_LEGACY_CPU_AML_SIZE * max_cpus;
int legacy_table_size =
ROUND_UP(tables_blob->len - aml_len + legacy_aml_len,
ACPI_BUILD_ALIGN_SIZE);
if (tables_blob->len > legacy_table_size) {
error_report("Warning: migration may not work.");
}
g_array_set_size(tables_blob, legacy_table_size);
} else {
if (tables_blob->len > ACPI_BUILD_TABLE_SIZE / 2) {
error_report("Warning: ACPI tables are larger than 64k.");
error_report("Warning: migration may not work.");
error_report("Warning: please remove CPUs, NUMA nodes, "
"memory slots or PCI bridges.");
}
acpi_align_size(tables_blob, ACPI_BUILD_TABLE_SIZE);
}
acpi_align_size(tables->linker, ACPI_BUILD_ALIGN_SIZE);
g_array_free(table_offsets, true);
}
| 1threat
|
static int vnc_start_vencrypt_handshake(VncState *vs)
{
int ret;
if ((ret = gnutls_handshake(vs->tls.session)) < 0) {
if (!gnutls_error_is_fatal(ret)) {
VNC_DEBUG("Handshake interrupted (blocking)\n");
if (!gnutls_record_get_direction(vs->tls.session))
qemu_set_fd_handler(vs->csock, vnc_tls_handshake_io, NULL, vs);
else
qemu_set_fd_handler(vs->csock, NULL, vnc_tls_handshake_io, vs);
return 0;
}
VNC_DEBUG("Handshake failed %s\n", gnutls_strerror(ret));
vnc_client_error(vs);
return -1;
}
if (vs->vd->tls.x509verify) {
if (vnc_tls_validate_certificate(vs) < 0) {
VNC_DEBUG("Client verification failed\n");
vnc_client_error(vs);
return -1;
} else {
VNC_DEBUG("Client verification passed\n");
}
}
VNC_DEBUG("Handshake done, switching to TLS data mode\n");
qemu_set_fd_handler(vs->csock, vnc_client_read, vnc_client_write, vs);
start_auth_vencrypt_subauth(vs);
return 0;
}
| 1threat
|
sharedpreferences is not saving or loading my data android .please help thanks : here is my savaData and loadData method which is used to save and laod data
public void saveData(){
SharedPreferences sharedPreferences= getActivity().getSharedPreferences("SubjectTitle", Context.MODE_PRIVATE);
SharedPreferences.Editor editor=sharedPreferences.edit();
int i=0,n;
n=addArray.size();
for(Bunk b: addArray) {
editor.putString("Title"+i, b.getTitle());
editor.putInt("No_of_bunk"+i, b.getBunk_remain());
editor.putFloat("pre_of_att"+i, b.getPrecentageAtt());
i++;
}
editor.putInt("size_of_data",n);
editor.apply();
Toast.makeText(getActivity(),"data saved",Toast.LENGTH_SHORT).show();
}
public ArrayList<Bunk> loadData(){
SharedPreferences sharedPreferences= getActivity().getSharedPreferences("SubjectTitle", Context.MODE_PRIVATE);
int n=sharedPreferences.getInt("size_pf_data",Default);
String loadTitle;
int loadBunk;
float loadAtt;
for(int i=0;i<n;i++){
loadTitle=sharedPreferences.getString("Title"+i,DEFAULT);
loadBunk=sharedPreferences.getInt("No_of_bunk"+i,Default);
loadAtt=sharedPreferences.getFloat("pre_of_att"+i,def_ault);
addArray.add(new Bunk(loadTitle,loadBunk,loadAtt));
}
return addArray;
}
here is code which is used to load data from loadData method
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup perent, Bundle savedInstanceState) {
super.onCreateView(inflater, perent, savedInstanceState);
View v = inflater.inflate(R.layout.fragment_main, perent, false);
show=(ListView)v.findViewById(android.R.id.list);
addArray=loadData();
adapter=new BunkAdapter(addArray);
show.setAdapter(adapter);
return v;
}
| 0debug
|
How to make a variable from django server clickable and open to new tab : <pre><code><td>{{variable.atr}}</td>
</code></pre>
<p>How to make above element clickable and open new tab? Thanks</p>
| 0debug
|
int av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
{
BufferSinkContext *buf = ctx->priv;
AVFilterLink *inlink = ctx->inputs[0];
int ret;
AVFrame *cur_frame;
if (!av_fifo_size(buf->fifo)) {
if (flags & AV_BUFFERSINK_FLAG_NO_REQUEST)
return AVERROR(EAGAIN);
if ((ret = ff_request_frame(inlink)) < 0)
return ret;
}
if (!av_fifo_size(buf->fifo))
return AVERROR(EINVAL);
if (flags & AV_BUFFERSINK_FLAG_PEEK) {
cur_frame = *((AVFrame **)av_fifo_peek2(buf->fifo, 0));
av_frame_ref(frame, cur_frame);
} else {
av_fifo_generic_read(buf->fifo, &cur_frame, sizeof(cur_frame), NULL);
av_frame_move_ref(frame, cur_frame);
av_frame_free(&cur_frame);
}
return 0;
}
| 1threat
|
How to create anchor tags with Vue Router : <p>I am creating a small <a href="http://vuejs.org/" rel="noreferrer">Vue</a> webapp, I want to create an anchor tag in this.</p>
<p>I have given an <code>id</code> to one of the <code>div</code> I wanted to have anchor tags like this:</p>
<pre><code><div id="for-home">
....
</div>
</code></pre>
<p>And here is my router configuration: </p>
<pre><code>export default new Router({
abstract: true,
mode: 'history',
scrollBehavior: () => ({ y: 0 }),
routes: [
{ path: '/', component: abcView}
]
})
</code></pre>
<p>But with this anchor tags are sometimes working and sometimes not working, Have I missed something in this?</p>
| 0debug
|
Conventional For Loop vs Enhanced For Loop : <p>This code: </p>
<pre><code>import java.util.*;
import java.io.*;
class TestClass {
public static void main(String args[] ) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int arr[] = new int[n];
for(int i = 0; i < n; i++) arr[i] = sc.nextInt();
for(int i : arr) System.out.println(arr[i]);
}
}
</code></pre>
<p>Outputs: </p>
<pre><code>2
3
4
1
2
</code></pre>
<p>With this Input: </p>
<pre><code>5 1
1 2 3 4 1
</code></pre>
<p>On the other hand
This Code:</p>
<pre><code>import java.util.*;
import java.io.*;
class TestClass {
public static void main(String args[] ) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int arr[] = new int[n];
for(int i = 0; i < n; i++) arr[i] = sc.nextInt();
for(int i = 0; i < n; i++) System.out.println(arr[i]);
}
}
</code></pre>
<p>Outputs:</p>
<pre><code>1
2
3
4
1
</code></pre>
<p>In the first code snippet the foreach loop should print the elements of the array but I don't understand what are those numbers and how those numbers are the elements of that array.</p>
| 0debug
|
static int ac3_parse_bsi(AC3DecodeContext *ctx)
{
ac3_bsi *bsi = &ctx->bsi;
uint32_t *flags = &bsi->flags;
GetBitContext *gb = &ctx->gb;
*flags = 0;
bsi->cmixlev = 0;
bsi->surmixlev = 0;
bsi->dsurmod = 0;
bsi->bsid = get_bits(gb, 5);
if (bsi->bsid > 0x08)
return -1;
bsi->bsmod = get_bits(gb, 3);
bsi->acmod = get_bits(gb, 3);
if (bsi->acmod & 0x01 && bsi->acmod != 0x01)
bsi->cmixlev = get_bits(gb, 2);
if (bsi->acmod & 0x04)
bsi->surmixlev = get_bits(gb, 2);
if (bsi->acmod == 0x02)
bsi->dsurmod = get_bits(gb, 2);
if (get_bits(gb, 1))
*flags |= AC3_BSI_LFEON;
bsi->dialnorm = get_bits(gb, 5);
if (get_bits(gb, 1)) {
*flags |= AC3_BSI_COMPRE;
bsi->compr = get_bits(gb, 5);
}
if (get_bits(gb, 1)) {
*flags |= AC3_BSI_LANGCODE;
bsi->langcod = get_bits(gb, 8);
}
if (get_bits(gb, 1)) {
*flags |= AC3_BSI_AUDPRODIE;
bsi->mixlevel = get_bits(gb, 5);
bsi->roomtyp = get_bits(gb, 2);
}
if (bsi->acmod == 0x00) {
bsi->dialnorm2 = get_bits(gb, 5);
if (get_bits(gb, 1)) {
*flags |= AC3_BSI_COMPR2E;
bsi->compr2 = get_bits(gb, 5);
}
if (get_bits(gb, 1)) {
*flags |= AC3_BSI_LANGCOD2E;
bsi->langcod2 = get_bits(gb, 8);
}
if (get_bits(gb, 1)) {
*flags |= AC3_BSI_AUDPRODIE;
bsi->mixlevel2 = get_bits(gb, 5);
bsi->roomtyp2 = get_bits(gb, 2);
}
}
if (get_bits(gb, 1))
*flags |= AC3_BSI_COPYRIGHTB;
if (get_bits(gb, 1))
*flags |= AC3_BSI_ORIGBS;
if (get_bits(gb, 1)) {
*flags |= AC3_BSI_TIMECOD1E;
bsi->timecod1 = get_bits(gb, 14);
}
if (get_bits(gb, 1)) {
*flags |= AC3_BSI_TIMECOD2E;
bsi->timecod2 = get_bits(gb, 14);
}
if (get_bits(gb, 1)) {
*flags |= AC3_BSI_ADDBSIE;
bsi->addbsil = get_bits(gb, 6);
do {
get_bits(gb, 8);
} while (bsi->addbsil--);
}
bsi->nfchans = nfchans_tbl[bsi->acmod];
return 0;
}
| 1threat
|
NuGet Package restore failed: Microsoft.Bcl.Build.Tasks.dll used by another process : <blockquote>
<p>NuGet Package restore failed for project MyProject.Application: The
process cannot access the file
'C:\MySolution\packages\Microsoft.Bcl.Build.1.0.21\build/Microsoft.Bcl.Build.Tasks.dll'
because it is being used by another process..</p>
</blockquote>
<p>Any idea how to fix this issue? Thanks.</p>
| 0debug
|
Flatten Javascript / Typescript object array : I have an array of object like below
let list = [
{
'items': [
'item 1',
'item 2'
]
},
{
'items': [
'item 3'
]
}
]
and I want flatten array from this array like below
['item 1','item 2','item 3']
which javascript / typescript function (chaining) I should use so I will get expected output.
I have tried with map function `list.map(i => i.items)` but I got array in array like below
[["item 1","item 2"],["item 3"]]
**NOTE** : I am looking for any existing function / function chaining if available to get expected output. I am not expecting result by any loop.
| 0debug
|
How to find module "fs" in MS Code with TypeScript? : <p>I'm running on a MacBook Air. I installed MS Code as an IDE and also have TypeScript installed.</p>
<p>I have a simple file with just this line:</p>
<pre><code>import fs = require('fs');
</code></pre>
<p>I'm getting a red squiggly under the 'fs' inside the parenthesis and the error message is <code>[ts] Cannot find module 'fs'.</code> The file has a .ts extension. I'm new to JavaScript and to TypeScript, but I was under the impression that <code>fs</code> was a core module, so how could it not be found? How do I fix the problem?</p>
<p>Other things that I tried already:</p>
<ul>
<li>Putting a simple function body in the file and then compiling on the command line with <code>tsc</code>. I get an essentially equivalent error there: <code>error TS2307: Cannot find module 'fs'.</code> </li>
<li>On the command line <code>sudo npm install fs -g</code>. This reports apparent success, but doesn't fix the problem.</li>
</ul>
<p>I poked around SE and the web, but the answers that seemed close all appear to assume that 'fs' is available.</p>
| 0debug
|
How To extract The Content of TinyMCE Text as Html ? : Hello im using TinyMCE ; i just want to extract The Content as Html Tags
so that i can use them else where i have tried many things with no good results at all
How can i Do so?
of if u can tell me away to get to the id's in the java script Cdn or some thing?
i need to finish this asap its the last step of a long long Junior
so that i just can get the content [i want to extract this please ][1]
is there away or its just a dream
[1]: https://i.stack.imgur.com/EoJFk.png
| 0debug
|
void qmp_migrate(const char *uri, bool has_blk, bool blk,
bool has_inc, bool inc, bool has_detach, bool detach,
Error **errp)
{
Error *local_err = NULL;
MigrationState *s = migrate_get_current();
MigrationParams params;
const char *p;
params.blk = has_blk && blk;
params.shared = has_inc && inc;
if (s->state == MIG_STATE_ACTIVE || s->state == MIG_STATE_SETUP ||
s->state == MIG_STATE_CANCELLING) {
error_set(errp, QERR_MIGRATION_ACTIVE);
if (qemu_savevm_state_blocked(errp)) {
if (migration_blockers) {
*errp = error_copy(migration_blockers->data);
s = migrate_init(¶ms);
if (strstart(uri, "tcp:", &p)) {
tcp_start_outgoing_migration(s, p, &local_err);
#ifdef CONFIG_RDMA
} else if (strstart(uri, "rdma:", &p)) {
rdma_start_outgoing_migration(s, p, &local_err);
#endif
#if !defined(WIN32)
} else if (strstart(uri, "exec:", &p)) {
exec_start_outgoing_migration(s, p, &local_err);
} else if (strstart(uri, "unix:", &p)) {
unix_start_outgoing_migration(s, p, &local_err);
} else if (strstart(uri, "fd:", &p)) {
fd_start_outgoing_migration(s, p, &local_err);
#endif
} else {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "uri", "a valid migration protocol");
s->state = MIG_STATE_ERROR;
if (local_err) {
migrate_fd_error(s);
error_propagate(errp, local_err);
| 1threat
|
Generate static Javascript client from Swagger for use in React Native : <p>I'm building a React Native app that will consume an API with Swagger 2.0 definition. I went to Swagger's repo at <a href="https://github.com/swagger-api/swagger-codegen#where-is-javascript" rel="noreferrer">https://github.com/swagger-api/swagger-codegen#where-is-javascript</a> and it points to their Javascript generator at <a href="https://github.com/swagger-api/swagger-js" rel="noreferrer">https://github.com/swagger-api/swagger-js</a>.</p>
<p>The problem is that the generator is dynamic, and since I'll be embedding the client in a mobile app, dynamic generator is not an option. They also say that there's a third party project available at <a href="https://github.com/wcandillon/swagger-js-codegen" rel="noreferrer">https://github.com/wcandillon/swagger-js-codegen</a>, which says that the project is no longer maintained and points back to <a href="https://github.com/swagger-api/swagger-codegen" rel="noreferrer">https://github.com/swagger-api/swagger-codegen</a>. (while that 3rd party generator works, I don't want to use a deprecated tool that might break any time since I'll be updating the API client when new endpoints arrive. And that tool also doesn't generate really good code anyway as it says in its own repo.)</p>
<p>At this point I'm stuck. What is the supported way of generating a static Javascript client from Swagger definition for use in React Native?</p>
| 0debug
|
static int gif_read_header1(GifState *s)
{
ByteIOContext *f = s->f;
uint8_t sig[6];
int ret, v, n;
int has_global_palette;
ret = get_buffer(f, sig, 6);
if (ret != 6)
return -1;
if (memcmp(sig, gif87a_sig, 6) != 0 &&
memcmp(sig, gif89a_sig, 6) != 0)
return -1;
s->transparent_color_index = -1;
s->screen_width = get_le16(f);
s->screen_height = get_le16(f);
if( (unsigned)s->screen_width > 32767
|| (unsigned)s->screen_height > 32767){
av_log(NULL, AV_LOG_ERROR, "picture size too large\n");
return -1;
}
v = get_byte(f);
s->color_resolution = ((v & 0x70) >> 4) + 1;
has_global_palette = (v & 0x80);
s->bits_per_pixel = (v & 0x07) + 1;
s->background_color_index = get_byte(f);
get_byte(f);
#ifdef DEBUG
printf("gif: screen_w=%d screen_h=%d bpp=%d global_palette=%d\n",
s->screen_width, s->screen_height, s->bits_per_pixel,
has_global_palette);
#endif
if (has_global_palette) {
n = 1 << s->bits_per_pixel;
get_buffer(f, s->global_palette, n * 3);
}
return 0;
}
| 1threat
|
How to make an adapter for recycler view through the dataBinding(google)? : <p><strong>I have a recycler and I need an adapter for it. It should work through databinding.</strong></p>
| 0debug
|
Looping over a tensor : <p>I am trying to process a tensor of variable size, in a python way that would be something like:</p>
<pre><code># X is of shape [m, n]
for x in X:
process(x)
</code></pre>
<p>I have tried to use <em>tf.scan</em>, the thing is that I want to process every sub-tensor, so I have tried to use a nested <em>scan</em>, but I was enable to do it, because <em>tf.scan</em> work with the accumulator, if not found it will take the first entry of the <em>elems</em> as initializer, which I don't want to do.
As an example, suppose I want to add one to every element of my tensor (this is just an example), and I want to process it element by element. If I run the code bellow, I will only have one added to a sub-tensor, because <em>scan</em> consider the first tensor as initializer, along with the first element of every sub-tensor.</p>
<pre><code>import numpy as np
import tensorflow as tf
batch_x = np.random.randint(0, 10, size=(5, 10))
x = tf.placeholder(tf.float32, shape=[None, 10])
def inner_loop(x_in):
return tf.scan(lambda _, x_: x_ + 1, x_in)
outer_loop = tf.scan(lambda _, input_: inner_loop(input_), x, back_prop=True)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
rs = sess.run(outer_loop, feed_dict={x: batch_x})
</code></pre>
<p>Any suggestions ?</p>
| 0debug
|
void ppc_hw_interrupt (CPUState *env)
{
env->exception_index = -1;
}
| 1threat
|
fetchmail: benefits of having ssl certificate and fingerprint checking : <p>I am trying to decide on a new e-mail service. I use fetchmail to fetch my e-mail and process it using procmail. Some of the email services (etc. gmx.com, outlook.com, etc) do not seem to require the certificate and the fingerprint checked. Some others, such as inbox.com or gmail.com do. I am wondering if there is a security hole in going from the latter kind to the former. What is the value of the certificate checking?
Sorry that i am not a cryptography guy but I would not like to have a security hole than needed.</p>
<p>Thanks!</p>
| 0debug
|
int do_eject(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
BlockDriverState *bs;
int force = qdict_get_int(qdict, "force");
const char *filename = qdict_get_str(qdict, "device");
bs = bdrv_find(filename);
if (!bs) {
qerror_report(QERR_DEVICE_NOT_FOUND, filename);
return -1;
}
return eject_device(mon, bs, force);
}
| 1threat
|
Haskell, How many elements from one list are present in the other list : I am new to functional programming using Haskell and I can't seem to be able to create a function that takes two lists as arguments and returns how many elements there are common in both lists.
e.g. f [1, 2, 4, 2] [2, 3, 4, 4] returning 2 (repetitions are ignored).
Any suggestions?
| 0debug
|
static void virtio_net_apply_guest_offloads(VirtIONet *n)
{
qemu_peer_set_offload(qemu_get_subqueue(n->nic, 0),
!!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_CSUM)),
!!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_TSO4)),
!!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_TSO6)),
!!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_ECN)),
!!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_UFO)));
}
| 1threat
|
connection.query('SELECT * FROM users WHERE username = ' + input_string)
| 1threat
|
static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
{
PixdescTestContext *priv = inlink->dst->priv;
AVFilterLink *outlink = inlink->dst->outputs[0];
AVFilterBufferRef *outpicref;
int i;
outlink->out_buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,
outlink->w, outlink->h);
outpicref = outlink->out_buf;
avfilter_copy_buffer_ref_props(outpicref, picref);
for (i = 0; i < 4; i++) {
int h = outlink->h;
h = i == 1 || i == 2 ? h>>priv->pix_desc->log2_chroma_h : h;
if (outpicref->data[i]) {
uint8_t *data = outpicref->data[i] +
(outpicref->linesize[i] > 0 ? 0 : outpicref->linesize[i] * (h-1));
memset(data, 0, FFABS(outpicref->linesize[i]) * h);
}
}
if (priv->pix_desc->flags & PIX_FMT_PAL)
memcpy(outpicref->data[1], outpicref->data[1], 256*4);
avfilter_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0));
}
| 1threat
|
how do i make starked barplot in r utilising three columns, i want to use the barplot() function : i want a starked barplot in R with year as my x-axis, percentage as my y-axis, and landuse as a colour fill. my data is given below
Year Percentage LandUse
1 2015 49.8 Agriculture
2 2012 51.2 Agriculture
3 2009 50.2 Agriculture
10 2015 22.5 fishing
11 2012 21.4 fishing
12 2009 21.9 fishing
19 2015 14.7 services and residential
20 2012 16.0 services and residential
21 2009 17.1 services and residential
28 2015 0.8 mining and quarrying
29 2012 0.7 mining and quarrying
30 2009 0.7 mining and quarrying
37 2015 0.4 water and waste treatment
38 2012 0.5 water and waste treatment
39 2009 0.4 water and waste treatment
46 2015 0.8 Industry and Manufacturing
47 2012 0.8 Industry and Manufacturing
48 2009 0.9 Industry and Manufacturing
| 0debug
|
static void balloon_stats_set_poll_interval(Object *obj, struct Visitor *v,
void *opaque, const char *name,
Error **errp)
{
VirtIOBalloon *s = opaque;
Error *local_err = NULL;
int64_t value;
visit_type_int(v, &value, name, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
if (value < 0) {
error_setg(errp, "timer value must be greater than zero");
return;
}
if (value > UINT_MAX) {
error_setg(errp, "timer value is too big");
return;
}
if (value == s->stats_poll_interval) {
return;
}
if (value == 0) {
balloon_stats_destroy_timer(s);
return;
}
if (balloon_stats_enabled(s)) {
s->stats_poll_interval = value;
balloon_stats_change_timer(s, value);
return;
}
g_assert(s->stats_timer == NULL);
s->stats_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, balloon_stats_poll_cb, s);
s->stats_poll_interval = value;
balloon_stats_change_timer(s, 0);
}
| 1threat
|
static int set_boot_dev(ISADevice *s, const char *boot_device)
{
#define PC_MAX_BOOT_DEVICES 3
int nbds, bds[3] = { 0, };
int i;
nbds = strlen(boot_device);
if (nbds > PC_MAX_BOOT_DEVICES) {
error_report("Too many boot devices for PC");
return(1);
}
for (i = 0; i < nbds; i++) {
bds[i] = boot_device2nibble(boot_device[i]);
if (bds[i] == 0) {
error_report("Invalid boot device for PC: '%c'",
boot_device[i]);
return(1);
}
}
rtc_set_memory(s, 0x3d, (bds[1] << 4) | bds[0]);
rtc_set_memory(s, 0x38, (bds[2] << 4) | (fd_bootchk ? 0x0 : 0x1));
return(0);
}
| 1threat
|
Get string characters until number reached : <p>Basically, I want to get the letters of the string from the first character until a number is reached.</p>
<p>Example</p>
<p>Input: asdfblabla2012365adsf</p>
<p>Output: asdfblabla</p>
| 0debug
|
Find the column index by its name in SQL : If I have three columns, 'syscode', 'loc_cod', 'loc_name' but wanted to know that 'loc_name' was 3rd in order, how could I retrieve that with a SQL query?
Using T SQL/SSMS.
| 0debug
|
void rgb16tobgr24(const uint8_t *src, uint8_t *dst, unsigned int src_size)
{
const uint16_t *end;
uint8_t *d = (uint8_t *)dst;
const uint16_t *s = (const uint16_t *)src;
end = s + src_size/2;
while(s < end)
{
register uint16_t bgr;
bgr = *s++;
*d++ = (bgr&0xF800)>>8;
*d++ = (bgr&0x7E0)>>3;
*d++ = (bgr&0x1F)<<3;
}
}
| 1threat
|
static void uninit(struct vf_instance *vf)
{
free(vf->priv);
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.