problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
void monitor_protocol_event(MonitorEvent event, QObject *data)
{
QDict *qmp;
const char *event_name;
Monitor *mon;
assert(event < QEVENT_MAX);
switch (event) {
case QEVENT_DEBUG:
event_name = "DEBUG";
break;
case QEVENT_SHUTDOWN:
event_name = "SHUTDOWN";
break;
case QEVENT_RESET:
event_name = "RESET";
break;
case QEVENT_POWERDOWN:
event_name = "POWERDOWN";
break;
case QEVENT_STOP:
event_name = "STOP";
break;
case QEVENT_VNC_CONNECTED:
event_name = "VNC_CONNECTED";
break;
case QEVENT_VNC_INITIALIZED:
event_name = "VNC_INITIALIZED";
break;
case QEVENT_VNC_DISCONNECTED:
event_name = "VNC_DISCONNECTED";
break;
default:
abort();
break;
}
qmp = qdict_new();
timestamp_put(qmp);
qdict_put(qmp, "event", qstring_from_str(event_name));
if (data) {
qobject_incref(data);
qdict_put_obj(qmp, "data", data);
}
QLIST_FOREACH(mon, &mon_list, entry) {
if (!monitor_ctrl_mode(mon))
return;
monitor_json_emitter(mon, QOBJECT(qmp));
}
QDECREF(qmp);
}
| 1threat
|
Hibernate Unknown integral data type for ids : <p>I'm starting with Hibernate and I have an error that I just can't figure out.</p>
<p>I have the following Classes:</p>
<pre><code>@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class AbstractColumn {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private String id;
private String name;
//Other stuff
}
</code></pre>
<p>Then I have</p>
<pre><code>@Entity
public class DoubleColumn extends AbstractColumn implements Column {
@ElementCollection
private Map<Double,String> isNA;
private double min=0;
private double max=0;
@ElementCollection
private List<Double> data;
// a lot of stuff
}
</code></pre>
<p>And finally:</p>
<pre><code>@Entity
public class DataFrame {
@OneToMany(cascade = CascadeType.ALL)
@PrimaryKeyJoinColumn
private List<AbstractColumn> data;
private String name;
@Id
@GeneratedValue
private String id;
@ElementCollection
private Map<String,Integer> colIndex;
//more stuff
}
</code></pre>
<p>The error I'm getting is:</p>
<pre><code>Exception in thread "main" org.hibernate.id.IdentifierGenerationException: Unknown integral data type for ids : java.lang.String
at org.hibernate.id.IdentifierGeneratorHelper.getIntegralDataTypeHolder(IdentifierGeneratorHelper.java:224)
at org.hibernate.id.enhanced.SequenceStructure$1.getNextValue(SequenceStructure.java:98)
at org.hibernate.id.enhanced.NoopOptimizer.generate(NoopOptimizer.java:40)
at org.hibernate.id.enhanced.SequenceStyleGenerator.generate(SequenceStyleGenerator.java:432)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:105)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:192)
at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:38)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:177)
at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:32)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:73)
at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:675)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:667)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:662)
at Main.main(Main.java:285)
</code></pre>
<p>The only hint that the error throws is that the error is in the main class here:</p>
<pre><code>DoubleColumn c1 = new DoubleColumn("Datos varios");
c1.addData(12);
c1.addData(11);
c1.addData(131);
c1.addData(121);
c1.addData(151);
c1.addData(116);
DataFrame datosHibernate = new DataFrame("Dataframe Hibernate");
datosHibernate.addColumn(c1);
Configuration hibernateConfig = new Configuration();
SessionFactory sessionFactory = hibernateConfig.configure().buildSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
session.save(datosHibernate);
session.getTransaction().commit();
session.disconnect();
session.close();
System.exit(0);
</code></pre>
<p>The ids are Strings, and I have them annotated as @GeneratedValue (I think I do not need to initialize them myself). The relation @OneToMany have the cascade annotation so it should be mapped correctly.</p>
<p>I've tried the code WITHOUT the session.save line and doesn't throw errors, so is not a problem in the code per se, it has to be something with Hibernate.</p>
<p>My configuration file is:</p>
<pre><code><hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:h2:E:/bd;DB_CLOSE_DELAY=-1;MVCC=TRUE</property>
<property name="connection.driver_class">org.h2.Driver</property>
<property name="connection.username">user</property>
<property name="connection.password"></property>
<property name="dialect">org.hibernate.dialect.H2Dialect</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">create</property>
<mapping class="com.dataframe.estructuras.DataFrame"></mapping>
<mapping class="com.dataframe.estructuras.column.AbstractColumn"/>
<mapping class="com.dataframe.estructuras.column.types.DoubleColumn"/>
</session-factory>
</hibernate-configuration>
</code></pre>
<p>It creates the database file and I see all the SQL code generated, tables and all. Is when it tries to store the info when the thing breaks.</p>
| 0debug
|
Is there any free api for live cricket match in android : <p>Hello i beginner in android. I want to develop android app for live cricket score update. Anyone please suggest me how to do this.I want to develop without web app.</p>
| 0debug
|
<?php echo $_POST["name"] ; ?> Why we need Square Bracket here? : <p>Is there any explanation why this " %_ " and "Square Bracket" is used ?
i cant proceed without knowing this,
Thanks in advance .</p>
| 0debug
|
Retrieve array value by index : <p>If I have an array like this:</p>
<pre>
Array
(
[0] => Array
(
[image_path] => 3blocks-02.png
)
[1] => Array
(
[image_path] => 2blocks-02.png
)
)
</pre>
<p>Is there a way I can retrieve the ['image_path'] value by the array index in a forreach loop?</p>
<p>I have tried:</p>
<pre><code>foreach($images as $image)
{
$image[1]
}
and
foreach($images as $image)
{
$image[1]['image_path']
}
</code></pre>
<p>and a key => value loop but I cant seem to get the data</p>
| 0debug
|
static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist)
{
AHCICmdHdr *cmd = ad->cur_cmd;
uint32_t opts = le32_to_cpu(cmd->opts);
uint64_t prdt_addr = le64_to_cpu(cmd->tbl_addr) + 0x80;
int sglist_alloc_hint = opts >> AHCI_CMD_HDR_PRDT_LEN;
dma_addr_t prdt_len = (sglist_alloc_hint * sizeof(AHCI_SG));
dma_addr_t real_prdt_len = prdt_len;
uint8_t *prdt;
int i;
int r = 0;
if (!sglist_alloc_hint) {
DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts);
return -1;
}
if (!(prdt = dma_memory_map(ad->hba->dma, prdt_addr, &prdt_len,
DMA_DIRECTION_TO_DEVICE))){
DPRINTF(ad->port_no, "map failed\n");
return -1;
}
if (prdt_len < real_prdt_len) {
DPRINTF(ad->port_no, "mapped less than expected\n");
r = -1;
goto out;
}
if (sglist_alloc_hint > 0) {
AHCI_SG *tbl = (AHCI_SG *)prdt;
qemu_sglist_init(sglist, sglist_alloc_hint, ad->hba->dma);
for (i = 0; i < sglist_alloc_hint; i++) {
qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr),
le32_to_cpu(tbl[i].flags_size) + 1);
}
}
out:
dma_memory_unmap(ad->hba->dma, prdt, prdt_len,
DMA_DIRECTION_TO_DEVICE, prdt_len);
return r;
}
| 1threat
|
static void get_tree_codes(uint32_t *bits, int16_t *lens, uint8_t *xlat,
Node *nodes, int node,
uint32_t pfx, int pl, int *pos)
{
int s;
s = nodes[node].sym;
if (s != -1) {
bits[*pos] = (~pfx) & ((1U << FFMAX(pl, 1)) - 1);
lens[*pos] = FFMAX(pl, 1);
xlat[*pos] = s + (pl == 0);
(*pos)++;
} else {
pfx <<= 1;
pl++;
get_tree_codes(bits, lens, xlat, nodes, nodes[node].l, pfx, pl,
pos);
pfx |= 1;
get_tree_codes(bits, lens, xlat, nodes, nodes[node].r, pfx, pl,
pos);
}
}
| 1threat
|
static uint32_t nam_readw (void *opaque, uint32_t addr)
{
PCIAC97LinkState *d = opaque;
AC97LinkState *s = &d->ac97;
uint32_t val = ~0U;
uint32_t index = addr - s->base[0];
s->cas = 0;
val = mixer_load (s, index);
return val;
}
| 1threat
|
static int qemu_rdma_exchange_recv(RDMAContext *rdma, RDMAControlHeader *head,
int expecting)
{
RDMAControlHeader ready = {
.len = 0,
.type = RDMA_CONTROL_READY,
.repeat = 1,
};
int ret;
ret = qemu_rdma_post_send_control(rdma, NULL, &ready);
if (ret < 0) {
fprintf(stderr, "Failed to send control buffer!\n");
return ret;
}
ret = qemu_rdma_exchange_get_response(rdma, head,
expecting, RDMA_WRID_READY);
if (ret < 0) {
return ret;
}
qemu_rdma_move_header(rdma, RDMA_WRID_READY, head);
ret = qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY);
if (ret) {
fprintf(stderr, "rdma migration: error posting second control recv!");
return ret;
}
return 0;
}
| 1threat
|
React native packager fails on node 6.5 : <p>This was working previously. But since I upgraded from node 4.6 to 6.5, When I do an <code>npm start</code>, I end up with below error</p>
<pre><code>Failed to build DependencyGraph: @providesModule naming collision:
Duplicate module name: String.prototype.es6
Paths: ...../node_modules/react-native/packager/react-packager/src/Resolver/polyfills/String.prototype.es6.js collides with ...../app/MallJell/nd/react-native/packager/react-packager/src/Resolver/polyfills/String.prototype.es6.js
This error is caused by a @providesModule declaration with the same name across two different files.
Error: @providesModule naming collision:
Duplicate module name: String.prototype.es6
Paths: ....../react-native/packager/react-packager/src/Resolver/polyfills/String.prototype.es6.js collides with ..../react-packager/src/Resolver/polyfills/String.prototype.es6.js
This error is caused by a @providesModule declaration with the same name across two different files.
at HasteMap._updateHasteMap (..../node_modules/react-native/packager/react-packager/src/node-haste/DependencyGraph/HasteMap.js:155:13)
at module.getName.then.name (.....node_modules/react-native/packager/react-packager/src/node-haste/DependencyGraph/HasteMap.js:115:31)
</code></pre>
| 0debug
|
Kotlin: Accessing parameter of when-statement : <p>Is there a way to get the value of the expression I passed into the <code>when</code> statement?</p>
<p>In my application I have a <code>KeyListener</code> like that</p>
<pre><code>_content.addKeyListener(object : KeyAdapter() {
override fun keyPressed(e: KeyEvent?) = when(e?.keyCode) {
KeyEvent.VK_T -> mainWindow.enterTrainingState()
KeyEvent.VK_P -> mainWindow.enterPlayState()
KeyEvent.VK_E -> mainWindow.close()
else -> println(e?.keyCode)
}
})
</code></pre>
<p>Has Kotlin a neat syntax to access <code>e?.keyCode</code>? I don't really want to repeat the expression.</p>
| 0debug
|
Is SQLite accessible from everywhere when an android app is in playstore? : I'm starting a new application in android studio with and I need a DataBase. I read that SQLite is the one that I need to use but I want to know if then when i publish my app the other people with their phones can acces this DataBase and where this DB is stored. Thanks
| 0debug
|
nullpointerexception in AsyncTask in android studio : <p>I am trying to parse a website using Jsoup.
But in the onPostUpdate method while changing the textview get the nullpointerexception.
please help I am using my mobile to run this.
jsoup is parsing the page but onPostupdate fails to update the TextView component.</p>
<p>Here is my code</p>
<pre><code> package com.example.mayurn.sitechecker;
import android.os.AsyncTask;
import android.provider.DocumentsContract;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
public class MainActivity extends AppCompatActivity {
TextView textview;
private static final String TAG="MyTag";
TextView setter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView textview = (TextView)findViewById(R.id.textView);
Button button = (Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new doit().execute();
Log.i(TAG,"doit executer");
}
});
}
public class doit extends AsyncTask<Void,Void,Void>{
String words;
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected Void doInBackground(Void... params) {
try {
//Document doc = Jsoup.connect("https://en.wikipedia.org/wiki/Main_Page").get();
org.jsoup.nodes.Document doc=Jsoup.connect("https://en.wikipedia.org/wiki/Main_Page").get();
words = doc.text();
Log.i(TAG,"Words initialized");
Log.i(TAG,words);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
try {
Log.i(TAG, "Inside onpostexecute");
textview.setText("words");
}catch (Exception e){e.printStackTrace();}
}
}
}
</code></pre>
<p>Logcat output is</p>
<pre><code>12-25 16:21:05.348 12857-12988/com.example.mayurn.sitechecker W/System.err: Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
12-25 16:21:09.071 12857-12988/com.example.mayurn.sitechecker I/MyTag: Words initialized
12-25 16:21:09.072 12857-12988/com.example.mayurn.sitechecker I/MyTag: Wikipedia, the free encyclopedia Open main menu Today's featured article Hebron Church is a mid-19th century Lutheran church in Intermont, Hampshire County, in the U.S. state of West Virginia. It was founded in 1786 as Great Capon Church by German settlers in the Cacapon River Valley, making it the first Lutheran church west of the Shenandoah Valley. The congregation worshiped in a log church, which initially served both Lutheran and Reformed denominations. In 1821, records and sermons transitioned from German to English. The church's congregation built the present Greek Revival-style church building in 1849, when it was renamed Hebron on the Cacapon. The original log church was moved across the road and used as a sexton's house, Sunday school classroom, and public schoolhouse. To celebrate the congregation's 175th anniversary in 1961, Hebron Church constructed a building for community functions and religious education, designed to be architecturally compatible with the 1849 brick church. Hebron Church was listed on the National Register of Historic Places in 2014, cited as a Potomac Highlands church with vernacular Greek Revival architecture. (Full article...) Recently featured: Themes in Maya Angelou's autobiographies Richard Dannatt Andrew Sledd Archive By email More featured articles... In the news Breitscheidplatz Christmas market The United Nations Security Council adopts a resolution condemning Israeli settlements in the West Bank. Syrian government forces retake control of the besieged areas of Aleppo. More than 30 people are killed by government security forces as protests break out across the Democratic Republic of the Congo following Joseph Kabila's refusal to step down after the completion of his scheduled term in office. An explosion at a fireworks market in Tultepec, Mexico, kills at least 32 people and injures more than 50 others. A terrorist attack kills 12 people and injures 56 others, as a stolen truck is rammed into a Christmas market (pictured) in Berlin, Germany. Ongoing: Battle of Mosul Recent deaths: Rick Parfitt Franca Sozzani Corno Michèle Morgan Retrieved from "https://en.wikipedia.org/w/index.php?title=Main_Page&oldid=749836961" Read in another language View edit history of this page. ® Content is available under CC BY-SA 3.0 unless otherwise noted. Terms of Use Privacy Desktop
12-25 16:21:09.072 12857-12857/com.example.mayurn.sitechecker I/MyTag: Inside onpostexecute
12-25 16:21:09.072 12857-12857/com.example.mayurn.sitechecker W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
12-25 16:21:09.072 12857-12857/com.example.mayurn.sitechecker W/System.err: at com.example.mayurn.sitechecker.MainActivity$doit.onPostExecute(MainActivity.java:82)
12-25 16:21:09.072 12857-12857/com.example.mayurn.sitechecker W/System.err: at com.example.mayurn.sitechecker.MainActivity$doit.onPostExecute(MainActivity.java:49)
12-25 16:21:09.072 12857-12857/com.example.mayurn.sitechecker W/System.err: at android.os.AsyncTask.finish(AsyncTask.java:651)
12-25 16:21:09.073 12857-12857/com.example.mayurn.sitechecker W/System.err: at android.os.AsyncTask.access$500(AsyncTask.java:180)
12-25 16:21:09.073 12857-12857/com.example.mayurn.sitechecker W/System.err: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
12-25 16:21:09.073 12857-12857/com.example.mayurn.sitechecker W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
12-25 16:21:09.073 12857-12857/com.example.mayurn.sitechecker W/System.err: at android.os.Looper.loop(Looper.java:148)
12-25 16:21:09.073 12857-12857/com.example.mayurn.sitechecker W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5451)
12-25 16:21:09.073 12857-12857/com.example.mayurn.sitechecker W/System.err: at java.lang.reflect.Method.invoke(Native Method)
12-25 16:21:09.073 12857-12857/com.example.mayurn.sitechecker W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
12-25 16:21:09.073 12857-12857/com.example.mayurn.sitechecker W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-25 16:21:22.001 12857-12857/com.example.mayurn.sitechecker V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@4a0167
12-25 16:21:22.006 12857-12857/com.example.mayurn.sitechecker V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@89a2b14
12-25 16:21:22.007 12857-12857/com.example.mayurn.sitechecker V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@83c9fbd
12-25 16:21:22.008 12857-12857/com.example.mayurn.sitechecker V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@3a9c9b2
12-25 16:21:22.009 12857-12857/com.example.mayurn.sitechecker V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@c6b4d03
12-25 16:21:22.009 12857-12857/com.example.mayurn.sitechecker V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@e78e480
</code></pre>
| 0debug
|
VSC PowerShell. After npm updating packages .ps1 cannot be loaded because running scripts is disabled on this system : <p>I design websites in VSC and PowerShell is my default terminal.</p>
<p>After updating and deploying a website to firebase earlier, I was prompted to update firebase tools - which I did using npm. Immediately after I cannot run/access any firebase scripts wthout the folllowing error:</p>
<p><code>firebase : File C:\Users\mada7\AppData\Roaming\npm\firebase.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:1</code></p>
<p><code>firebase
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess</code></p>
<p>I've spent a few hours searching around and can't find a solid answer the problem. Many threads are several years old and I find it bizarre I've not had this problem in the past year until today.
I can still access firebase scripts if I set my default terminal to cmd.</p>
<p>Assuming the problem was related to firebase-tools I've carried on working but have now updated vue.js and get the error again when trying to run any vue commands in powershell:</p>
<p><code>vue : File C:\Users\mada7\AppData\Roaming\npm\vue.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:1</code></p>
<p><code>vue
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
</code></p>
<p><code>VSCode Version:
Version: 1.37.1 (user setup)
Commit: f06011a
Date: 2019-08-15T16:17:55.855Z
Electron: 4.2.7
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.18362
OS Version:
Windows 10 Home
Version - 1903
OS build - 18362.295</code></p>
<p>I've been reading around and seen many threads around permissions for scripts, but I haven't changed any - indeed the PowerShell scripts worked right up until I updated my packages. No other settings touched in the mean time. I don't want to be changing PowerShell settings unnecessarily.</p>
| 0debug
|
static void g364fb_screen_dump(void *opaque, const char *filename)
{
G364State *s = opaque;
int y, x;
uint8_t index;
uint8_t *data_buffer;
FILE *f;
if (s->depth != 8) {
error_report("g364: unknown guest depth %d", s->depth);
return;
}
f = fopen(filename, "wb");
if (!f)
return;
if (s->ctla & CTLA_FORCE_BLANK) {
fprintf(f, "P4\n%d %d\n",
s->width, s->height);
for (y = 0; y < s->height; y++)
for (x = 0; x < s->width; x++)
fputc(0, f);
} else {
data_buffer = s->vram + s->top_of_screen;
fprintf(f, "P6\n%d %d\n%d\n",
s->width, s->height, 255);
for (y = 0; y < s->height; y++)
for (x = 0; x < s->width; x++, data_buffer++) {
index = *data_buffer;
fputc(s->color_palette[index][0], f);
fputc(s->color_palette[index][1], f);
fputc(s->color_palette[index][2], f);
}
}
fclose(f);
}
| 1threat
|
How to move between divs with the scroll in wordpress? : <p>I need to be able to display content using a scroll effect like this one on this page</p>
<p><a href="http://www.quoplus.com/" rel="nofollow noreferrer">http://www.quoplus.com/</a></p>
<p>Check it out!</p>
<p>Any idea how could I do this in a web site based in wordpress?</p>
| 0debug
|
Please Help Me!!! Modal Does Not Work : `cell = '<div class="col-4"><div class="card" style="width: 18rem;">\
<img class="card-img-top" src="products/'+thumb+ '" alt="Card image cap">\
<div class="card-body">\
<h5 class="card-title">'+title+ '</h5>\
<p class="card-text">'+cats+'</p>\
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Show More</button>\
</div>\
</div></div>`
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<span id="message">Thank You </span>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Please help me. My modal doesnt show no matter how many times i try. Does modal work in bootstrap cards? No matter how many times i press the button the modal doesnt show. My modal is in another html page. Is there a problem with that? Im using visual studio code
| 0debug
|
Limitations for Firebase Notification Topics : <p>I want to use Firebase notification for my android application and what i want to know is that is there any limitation for number of topics ? or for the number of users that can subscribe a topic ?
For example can i have 10000 topics with 1 million users for each of them ?</p>
| 0debug
|
Please - compile me new pdo PDO_4D : Im new to all this so please keep that in mind.
Short story; We have 32 client databases, some are big, with millions of records (V.11. Currently, hosted and build on Mac's). I have build a website on windows 2012 64x server and included last version of PDO. with Php version that was stated (xamp 2.5 with PHP/5.3.8 ). Plugin and apache are 32x.
My web page connects to all 32 clients on 4d sql servers and runs few sql select quarries. The problems I'm encountering are almost impossible to describe. On some search terms it sometimes works and sometimes not. What I men, if i search for "jone doe" it does give me results, and if i change one latter it doesn't, sql connect handler on client stays hanging and web page goes to timeout. Note that there is no pattern. Some searches are hanging on one client. some on 2 or 3. Different search is same, but different clients. Only one Search for specific number of 13 characters is passing all clients and it's working perfectly. Let me also say I'm targeting specific tables and columns so I'm sure my sgl quarry is not a problem, i have few search boxes and they are all single search no OR or AND sql, also I'm selecting about 4-6 columns to display results for that one select query. Also its all on private network at work. So connections are not the problem also. I will add that results can be from 0 - 50 maximum per one connection. Here is striped down sample of code;
connections are defined up, this is rest of the code...
function trazi($dbaza) {
global $db; global $db2; global $db3; global $db4; global $db5; global $db6; global $db7;
global $db8; global $db9; global $db10; global $db11; global $db12; global $db13; global
$db14; global $db15; global $db16; global $db17; global $db18; global $db19; global $db20;
global $db21; global $db22; global $db23; global $db24; global $db25; global $db26; global $db27;
global $db28; global $db29; global $db30; global $db31; global $db32;
global $inime; global $inoib; global $inbb; global $inbbroj; global $insb;
$odabrani = $dbaza->prepare('SELECT STANJE, SUD_BROJ_O, SUD_BROJ_P, SUD_BROJ_JBR , NAZIV_LONG, OIB FROM PREDMETI WHERE SUD_BROJ_O = ? ');
$params = array($insb);
$odabrani->execute($params);
$rezultat = $odabrani->fetchAll(PDO::FETCH_ASSOC);
unset($dbaza);
unset($odabrani);
if ($rezultat) {
<th>Ime i prezime</th>
<th>OIB</th>
<th>Bilježnički broj</th>
<th>Sudski parnički broj</th>
<th>Sudski ovršni broj</th>
<th>Stanje predmeta</th>';
foreach($rezultat as $row) {
echo "<tr>
<td>".$row['NAZIV_LONG']. "</td>".
"<td>".$row['OIB']."</td>".
"<td>".$row['SUD_BROJ_JBR']."</td>".
"<td>".$row['SUD_BROJ_P']."</td>".
"<td>".$row['SUD_BROJ_O']."</td>".
"<td>".$row['STANJE']."</td>".
"</tr>";
}
echo "</table>";
} else {
echo "Vaša pretraga nije pronašla niti jedan rezultat.";
}
}
unset($rezultat);
//ATLANTIC
echo '<br><br><div style="color:#922E19">ATLANTIC</div>';
trazi($db);
ob_implicit_flush(true);
$buffer = str_repeat(" ", 4096);
echo $buffer;
ob_flush(); usleep(300000);
//CEDEVITA
echo '<br><br><div style="color:#922E19">CEDEVITA</div>';
trazi($db2);
ob_implicit_flush(true);
$buffer = str_repeat(" ", 4096);
echo $buffer;
ob_flush(); usleep(300000);
ETC...
I have spent weeks on this problem until I find this topic. I really hope that this PDO limitations are the problem because on some quarries he selects to much data and breaks.
The problem; I have made changes to 4d pdo source files and changed limitations, But i can not compile it nether I know how. I don't have a PC, my server is of no use for this topic and I'm on Mac. Can someone please help me compile a dll with this changes. I will attach a zip file with changes made.
Please help.
http://forums.4d.fr/4DBB_Main/x_User/18851165/files/18851204.zip
Edit; or can someone compile me this version with bug fixes;
https://github.com/famsf/pecl-pdo-4d
I don't know does it matter but I'm using PHP/5.3.8 32bits
| 0debug
|
Wrap media query in class : <p>I was wondering if there as a reason why I couldn't wrap a media query I have for the home page with the .home{} class so that it only fires there.</p>
<p>So instead of </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-css lang-css prettyprint-override"><code>@media (max-width:416px){
.home .et_pb_code_0 {
border-right:0 !important;
}
.home .et_pb_code_1 {
border-right:0 !important;
border-left:0 !important;
}
.home .et_pb_code_2 {
border-left:0 !important;
}
}</code></pre>
</div>
</div>
</p>
<p>I would use:</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-css lang-css prettyprint-override"><code>.home {
@media (max-width:416px){
.et_pb_code_0 {
border-right:0 !important;
}
.et_pb_code_1 {
border-right:0 !important;
border-left:0 !important;
}
.et_pb_code_2 {
border-left:0 !important;
}
}
}</code></pre>
</div>
</div>
</p>
<p>Thanks!</p>
| 0debug
|
Windows 10 - How do I test touch events without a touchscreen? : <p>I need to test my Windows app using touch events but don't have a touch screen available.</p>
| 0debug
|
what is the difference between time.perf_counter() and time.process_time()? : <p>I am using Jupyter notebook. I'm trying to measure how long will it take to count the Avogadro's number with python. I found that <code>time.perf_counter()</code> and <code>time.process_time()</code> modules will be useful for this kind of work. So I tried both of them, but the result was totally different. What makes this kind of difference? Here are my codes.</p>
<pre><code>import time
a = 10 ** 5
def AvogadroCounting():
i = 0
while i <= a:
i += 1
AvogadroCounting()
t_fract = time.perf_counter() #time to count fraction of avogadro's number in Seconds
print(t_fract, 'secs')
</code></pre>
<p>and my notebook gives 693920.393636181 secs.</p>
<pre><code>import time
a = 10 ** 5
def AvogadroCounting():
i = 0
while i <= a:
i += 1
AvogadroCounting()
t_fract = time.process_time() #time to count fraction of avogadro's number in Seconds
print(t_fract, 'secs')
</code></pre>
<p>and this gives 2048.768273 secs.</p>
| 0debug
|
static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, int Al,
const uint8_t *mb_bitmask, const AVFrame *reference){
int i, mb_x, mb_y;
uint8_t* data[MAX_COMPONENTS];
const uint8_t *reference_data[MAX_COMPONENTS];
int linesize[MAX_COMPONENTS];
GetBitContext mb_bitmask_gb;
if (mb_bitmask) {
init_get_bits(&mb_bitmask_gb, mb_bitmask, s->mb_width*s->mb_height);
}
if(s->flipped && s->avctx->flags & CODEC_FLAG_EMU_EDGE) {
av_log(s->avctx, AV_LOG_ERROR, "Can not flip image with CODEC_FLAG_EMU_EDGE set!\n");
s->flipped = 0;
}
for(i=0; i < nb_components; i++) {
int c = s->comp_index[i];
data[c] = s->picture_ptr->data[c];
reference_data[c] = reference ? reference->data[c] : NULL;
linesize[c]=s->linesize[c];
s->coefs_finished[c] |= 1;
if(s->flipped) {
int offset = (linesize[c] * (s->v_scount[i] * (8 * s->mb_height -((s->height/s->v_max)&7)) - 1 ));
data[c] += offset;
reference_data[c] += offset;
linesize[c] *= -1;
}
}
for(mb_y = 0; mb_y < s->mb_height; mb_y++) {
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
const int copy_mb = mb_bitmask && !get_bits1(&mb_bitmask_gb);
if (s->restart_interval && !s->restart_count)
s->restart_count = s->restart_interval;
if(get_bits_count(&s->gb)>s->gb.size_in_bits){
av_log(s->avctx, AV_LOG_ERROR, "overread %d\n", get_bits_count(&s->gb) - s->gb.size_in_bits);
return -1;
}
for(i=0;i<nb_components;i++) {
uint8_t *ptr;
int n, h, v, x, y, c, j;
int block_offset;
n = s->nb_blocks[i];
c = s->comp_index[i];
h = s->h_scount[i];
v = s->v_scount[i];
x = 0;
y = 0;
for(j=0;j<n;j++) {
block_offset = (((linesize[c] * (v * mb_y + y) * 8) +
(h * mb_x + x) * 8) >> s->avctx->lowres);
if(s->interlaced && s->bottom_field)
block_offset += linesize[c] >> 1;
ptr = data[c] + block_offset;
if(!s->progressive) {
if (copy_mb) {
mjpeg_copy_block(ptr, reference_data[c] + block_offset, linesize[c], s->avctx->lowres);
} else {
s->dsp.clear_block(s->block);
if(decode_block(s, s->block, i,
s->dc_index[i], s->ac_index[i],
s->quant_matrixes[ s->quant_index[c] ]) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "error y=%d x=%d\n", mb_y, mb_x);
return -1;
}
s->dsp.idct_put(ptr, linesize[c], s->block);
}
} else {
int block_idx = s->block_stride[c] * (v * mb_y + y) + (h * mb_x + x);
DCTELEM *block = s->blocks[c][block_idx];
if(Ah)
block[0] += get_bits1(&s->gb) * s->quant_matrixes[ s->quant_index[c] ][0] << Al;
else if(decode_dc_progressive(s, block, i, s->dc_index[i], s->quant_matrixes[ s->quant_index[c] ], Al) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "error y=%d x=%d\n", mb_y, mb_x);
return -1;
}
}
if (++x == h) {
x = 0;
y++;
}
}
}
if (s->restart_interval && show_bits(&s->gb, 8) == 0xFF){
--s->restart_count;
align_get_bits(&s->gb);
while(show_bits(&s->gb, 8) == 0xFF)
skip_bits(&s->gb, 8);
skip_bits(&s->gb, 8);
for (i=0; i<nb_components; i++)
s->last_dc[i] = 1024;
}
}
}
return 0;
}
| 1threat
|
Can I use multiple 'await' in an async function's try/catch block? : <p>i.e.</p>
<pre><code>async asyncfunction(){
try{
await method1();
await method2();
}
catch(error){
console.log(error);
}
}
</code></pre>
<p>Given method1() and method2() are asynchronous functions. Should there be a try/catch block for each await method? Is there an even cleaner way to write this? I'm trying to avoid '.then' and '.catch' chaining.</p>
| 0debug
|
Regex Instagram for Embed : How to Embed Instagram URLs in $text?
$text = It was 'https://www.instagram.com/p/Bes0orNjOIa/?taken-by=kendalljenner, then it was https://www.instagram.com/p/BfL4X3-lcst/?taken-by=kendalljenner';
Result
echo $text;
// It was <iframe src="//www.instagram.com/p/Bes0orNjOIa/embed"></iframe>, then it was <iframe src="//www.instagram.com/p/BfL4X3-lcst/embed"></iframe>
| 0debug
|
i need to know where i m wrong in json object to POST using idhttp in delphi,source gives socket error 14001,WITH OBJ JSO NO PARAM MESSAGE FOR POST : jso := TlkJSONobject.Create;//(data) as TlkJSONobject;
jso.Add('InvoiceNumber', '');
jso.Add('POSID', '910441');
jso.add('USIN', ePOSNo.Text);
jso.add('DATETIME', eDate.Text);
IdHTTP1.Request.Accept := 'application/json';
IdHTTP1.Request.ContentType := 'application/json';
{ Call the Post method of TIdHTTP and read the result into TMemo }
Memo1.Lines.Text := IdHTTP1.Post('http://localhost;8524/api/IMSFISCAL/GetInvoiceNumberByModel', JSO);
jso cannot be passed as t stream
need help on it
| 0debug
|
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
| 1threat
|
Laravel Passport Get Client ID By Access Token : <p>I'm writing a tiny sms gateway to be consumed by a couple of projects,</p>
<p>I implemented laravel passport authentication (<a href="https://laravel.com/docs/5.4/passport#client-credentials-grant-tokens" rel="noreferrer">client credentials grant token</a>)</p>
<p>Then I've added <code>CheckClientCredentials</code> to api middleware group:</p>
<pre><code>protected $middlewareGroups = [
'web' => [
...
],
'api' => [
'throttle:60,1',
'bindings',
\Laravel\Passport\Http\Middleware\CheckClientCredentials::class
],
];
</code></pre>
<p>The logic is working fine, now in my controller I need to get client associated with a valid token.</p>
<p><strong>routes.php</strong></p>
<pre><code>Route::post('/sms', function(Request $request) {
// save the sms along with the client id and send it
$client_id = ''; // get the client id somehow
sendSms($request->text, $request->to, $client_id);
});
</code></pre>
<p>For obvious security reasons I can never send the client id with the consumer request e.g. <code>$client_id = $request->client_id;</code>.</p>
| 0debug
|
static void ahci_mem_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
AHCIState *s = opaque;
if (addr & 3) {
fprintf(stderr, "ahci: Mis-aligned write to addr 0x"
TARGET_FMT_plx "\n", addr);
return;
}
if (addr < AHCI_GENERIC_HOST_CONTROL_REGS_MAX_ADDR) {
DPRINTF(-1, "(addr 0x%08X), val 0x%08"PRIX64"\n", (unsigned) addr, val);
switch (addr) {
case HOST_CAP:
break;
case HOST_CTL:
if (val & HOST_CTL_RESET) {
DPRINTF(-1, "HBA Reset\n");
ahci_reset(s);
} else {
s->control_regs.ghc = (val & 0x3) | HOST_CTL_AHCI_EN;
ahci_check_irq(s);
}
break;
case HOST_IRQ_STAT:
s->control_regs.irqstatus &= ~val;
ahci_check_irq(s);
break;
case HOST_PORTS_IMPL:
break;
case HOST_VERSION:
break;
default:
DPRINTF(-1, "write to unknown register 0x%x\n", (unsigned)addr);
}
} else if ((addr >= AHCI_PORT_REGS_START_ADDR) &&
(addr < (AHCI_PORT_REGS_START_ADDR +
(s->ports * AHCI_PORT_ADDR_OFFSET_LEN)))) {
ahci_port_write(s, (addr - AHCI_PORT_REGS_START_ADDR) >> 7,
addr & AHCI_PORT_ADDR_OFFSET_MASK, val);
}
}
| 1threat
|
how can i find length of json object in sql server 2016? : [{"FUNCTION_HIERARCHY_LEVEL":"1","FUNCTION_PRIMARY_INDICATOR":"1","FUNCTION_CODE":"16041049","FUNCTION_DESCRIPTION":"SERVICES","FUNCTION_GLOBAL_CODE":"163554","FUNCTION_GLOBAL_DESCRIPTION":"Internal Services","Function_TYPE":"bbcc","FUNCTION_TYPE_CODE":"ASSIGNED","FUNCTION_TYPE_DESCRIPTION":"Assigned to the Function"},{"FUNCTION_HIERARCHY_LEVEL":"2","FUNCTION_PRIMARY_INDICATOR":"1","FUNCTION_CODE":"16041049","FUNCTION_DESCRIPTION":"SERVICES","FUNCTION_GLOBAL_CODE":"1736","FUNCTION_GLOBAL_DESCRIPTION":"Information Technology","Function_TYPE":"bb","FUNCTION_TYPE_CODE":"ASSIGNED","FUNCTION_TYPE_DESCRIPTION":"Assigned to the Function"},{"FUNCTION_HIERARCHY_LEVEL":"1","FUNCTION_PRIMARY_INDICATOR":"1","FUNCTION_CODE":"16041049","FUNCTION_DESCRIPTION":"SERVICES","FUNCTION_GLOBAL_CODE":"163554","FUNCTION_GLOBAL_DESCRIPTION":"Internal Services","Function_TYPE":"bbcc","FUNCTION_TYPE_CODE":"HE","FUNCTION_TYPE_DESCRIPTION":"Client Service Function Assigned by HR"},{"FUNCTION_HIERARCHY_LEVEL":"2","FUNCTION_PRIMARY_INDICATOR":"1","FUNCTION_CODE":"16041049","FUNCTION_DESCRIPTION":"SERVICES","FUNCTION_GLOBAL_CODE":"1736","FUNCTION_GLOBAL_DESCRIPTION":"Information Technology","Function_TYPE":"bb","FUNCTION_TYPE_CODE":"HE","FUNCTION_TYPE_DESCRIPTION":"Client Service Function Assigned by HR"}]
how can i find length of this json in sql if this value is stored in json column in some table?
| 0debug
|
A missing syntax error : <p>I need to develop a php code to create a double level array. When I run the file this error appears:</p>
<blockquote>
<p>Parse error: syntax error, unexpected ';' in
C:\inetpub\wwwroot\file.php on line 20</p>
</blockquote>
<p>I think that my error is a typo or some sentence bad closing but I can't find it.</p>
<pre><code><?php
$serverName = "serverName\SQLEXPRESS";
$connectionInfo = array( "Database"=>"dbName", "UID"=>"user", "PWD"=>"pass");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
$sql = "SELECT * FROM table1";
$stmt = sqlsrv_query( $conn, $sql);
if ($stmt === false) {
die( print_r( sqlsrv_errors(), true) );
}
$bbs = array();
while($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC){
$bbs = array_merge($bbs, array_values($row));
}
print_r($bbs);
?>
</code></pre>
| 0debug
|
int ff_vaapi_render_picture(struct vaapi_context *vactx, VASurfaceID surface)
{
VABufferID va_buffers[3];
unsigned int n_va_buffers = 0;
vaUnmapBuffer(vactx->display, vactx->pic_param_buf_id);
va_buffers[n_va_buffers++] = vactx->pic_param_buf_id;
if (vactx->iq_matrix_buf_id) {
vaUnmapBuffer(vactx->display, vactx->iq_matrix_buf_id);
va_buffers[n_va_buffers++] = vactx->iq_matrix_buf_id;
}
if (vactx->bitplane_buf_id) {
vaUnmapBuffer(vactx->display, vactx->bitplane_buf_id);
va_buffers[n_va_buffers++] = vactx->bitplane_buf_id;
}
if (vaBeginPicture(vactx->display, vactx->context_id,
surface) != VA_STATUS_SUCCESS)
return -1;
if (vaRenderPicture(vactx->display, vactx->context_id,
va_buffers, n_va_buffers) != VA_STATUS_SUCCESS)
return -1;
if (vaRenderPicture(vactx->display, vactx->context_id,
vactx->slice_buf_ids,
vactx->n_slice_buf_ids) != VA_STATUS_SUCCESS)
return -1;
if (vaEndPicture(vactx->display, vactx->context_id) != VA_STATUS_SUCCESS)
return -1;
}
| 1threat
|
How to handle partially dynamic JSON with Swift Codable? : <p>I've got some JSON messages coming in over a websocket connection.</p>
<pre><code>// sample message
{
type: "person",
data: {
name: "john"
}
}
// some other message
{
type: "location",
data: {
x: 101,
y: 56
}
}
</code></pre>
<p>How can I convert those messages into proper structs using Swift 4 and the Codable protocol?</p>
<p>In Go I can do something like: "Hey at the moment I only care about the <code>type</code> field and I'm not interested in the rest (the <code>data</code> part)." It would look like this</p>
<pre><code>type Message struct {
Type string `json:"type"`
Data json.RawMessage `json:"data"`
}
</code></pre>
<p>As you can see <code>Data</code> is of type <code>json.RawMessage</code> which can be parsed later on. Here is a full example <a href="https://golang.org/pkg/encoding/json/#example_RawMessage_unmarshal" rel="noreferrer">https://golang.org/pkg/encoding/json/#example_RawMessage_unmarshal</a>.</p>
<p>Can I do something similar in Swift? Like (haven't tried it yet)</p>
<pre><code>struct Message: Codable {
var type: String
var data: [String: Any]
}
</code></pre>
<p>Then <code>switch</code> on the <code>type</code> to convert the dictionary into proper structs. Would that work?</p>
| 0debug
|
Is this statement true that Java 8 provides functional styling but is not functional programming? : Is this statement true that Java 8 provides functional styling but is not functional programming as the syntax which it uses is also an object?
Calculator calc = (i, j) -> i/j;
If yes, then why we get articles everywhere Functional Programming with Java 8?
| 0debug
|
void vbe_ioport_write_data(void *opaque, uint32_t addr, uint32_t val)
{
VGACommonState *s = opaque;
if (s->vbe_index <= VBE_DISPI_INDEX_NB) {
#ifdef DEBUG_BOCHS_VBE
printf("VBE: write index=0x%x val=0x%x\n", s->vbe_index, val);
#endif
switch(s->vbe_index) {
case VBE_DISPI_INDEX_ID:
if (val == VBE_DISPI_ID0 ||
val == VBE_DISPI_ID1 ||
val == VBE_DISPI_ID2 ||
val == VBE_DISPI_ID3 ||
val == VBE_DISPI_ID4) {
s->vbe_regs[s->vbe_index] = val;
}
break;
case VBE_DISPI_INDEX_XRES:
case VBE_DISPI_INDEX_YRES:
case VBE_DISPI_INDEX_BPP:
case VBE_DISPI_INDEX_VIRT_WIDTH:
case VBE_DISPI_INDEX_X_OFFSET:
case VBE_DISPI_INDEX_Y_OFFSET:
s->vbe_regs[s->vbe_index] = val;
vbe_fixup_regs(s);
break;
case VBE_DISPI_INDEX_BANK:
if (s->vbe_regs[VBE_DISPI_INDEX_BPP] == 4) {
val &= (s->vbe_bank_mask >> 2);
} else {
val &= s->vbe_bank_mask;
}
s->vbe_regs[s->vbe_index] = val;
s->bank_offset = (val << 16);
vga_update_memory_access(s);
break;
case VBE_DISPI_INDEX_ENABLE:
if ((val & VBE_DISPI_ENABLED) &&
!(s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED)) {
int h, shift_control;
s->vbe_regs[VBE_DISPI_INDEX_VIRT_WIDTH] = 0;
s->vbe_regs[VBE_DISPI_INDEX_X_OFFSET] = 0;
s->vbe_regs[VBE_DISPI_INDEX_Y_OFFSET] = 0;
s->vbe_regs[VBE_DISPI_INDEX_ENABLE] |= VBE_DISPI_ENABLED;
vbe_fixup_regs(s);
if (!(val & VBE_DISPI_NOCLEARMEM)) {
memset(s->vram_ptr, 0,
s->vbe_regs[VBE_DISPI_INDEX_YRES] * s->vbe_line_offset);
}
s->gr[VGA_GFX_MISC] = (s->gr[VGA_GFX_MISC] & ~0x0c) | 0x04 |
VGA_GR06_GRAPHICS_MODE;
s->cr[VGA_CRTC_MODE] |= 3;
s->cr[VGA_CRTC_OFFSET] = s->vbe_line_offset >> 3;
s->cr[VGA_CRTC_H_DISP] =
(s->vbe_regs[VBE_DISPI_INDEX_XRES] >> 3) - 1;
h = s->vbe_regs[VBE_DISPI_INDEX_YRES] - 1;
s->cr[VGA_CRTC_V_DISP_END] = h;
s->cr[VGA_CRTC_OVERFLOW] = (s->cr[VGA_CRTC_OVERFLOW] & ~0x42) |
((h >> 7) & 0x02) | ((h >> 3) & 0x40);
s->cr[VGA_CRTC_LINE_COMPARE] = 0xff;
s->cr[VGA_CRTC_OVERFLOW] |= 0x10;
s->cr[VGA_CRTC_MAX_SCAN] |= 0x40;
if (s->vbe_regs[VBE_DISPI_INDEX_BPP] == 4) {
shift_control = 0;
s->sr[VGA_SEQ_CLOCK_MODE] &= ~8;
} else {
shift_control = 2;
s->sr[VGA_SEQ_MEMORY_MODE] |= VGA_SR04_CHN_4M;
s->sr[VGA_SEQ_PLANE_WRITE] |= VGA_SR02_ALL_PLANES;
}
s->gr[VGA_GFX_MODE] = (s->gr[VGA_GFX_MODE] & ~0x60) |
(shift_control << 5);
s->cr[VGA_CRTC_MAX_SCAN] &= ~0x9f;
} else {
s->bank_offset = 0;
}
s->dac_8bit = (val & VBE_DISPI_8BIT_DAC) > 0;
s->vbe_regs[s->vbe_index] = val;
vga_update_memory_access(s);
break;
default:
break;
}
}
}
| 1threat
|
I does not know why it is 25 : <p>[enter image description here][1]</p>
<p>[1]: <a href="https://i.stack.imgur.com/gg6E1.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/gg6E1.jpg</a> Please tell me why it is 25.</p>
| 0debug
|
trouble with friend function : <p>so my program is that i want the user to enter information about a board so everything is working except the part where i need the user to enter the value of attitude then add another number to increase that attitude so I'm stuck at this. As you can see I declared this function as a friend but when I enter the number that I need to increase it to the value of attitude) it stays the same! I hope I made clear the problem I'm facing! and I'd appreciate some help</p>
<pre><code>#ifndef BOARD_H
#define BOARD_H
class Board {
friend void incAttitude(Board &);
public:
friend void incAttitude(Board &);
static int boardcount;
Board(int=5,int=3,double=1.5,char* ='\0');
~Board();
Board &setBoard(int,int,double,char*);
char getLocation();
Board &print();
double surface();
private:
const int length;
int width;
double attitude;
char location[30];
};
#endif
#include<iostream>
#include<cstring>
#include<string>
#include<assert.h>
using namespace std;
#include "Board.h"
int Board::boardcount=0;
Board::Board(int l,int w,double a,char* lo)
: length(l)
{
width=w;
attitude=a;
location[0]='\0';
boardcount++;
}
Board::~Board(){
boardcount--;
}
Board &Board::setBoard(int l,int w,double a,char* lo)
{
width=(w>=2 && w<=5)?w:3;
attitude=(a>=1.5 && a<=2.8)?a:1.5;
strncpy_s(location,lo,29);
location[29]='\0';
return *this;
}
char Board::getLocation(){
return *location;
}
double Board::surface(){
return length*width;
}
void incAttitude(Board &h)
{
double incAttitude;
cout<<"enter to increase attitude "<<endl;
cin>>incAttitude;
h.attitude+=incAttitude;
cout<<"the attitude of the board after the increase : "<<h.attitude<<endl;
}
Board &Board::print(){
cout<<"the length of the boarad : "<<length<<endl;
cout<<"the width of the board : "<<width<<endl;
cout<<"the height of the board : "<<attitude<<endl;
cout<<"the location of the board : "<<location<<endl;
cout<<"the surface of the board : "<<surface()<<endl;
return *this;
}
int main(){
Board hh;
Board *boardptr;
int count,len,wid;
double att;
char locat[30];
cout<<"how many boards do you need to create ? "<<endl;
cin>>count;
boardptr = new Board[count];
assert(boardptr!=0);
for (int i=0; i<count; i++){
cout << "Enter the length: ";
cin >>len;
cout << "Enter the width: ";
cin >> wid;
cout << "Enter the attitude: ";
cin >> att;
incAttitude(hh);
cout<<"Enter the location: ";
cin >>locat;
boardptr[i].setBoard(len,wid,att,locat);
cout<<"------------------------------------------"<<endl;
if (strcmp("NewYork",locat) == 0)
{
boardptr[i].setBoard(len,wid,att,locat).print();
}
}
delete [] boardptr;
system("pause");
return 0;
}
</code></pre>
| 0debug
|
How to reduce the value from multiple rows by calculation : <p>I have table called : stock , From that qty will be reduced by priority column in the respective warehouse.</p>
<pre>
-------------------------------------------
Id SKU priority Warehouse Qty
--------------------------------------------
1 sku1 p1 W1 1
2 sku1 p2 w2 2
3 sku1 p3 w3 3
</pre>
<p>From the above table, 4 qty item will be reduced based on priority.</p>
<p>Expected output :</p>
<pre>
------------------------------------------
Id SKU priority Warehouse Qty
--------------------------------------------
1 sku1 p1 W1 0
2 sku1 p2 w2 0
3 sku1 p3 w3 2
</pre>
<p>Can anyone suggest how to achieve it.</p>
| 0debug
|
static void test_visitor_in_native_list_string(TestInputVisitorData *data,
const void *unused)
{
UserDefNativeListUnion *cvalue = NULL;
strList *elem = NULL;
Visitor *v;
GString *gstr_list = g_string_new("");
GString *gstr_union = g_string_new("");
int i;
for (i = 0; i < 32; i++) {
g_string_append_printf(gstr_list, "'%d'", i);
if (i != 31) {
g_string_append(gstr_list, ", ");
}
}
g_string_append_printf(gstr_union, "{ 'type': 'string', 'data': [ %s ] }",
gstr_list->str);
v = visitor_input_test_init_raw(data, gstr_union->str);
visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort);
g_assert(cvalue != NULL);
g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_STRING);
for (i = 0, elem = cvalue->u.string.data; elem; elem = elem->next, i++) {
gchar str[8];
sprintf(str, "%d", i);
g_assert_cmpstr(elem->value, ==, str);
}
g_string_free(gstr_union, true);
g_string_free(gstr_list, true);
qapi_free_UserDefNativeListUnion(cvalue);
}
| 1threat
|
Login with Node.js : <p>I want to do a POST action with node.js with a command line application.
The goal is to login to <a href="http://hbeta.net" rel="nofollow">http://hbeta.net</a>
(I want to create a application that post the username and the password automaticly)
thanks ;)</p>
| 0debug
|
Xcode 8 (Swift 3) Command failed due to signal: Killed: 9 : <p>After upgrading to Xcode 8 and converting all my code to Swift 3, I have troubles compiling swift resources. It takes a very long time, and my computer gets super laggy and after about 30 minutes I get this</p>
<p>CompileSwift normal arm64 /Users/choojayson/Dropbox/BottomsUp/Thirst/UserDrank.swift
cd /Users/choojayson/Dropbox/BottomsUp
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/choojayson/Dropbox/BottomsUp/Thirst/PendingVC.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/NotificationCell.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/ProfileCell.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/NotificationsVC.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/UserPendingAction.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/ChooseDrinkVC.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/AppDelegate.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/UserCell.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/FirebaseReferences.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/ProfileStatsCell.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/UserDrankTime.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/MyProfileVC.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/ProfileStatsFooterCell.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/WeeklyDrank.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/DrinkList.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/DrinkCell.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/User.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/HeaderCell.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/EndorseVC.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/GlobalScore.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/Username.swift /Users/choojayson/Dropbox/BottomsUp/HomeVC.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/LoginVC.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/LeaderBoardVC.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/CollectionViewHeaderCell.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/Global.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/CircularTransition.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/Drink.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/WeeklyBestVC.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/DrinkStatus.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/LeaderBoardCell.swift /Users/choojayson/Dropbox/BottomsUp/Thirst/PendingCell.swift -primary-file /Users/choojayson/Dropbox/BottomsUp/Thirst/UserDrank.swift -target arm64-apple-ios8.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.0.sdk -I /Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Products/Debug-iphoneos -F /Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Products/Debug-iphoneos -F /Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Products/Debug-iphoneos/SDWebImage -F /Users/choojayson/Dropbox/BottomsUp/Pods/FirebaseAnalytics/Frameworks/frameworks -F /Users/choojayson/Dropbox/BottomsUp/Pods/FirebaseAuth/Frameworks/frameworks -F /Users/choojayson/Dropbox/BottomsUp/Pods/FirebaseDatabase/Frameworks -F /Users/choojayson/Dropbox/BottomsUp/Pods/FirebaseInstanceID/Frameworks/frameworks -F /Users/choojayson/Dropbox/BottomsUp/Pods/FirebaseMessaging/Frameworks/frameworks -F /Users/choojayson/Dropbox/BottomsUp/Pods/FirebaseStorage/Frameworks -F /Users/choojayson/Dropbox/BottomsUp/Pods/GoogleIPhoneUtilities/Frameworks -F /Users/choojayson/Dropbox/BottomsUp/Pods/GoogleInterchangeUtilities/Frameworks -F /Users/choojayson/Dropbox/BottomsUp/Pods/GoogleNetworkingUtilities/Frameworks -F /Users/choojayson/Dropbox/BottomsUp/Pods/GoogleParsingUtilities/Frameworks -F /Users/choojayson/Dropbox/BottomsUp/Pods/GoogleSymbolUtilities/Frameworks -F /Users/choojayson/Dropbox/BottomsUp/Pods/GoogleUtilities/Frameworks -F /Users/choojayson/Dropbox/BottomsUp -enable-testing -g -module-cache-path /Users/choojayson/Library/Developer/Xcode/DerivedData/ModuleCache -serialize-debugging-options -Xcc -I/Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Intermediates/Thirst.build/Debug-iphoneos/Thirst.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Intermediates/Thirst.build/Debug-iphoneos/Thirst.build/Thirst-generated-files.hmap -Xcc -I/Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Intermediates/Thirst.build/Debug-iphoneos/Thirst.build/Thirst-own-target-headers.hmap -Xcc -I/Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Intermediates/Thirst.build/Debug-iphoneos/Thirst.build/Thirst-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Intermediates/Thirst.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Intermediates/Thirst.build/Debug-iphoneos/Thirst.build/Thirst-project-headers.hmap -Xcc -I/Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Products/Debug-iphoneos/include -Xcc -I/Users/choojayson/Dropbox/BottomsUp/Pods/Firebase/Analytics/Sources -Xcc -I/Users/choojayson/Dropbox/BottomsUp/Pods/Headers/Public -Xcc -I/Users/choojayson/Dropbox/BottomsUp/Pods/Headers/Public/Firebase -Xcc -I/Users/choojayson/Dropbox/BottomsUp/Pods/Headers/Public/FirebaseAnalytics -Xcc -I/Users/choojayson/Dropbox/BottomsUp/Pods/Headers/Public/FirebaseAuth -Xcc -I/Users/choojayson/Dropbox/BottomsUp/Pods/Headers/Public/FirebaseDatabase -Xcc -I/Users/choojayson/Dropbox/BottomsUp/Pods/Headers/Public/FirebaseInstanceID -Xcc -I/Users/choojayson/Dropbox/BottomsUp/Pods/Headers/Public/FirebaseMessaging -Xcc -I/Users/choojayson/Dropbox/BottomsUp/Pods/Headers/Public/FirebaseStorage -Xcc -I/Users/choojayson/Dropbox/BottomsUp/Pods/Headers/Public/GoogleIPhoneUtilities -Xcc -I/Users/choojayson/Dropbox/BottomsUp/Pods/Headers/Public/GoogleInterchangeUtilities -Xcc -I/Users/choojayson/Dropbox/BottomsUp/Pods/Headers/Public/GoogleNetworkingUtilities -Xcc -I/Users/choojayson/Dropbox/BottomsUp/Pods/Headers/Public/GoogleParsingUtilities -Xcc -I/Users/choojayson/Dropbox/BottomsUp/Pods/Headers/Public/GoogleSymbolUtilities -Xcc -I/Users/choojayson/Dropbox/BottomsUp/Pods/Headers/Public/GoogleUtilities -Xcc -I/Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Intermediates/Thirst.build/Debug-iphoneos/Thirst.build/DerivedSources/arm64 -Xcc -I/Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Intermediates/Thirst.build/Debug-iphoneos/Thirst.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -DCOCOAPODS=1 -Xcc -working-directory/Users/choojayson/Dropbox/BottomsUp -emit-module-doc-path /Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Intermediates/Thirst.build/Debug-iphoneos/Thirst.build/Objects-normal/arm64/UserDrank~partial.swiftdoc -Onone -module-name Thirst -emit-module-path /Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Intermediates/Thirst.build/Debug-iphoneos/Thirst.build/Objects-normal/arm64/UserDrank~partial.swiftmodule -serialize-diagnostics-path /Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Intermediates/Thirst.build/Debug-iphoneos/Thirst.build/Objects-normal/arm64/UserDrank.dia -emit-dependencies-path /Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Intermediates/Thirst.build/Debug-iphoneos/Thirst.build/Objects-normal/arm64/UserDrank.d -emit-reference-dependencies-path /Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Intermediates/Thirst.build/Debug-iphoneos/Thirst.build/Objects-normal/arm64/UserDrank.swiftdeps -o /Users/choojayson/Library/Developer/Xcode/DerivedData/Thirst-fbgpdykwgpyxllfixfnpenbijinz/Build/Intermediates/Thirst.build/Debug-iphoneos/Thirst.build/Objects-normal/arm64/UserDrank.o -embed-bitcode-marker</p>
| 0debug
|
I've got a logical Error in my first if statement program : <p>I have typed this code in python,</p>
<pre><code>age = int(input("Enter your age: "))
if age < 13:
print("You are a Kid!")
elif (age == 13 and age < 18):
print("You are a teenager!")
else:
print("You are an adult!")
</code></pre>
<p>For the age greater than 13 I'm getting <strong>YOU ARE AN ADULT</strong>
Where did i go wrong? Looking forward for your help :)</p>
| 0debug
|
Sort A String Array By Second Word Based On Specific Format? : I have the following **data**
1. John Smith
2. Tom Cruise
3. Chuck Norris
4. Bill Gates
5. Steve Jobs
** **Explanation** **</br>
</br>
Now as you can see, the data is in specific format, `[ID]. [Firstname] [Lastname]`,
Is there a way to sort this array by firstname?
**Output** Should look something like this
4. Bill Gates
3. Chuck Norris
1. John Smith
5. Steve Jobs
2. Tom Cruise
| 0debug
|
Just need explanation understanding 1 simple line of code. : <p>I was studying a coding challenge in which you need to write a function that counts duplicate occurrences of character patterns in a string and returns how many times it occurs. For example if string is s = 'catcatcat', output is 3. If string s = 'abcdabcd', output is 2. If s = 'catcatcatcatcat', output is 5.The answer ended up being</p>
<pre><code>def function(s):
return max([s.count(s[:x]) for x in range(len(s)) if s[:x]*s.count(s[:x]) == s])
</code></pre>
<p>Can anyone help explain this code because im having trouble understanding. Btw just started learning python. </p>
| 0debug
|
lightweight hardware to send a simple message to a .NET app via wifi : <p>If possible, could someone point me in the direction of some hardware which is capable of using a wifi signal to send a message to a .NET app, which could then pop a push notification on a mobile device? It would have to be a real-time thing, popping messages into a data table to be read when the app is launched will not serve the purpose I require it to, so the app would act constantly as a 'listener'. The contents of the message are not important (1 or 0 would do), what's more important is that the message is sent quickly and that the mobile device receives the message every time.</p>
<p>PS - cheap and lightweight is preferable of course!
Thanks in advance.</p>
| 0debug
|
char *target_strerror(int err)
{
return strerror(target_to_host_errno(err));
| 1threat
|
cassandra cql shell window got disappears after installation in windows : <p>cassandra cql shell window got disappears after installation in windows?
this was installed using MSI installer availalbe in planet cassandra.</p>
<p>Why this happens ? please help me..</p>
<p>Thanks in advance.</p>
| 0debug
|
static void scsi_cd_change_media_cb(void *opaque, bool load)
{
SCSIDiskState *s = opaque;
s->media_changed = load;
s->tray_open = !load;
s->qdev.unit_attention = SENSE_CODE(UNIT_ATTENTION_NO_MEDIUM);
s->media_event = true;
s->eject_request = false;
}
| 1threat
|
PM2 log output limits : <p>I'm happy with how PM2 formats and outputs the log with</p>
<pre><code>pm2 logs app
</code></pre>
<p>But currently it truncates the log to 20 last entries:</p>
<blockquote>
<p>[PM2] Tailing last 20 lines for [app] process
...</p>
</blockquote>
<p>Is there a way to change the limits and output it in a similar manner, but with 1000 lines, for example?</p>
| 0debug
|
How can I get sql results over 100 in apache zeppelin? : <p>When I execute this query in apache-zeppelin I get only 100 results with 'Results are limited by 100.' message.</p>
<pre><code>%sql
SELECT ip
FROM log
</code></pre>
<p>So I appended 'Limit 10000' in SQL query, but it returns only 100 results again.</p>
<pre><code>%sql
SELECT ip
FROM log
LIMIT 10000
</code></pre>
<p>So, How can I get sql results over 100 in zeppelin?</p>
| 0debug
|
Selecting Outter Row for Subtable MS Word VBA : for MS Word tables/vba:
I have a sub-table within a row. When the cursor is placed in the sub-table, I'd like to select the outer table's row. I can't seem to find a way to select the outer row. Your assistance is very much appreciated. Thank you!
| 0debug
|
How to replace a multi-character character constant with one character : <p>I'm attempting to replace <code>'%7C'</code> with a <code>'|'</code> in C but i'm getting a multi-character character constant warning. I was wondering if it was possible to do this and if so how? I was attempting using the code below but it gave this warning.</p>
<p><strong>Parse.c</strong></p>
<pre><code>char *parse(char *command){
char * newCommand = (char *)malloc(sizeof(char)*35);
newCommand = strtok(command, " ");
newCommand = strtok(NULL, "/run?command= ");
for(int i = 0; i<strlen(newCommand); i++){
if(newCommand[i] == '+')
{
newCommand[i] = ' ';
}
if(newCommand[i] == '%7C')
{
newCommand[i] = '|';
}
}
return newCommand;
}
</code></pre>
| 0debug
|
Fastest approach to read thousands of images into one big numpy array : <p>I'm trying to find the fastest approach to read a bunch of images from a directory into a numpy array. My end goal is to compute statistics such as the max, min, and nth percentile of the pixels from all these images. This is straightforward and fast when the pixels from all the images are in one big numpy array, since I can use the inbuilt array methods such as <code>.max</code> and <code>.min</code>, and the <code>np.percentile</code> function.</p>
<p>Below are a few example timings with 25 tiff-images (512x512 pixels). These benchmarks are from using <code>%%timit</code> in a jupyter-notebook. The differences are too small to have any practical implications for just 25 images, but I am intending to read thousands of images in the future.</p>
<pre><code># Imports
import os
import skimage.io as io
import numpy as np
</code></pre>
<ol>
<li><p>Appending to a list</p>
<pre><code>%%timeit
imgs = []
img_path = '/path/to/imgs/'
for img in os.listdir(img_path):
imgs.append(io.imread(os.path.join(img_path, img)))
## 32.2 ms ± 355 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
</code></pre></li>
<li><p>Using a dictionary</p>
<pre><code>%%timeit
imgs = {}
img_path = '/path/to/imgs/'
for img in os.listdir(img_path):
imgs[num] = io.imread(os.path.join(img_path, img))
## 33.3 ms ± 402 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
</code></pre></li>
</ol>
<p>For the list and dictionary approaches above, I tried replacing the loop with a the respective comprehension with similar results time-wise. I also tried preallocating the dictionary keys with no significant difference in the time taken. To get the images from a list to a big array, I would use <code>np.concatenate(imgs)</code>, which only takes ~1 ms.</p>
<ol start="3">
<li><p>Preallocating a numpy array along the first dimension</p>
<pre><code>%%timeit
imgs = np.ndarray((512*25,512), dtype='uint16')
img_path = '/path/to/imgs/'
for num, img in enumerate(os.listdir(img_path)):
imgs[num*512:(num+1)*512, :] = io.imread(os.path.join(img_path, img))
## 33.5 ms ± 804 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
</code></pre></li>
<li><p>Preallocating a numpy along the third dimension</p>
<pre><code>%%timeit
imgs = np.ndarray((512,512,25), dtype='uint16')
img_path = '/path/to/imgs/'
for num, img in enumerate(os.listdir(img_path)):
imgs[:, :, num] = io.imread(os.path.join(img_path, img))
## 71.2 ms ± 2.22 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
</code></pre></li>
</ol>
<p>I initially thought the numpy preallocation approaches would be faster, since there is no dynamic variable expansion in the loop, but this does not seem to be the case. The approach that I find the most intuitive is the last one, where each image occupies a separate dimensions along the third axis of the array, but this is also the slowest. The additional time taken is not due to the preallocation itself, which only takes ~ 1 ms.</p>
<p>I have three question regarding this:</p>
<ol>
<li>Why is the numpy preallocation approaches not faster than the dictionary and list solutions?</li>
<li>Which is the fastest way to read in thousands of images into one big numpy array?</li>
<li>Could I benefit from looking outside numpy and scikit-image, for an even faster module for reading in images? I tried <code>plt.imread()</code>, but the <code>scikit-image.io</code> module is faster.</li>
</ol>
| 0debug
|
int av_image_fill_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width)
{
int i;
const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
int max_step [4];
int max_step_comp[4];
memset(linesizes, 0, 4*sizeof(linesizes[0]));
if (desc->flags & PIX_FMT_HWACCEL)
return AVERROR(EINVAL);
if (desc->flags & PIX_FMT_BITSTREAM) {
linesizes[0] = (width * (desc->comp[0].step_minus1+1) + 7) >> 3;
return 0;
}
av_image_fill_max_pixsteps(max_step, max_step_comp, desc);
for (i = 0; i < 4; i++) {
int s = (max_step_comp[i] == 1 || max_step_comp[i] == 2) ? desc->log2_chroma_w : 0;
linesizes[i] = max_step[i] * (((width + (1 << s) - 1)) >> s);
}
return 0;
}
| 1threat
|
static struct pxa2xx_dma_state_s *pxa2xx_dma_init(target_phys_addr_t base,
qemu_irq irq, int channels)
{
int i, iomemtype;
struct pxa2xx_dma_state_s *s;
s = (struct pxa2xx_dma_state_s *)
qemu_mallocz(sizeof(struct pxa2xx_dma_state_s));
s->channels = channels;
s->chan = qemu_mallocz(sizeof(struct pxa2xx_dma_channel_s) * s->channels);
s->base = base;
s->irq = irq;
s->handler = (pxa2xx_dma_handler_t) pxa2xx_dma_request;
s->req = qemu_mallocz(sizeof(uint8_t) * PXA2XX_DMA_NUM_REQUESTS);
memset(s->chan, 0, sizeof(struct pxa2xx_dma_channel_s) * s->channels);
for (i = 0; i < s->channels; i ++)
s->chan[i].state = DCSR_STOPINTR;
memset(s->req, 0, sizeof(uint8_t) * PXA2XX_DMA_NUM_REQUESTS);
iomemtype = cpu_register_io_memory(0, pxa2xx_dma_readfn,
pxa2xx_dma_writefn, s);
cpu_register_physical_memory(base, 0x0000ffff, iomemtype);
register_savevm("pxa2xx_dma", 0, 0, pxa2xx_dma_save, pxa2xx_dma_load, s);
return s;
}
| 1threat
|
static int encode_ext_header(Wmv2Context *w){
MpegEncContext * const s= &w->s;
PutBitContext pb;
int code;
init_put_bits(&pb, s->avctx->extradata, s->avctx->extradata_size);
put_bits(&pb, 5, s->avctx->time_base.den / s->avctx->time_base.num);
put_bits(&pb, 11, FFMIN(s->bit_rate/1024, 2047));
put_bits(&pb, 1, w->mspel_bit=1);
put_bits(&pb, 1, w->flag3=1);
put_bits(&pb, 1, w->abt_flag=1);
put_bits(&pb, 1, w->j_type_bit=1);
put_bits(&pb, 1, w->top_left_mv_flag=0);
put_bits(&pb, 1, w->per_mb_rl_bit=1);
put_bits(&pb, 3, code=1);
flush_put_bits(&pb);
s->slice_height = s->mb_height / code;
return 0;
}
| 1threat
|
Python Merge the lines between triple single quotes and then replace the starting quote with '#' : '''
Created on Mar 11, 2017
@author: XXZ
This file is to demonstrate the word frequency counter. This is a very
important practical
'''
Required Output:
#Created on Mar 11, 2017 @author: XXZ This file is to demonstrate the word
frequency counter. This is a very important practical
(I want to count it as a comment)
| 0debug
|
str_replace php a string : <p>I have a string</p>
<blockquote>
<p>X_HD003_0</p>
</blockquote>
<p>I have a function PHP</p>
<pre><code>str_replace()
</code></pre>
<p>Ugh......</p>
<p>My result that i want:</p>
<blockquote>
<p>HD003</p>
</blockquote>
<p>^^, some funny from PPAP song, but some string is: X_HD01_1, X_HD0003_2, X_HD12/12/2016/1_01, this string create by: </p>
<blockquote>
<p>"X_" + String + "_Number"</p>
</blockquote>
<p>I want to replace X_ and _Number with str_replace(). Hope everyone can help me! Thank you so much! </p>
| 0debug
|
segfault on copying struct : I have a strcut as following:
struct team_t team =
{
"some string1",
"some string2",
"some string3",
"some string4"
};
Then in another file I create the following function that copies this struct into a new strcut:
void *ucase( struct team_t *team)
{
struct team_t *ucase_team = malloc( sizeof *ucase_team);
memcpy ((char*)ucase_team, (char *)team, sizeof (ucase_team));
return NULL;
}
However, when I want to call `ucase(team)`, I'm getting segfault. I need to use `void *` because this will later be used for shell signals. What am I missing?
| 0debug
|
How to write to file the values returned by a function in python : Here the calc_property_statistics function returns maximum,minimum,average values. I need to write them to a file.
def calc_property_statistics(prop, realisation=0):
values = prop.get_values(realisation)
maximum = np.max(values)
minimum = np.min(values)
average = np.average(values)
print("maximum: {}, minimum: {}, average: {} for property {}".format(
maximum,
minimum,
average,
prop))
return (maximum, minimum, average)
| 0debug
|
yuv2mono_X_c_template(SwsContext *c, const int16_t *lumFilter,
const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrUSrc,
const int16_t **chrVSrc, int chrFilterSize,
const int16_t **alpSrc, uint8_t *dest, int dstW,
int y, enum PixelFormat target)
{
const uint8_t * const d128=dither_8x8_220[y&7];
uint8_t *g = c->table_gU[128] + c->table_gV[128];
int i;
int acc = 0;
for (i = 0; i < dstW - 1; i += 2) {
int j;
int Y1 = 1 << 18;
int Y2 = 1 << 18;
for (j = 0; j < lumFilterSize; j++) {
Y1 += lumSrc[j][i] * lumFilter[j];
Y2 += lumSrc[j][i+1] * lumFilter[j];
}
Y1 >>= 19;
Y2 >>= 19;
if ((Y1 | Y2) & 0x100) {
Y1 = av_clip_uint8(Y1);
Y2 = av_clip_uint8(Y2);
}
acc += acc + g[Y1 + d128[(i + 0) & 7]];
acc += acc + g[Y2 + d128[(i + 1) & 7]];
if ((i & 7) == 6) {
output_pixel(*dest++, acc);
}
}
}
| 1threat
|
Android Studio CMake - shared library missing libc++_shared.so? Can CMake bundle this? : <p>Now that Android Studio 2.2 is released officially, I'm migrating from my old ndk-build process to try and use CMake within AS. As I'm incorporating several codebases from within my company (that I can't edit) that make heavy use of C++11 code (including the dreaded std::to_string() method), the only way I can compile is with a select few configuration options - all of which I discovered earlier when beginning work with ndk-build. (see below)</p>
<p>So everything compiles again and builds into the APK - and I 100% verify that my output shared library exists in the APK, but I'm unable to successfully use <code>System.loadLibrary('mylibrary')</code> - and it turns out this is because the dependency <em>libc++_shared.so</em> is missing. </p>
<p>As in, I get the following error:</p>
<pre><code>java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
</code></pre>
<p>In my old ndk-build process, I always wound up with the 2 libraries (<em>mylibrary.so</em> and <em>libc++_shared.so</em>) in my output folder, which thereby got bundled together into the app. It seems the CMake toolchain isn't bundling <em>libc++_shared.so at all</em> (indeed, it's not found in the APK). </p>
<p>I've been banging my head on this for 6 hours. Can I somehow get the CMake toolchain to bundle this missing library? Any clues?</p>
<p>.</p>
<p>.</p>
<p><strong>My settings:</strong></p>
<p>In gradle.build:</p>
<pre><code>externalNativeBuild {
cmake {
arguments '-DANDROID_STL=c++_shared', '-DANDROID_TOOLCHAIN=gcc', '-DANDROID_PLATFORM=android-16'
}
}
</code></pre>
<p>And my CMakeLists.txt (filenames cut out for brevity):</p>
<pre><code>cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=gnu++11")
include_directories(.)
include_directories(./other)
set(my_SRCS jniInterface.cpp
etc.cpp)
add_library(mylibrary SHARED ${my_SRCS})
target_link_libraries(mylibrary atomic log)
</code></pre>
| 0debug
|
finding the position of an element within a numpy array in python : <p>I want to ask a question about finding the position of an element within an array in Python's numpy package. </p>
<p>I am using Jupyter Notebook for Python 3 and have the following code illustrated below:</p>
<pre><code>concentration_list = array([172.95, 173.97, 208.95])
</code></pre>
<p>and I want to write a block of code that would be able to return the position of an element within the array. </p>
<p>For this purpose, I wanted to use <code>172.95</code> to demonstrate. </p>
<p>Initially, I attempted to use <code>.index()</code>, passing in <code>172.95</code> inside the parentheses but this did not work as numpy does not recognise the <code>.index()</code> method -</p>
<pre><code>concentration_position = concentration_list.index(172.95)
AttributeError: 'numpy.ndarray' object has no attribute 'index'
</code></pre>
<p>The Sci.py documentation did not mention anything about such a method being available when I accessed the site. </p>
<p>Is there any function available (that I may not have discovered) to solve the problem?</p>
| 0debug
|
static abi_long do_fcntl(int fd, int cmd, abi_ulong arg)
{
struct flock fl;
struct target_flock *target_fl;
struct flock64 fl64;
struct target_flock64 *target_fl64;
#ifdef F_GETOWN_EX
struct f_owner_ex fox;
struct target_f_owner_ex *target_fox;
#endif
abi_long ret;
int host_cmd = target_to_host_fcntl_cmd(cmd);
if (host_cmd == -TARGET_EINVAL)
return host_cmd;
switch(cmd) {
case TARGET_F_GETLK:
if (!lock_user_struct(VERIFY_READ, target_fl, arg, 1))
return -TARGET_EFAULT;
fl.l_type =
target_to_host_bitmask(tswap16(target_fl->l_type), flock_tbl);
fl.l_whence = tswap16(target_fl->l_whence);
fl.l_start = tswapal(target_fl->l_start);
fl.l_len = tswapal(target_fl->l_len);
fl.l_pid = tswap32(target_fl->l_pid);
unlock_user_struct(target_fl, arg, 0);
ret = get_errno(fcntl(fd, host_cmd, &fl));
if (ret == 0) {
if (!lock_user_struct(VERIFY_WRITE, target_fl, arg, 0))
return -TARGET_EFAULT;
target_fl->l_type =
host_to_target_bitmask(tswap16(fl.l_type), flock_tbl);
target_fl->l_whence = tswap16(fl.l_whence);
target_fl->l_start = tswapal(fl.l_start);
target_fl->l_len = tswapal(fl.l_len);
target_fl->l_pid = tswap32(fl.l_pid);
unlock_user_struct(target_fl, arg, 1);
}
break;
case TARGET_F_SETLK:
case TARGET_F_SETLKW:
if (!lock_user_struct(VERIFY_READ, target_fl, arg, 1))
return -TARGET_EFAULT;
fl.l_type =
target_to_host_bitmask(tswap16(target_fl->l_type), flock_tbl);
fl.l_whence = tswap16(target_fl->l_whence);
fl.l_start = tswapal(target_fl->l_start);
fl.l_len = tswapal(target_fl->l_len);
fl.l_pid = tswap32(target_fl->l_pid);
unlock_user_struct(target_fl, arg, 0);
ret = get_errno(fcntl(fd, host_cmd, &fl));
break;
case TARGET_F_GETLK64:
if (!lock_user_struct(VERIFY_READ, target_fl64, arg, 1))
return -TARGET_EFAULT;
fl64.l_type =
target_to_host_bitmask(tswap16(target_fl64->l_type), flock_tbl) >> 1;
fl64.l_whence = tswap16(target_fl64->l_whence);
fl64.l_start = tswap64(target_fl64->l_start);
fl64.l_len = tswap64(target_fl64->l_len);
fl64.l_pid = tswap32(target_fl64->l_pid);
unlock_user_struct(target_fl64, arg, 0);
ret = get_errno(fcntl(fd, host_cmd, &fl64));
if (ret == 0) {
if (!lock_user_struct(VERIFY_WRITE, target_fl64, arg, 0))
return -TARGET_EFAULT;
target_fl64->l_type =
host_to_target_bitmask(tswap16(fl64.l_type), flock_tbl) >> 1;
target_fl64->l_whence = tswap16(fl64.l_whence);
target_fl64->l_start = tswap64(fl64.l_start);
target_fl64->l_len = tswap64(fl64.l_len);
target_fl64->l_pid = tswap32(fl64.l_pid);
unlock_user_struct(target_fl64, arg, 1);
}
break;
case TARGET_F_SETLK64:
case TARGET_F_SETLKW64:
if (!lock_user_struct(VERIFY_READ, target_fl64, arg, 1))
return -TARGET_EFAULT;
fl64.l_type =
target_to_host_bitmask(tswap16(target_fl64->l_type), flock_tbl) >> 1;
fl64.l_whence = tswap16(target_fl64->l_whence);
fl64.l_start = tswap64(target_fl64->l_start);
fl64.l_len = tswap64(target_fl64->l_len);
fl64.l_pid = tswap32(target_fl64->l_pid);
unlock_user_struct(target_fl64, arg, 0);
ret = get_errno(fcntl(fd, host_cmd, &fl64));
break;
case TARGET_F_GETFL:
ret = get_errno(fcntl(fd, host_cmd, arg));
if (ret >= 0) {
ret = host_to_target_bitmask(ret, fcntl_flags_tbl);
}
break;
case TARGET_F_SETFL:
ret = get_errno(fcntl(fd, host_cmd, target_to_host_bitmask(arg, fcntl_flags_tbl)));
break;
#ifdef F_GETOWN_EX
case TARGET_F_GETOWN_EX:
ret = get_errno(fcntl(fd, host_cmd, &fox));
if (ret >= 0) {
if (!lock_user_struct(VERIFY_WRITE, target_fox, arg, 0))
return -TARGET_EFAULT;
target_fox->type = tswap32(fox.type);
target_fox->pid = tswap32(fox.pid);
unlock_user_struct(target_fox, arg, 1);
}
break;
#endif
#ifdef F_SETOWN_EX
case TARGET_F_SETOWN_EX:
if (!lock_user_struct(VERIFY_READ, target_fox, arg, 1))
return -TARGET_EFAULT;
fox.type = tswap32(target_fox->type);
fox.pid = tswap32(target_fox->pid);
unlock_user_struct(target_fox, arg, 0);
ret = get_errno(fcntl(fd, host_cmd, &fox));
break;
#endif
case TARGET_F_SETOWN:
case TARGET_F_GETOWN:
case TARGET_F_SETSIG:
case TARGET_F_GETSIG:
case TARGET_F_SETLEASE:
case TARGET_F_GETLEASE:
ret = get_errno(fcntl(fd, host_cmd, arg));
break;
default:
ret = get_errno(fcntl(fd, cmd, arg));
break;
}
return ret;
}
| 1threat
|
How can i use this if i'm using two class together using jquery? : I have to select two classes but there is one issue if i want to use this just for single class how can i use that? Like given below:-
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
$('.city-selector ul li, .city-selector-close').click(function () {
var selectedCity = $(this).text();
$('.selected-city span').text(selectedCity);
})
<!-- language: lang-css -->
.city-selector-close{float:right;}
<!-- language: lang-html -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="city-selector-close">X</div>
<div class="city-selector">
<ul>
<li class="active">Gurgaon</li>
<li>Delhi</li>
<li>Noida</li>
<li>Faridabad</li>
</ul>
</div>
<div class="selected-city"><span>Gurgaon</span></div>
<!-- end snippet -->
in above example everything working fine like which city i want to select. I'm able to select but there is one issue when i select two class together `.city-selector ul li, .city-selector-close` and i just want to get text of clicked class
Still everything working fine but when i click on close then it will be also working like selected city how to solve this issue with this approach?
| 0debug
|
void virtio_notify(VirtIODevice *vdev, VirtQueue *vq)
{
if ((vq->inuse || vring_avail_idx(vq) != vq->last_avail_idx) &&
(vring_avail_flags(vq) & VRING_AVAIL_F_NO_INTERRUPT))
return;
vdev->isr |= 0x01;
virtio_update_irq(vdev);
}
| 1threat
|
C++ and for/in (?) loops : <p>I'm a bit rusty on C++ (still). Will the "getChildren()" function to the right be called every loop?</p>
<pre><code>for (Node* node : this->m_stage->getChildren()) {
}
</code></pre>
<p>On a side note, what would be the name of this kind of loop? </p>
| 0debug
|
not able to print the list, please rectify errors? : #This program is to find the normalization of a vector
#Def function
def _unit_vector_sample_(vector):
# calculate the magnitude
x = vector[0]
y = vector[1]
z = vector[2]
mag = ((x**2) + (y**2) + (z**2))**(1/2)
# normalize the vector by dividing each component with the magnitude
new_x = x/mag
new_y = y/mag
new_z = z/mag
unit_vector = [new_x, new_y, new_z]
#return unit_vector
#Main program
vector=[2,3,-4]
def _unit_vector_sample_(vector):
print(unit_vector)
| 0debug
|
Hello , I want to create a javafx TextField where the user can only input in the current order A11111111A : <p>So the first and last input should be letters, and between them should be only numbers. Here is my code : </p>
<pre><code>tf.textProperty().addListener(new ChangeListener<String>() {
public void changed(final ObservableValue<? extends String> ov, final String oldValue, final String newValue) {
String text_of_first_letter = tf.getText().substring(0, 1);
if (tf.getText().length() > 1 ) {
if(!newValue.matches("\\d*")) {
tf.setText(newValue.replaceFirst("[^\\d]", ""));
}
}
else if(tf.getText().length() == 1){
System.out.println("ktu");
tf.setText(newValue.replaceFirst("[^\\d]", text_of_first_letter));
}
}
});
</code></pre>
| 0debug
|
void command_loop(void)
{
int c, i, j = 0, done = 0, fetchable = 0, prompted = 0;
char *input;
char **v;
const cmdinfo_t *ct;
for (i = 0; !done && i < ncmdline; i++) {
input = strdup(cmdline[i]);
if (!input) {
fprintf(stderr, _("cannot strdup command '%s': %s\n"),
cmdline[i], strerror(errno));
exit(1);
}
v = breakline(input, &c);
if (c) {
ct = find_command(v[0]);
if (ct) {
if (ct->flags & CMD_FLAG_GLOBAL) {
done = command(ct, c, v);
} else {
j = 0;
while (!done && (j = args_command(j))) {
done = command(ct, c, v);
}
}
} else {
fprintf(stderr, _("command \"%s\" not found\n"), v[0]);
}
}
doneline(input, v);
}
if (cmdline) {
free(cmdline);
return;
}
while (!done) {
if (!prompted) {
printf("%s", get_prompt());
fflush(stdout);
qemu_aio_set_fd_handler(STDIN_FILENO, prep_fetchline, NULL, NULL,
NULL, &fetchable);
prompted = 1;
}
qemu_aio_wait();
if (!fetchable) {
continue;
}
input = fetchline();
if (input == NULL) {
break;
}
v = breakline(input, &c);
if (c) {
ct = find_command(v[0]);
if (ct) {
done = command(ct, c, v);
} else {
fprintf(stderr, _("command \"%s\" not found\n"), v[0]);
}
}
doneline(input, v);
prompted = 0;
fetchable = 0;
}
qemu_aio_set_fd_handler(STDIN_FILENO, NULL, NULL, NULL, NULL, NULL);
}
| 1threat
|
Not allowed to set the device owner because there are already several users on the device : <p>I was following this <a href="https://sdgsystems.com/blog/implementing-kiosk-mode-android-part-3-android-lollipop" rel="noreferrer">tutorial</a> to set the app as device owner. In that tutorial, there is a section 'Using adb to set the device owner'. The tutorial here says that after installing the Kiosk Mode Demo App, run the following command:</p>
<pre><code>adb shell dpm set-device-owner sdg.example.kiosk_mode/.AdminReceiver
</code></pre>
<p>This gave me the error:</p>
<pre><code>adb server is out of date. killing...
* daemon started successfully *
java.lang.IllegalStateException: Not allowed to set the device owner because there are already several users on the device
at android.os.Parcel.readException(Parcel.java:1629)
at android.os.Parcel.readException(Parcel.java:1574)
at android.app.admin.IDevicePolicyManager$Stub$Proxy.setDeviceOwner(IDevicePolicyManager.java:5146)
at com.android.commands.dpm.Dpm.runSetDeviceOwner(Dpm.java:114)
at com.android.commands.dpm.Dpm.onRun(Dpm.java:82)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
at com.android.commands.dpm.Dpm.main(Dpm.java:38)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:257)
</code></pre>
<p>I followed this <a href="https://stackoverflow.com/questions/36731277/adb-server-is-out-of-date-killing">SO link</a> and the answer of Diego Plascencia Lara helped me to get rid of </p>
<pre><code>adb server is out of date. killing...
* daemon started successfully *
</code></pre>
<p>But still the following error is occurring after running the <code>adb shell dpm set-device-owner sdg.example.kiosk_mode/.AdminReceiver</code> command:</p>
<pre><code>java.lang.IllegalStateException: Not allowed to set the device owner because there are already several users on the device
at android.os.Parcel.readException(Parcel.java:1629)
at android.os.Parcel.readException(Parcel.java:1574)
at android.app.admin.IDevicePolicyManager$Stub$Proxy.setDeviceOwner(IDevicePolicyManager.java:5146)
at com.android.commands.dpm.Dpm.runSetDeviceOwner(Dpm.java:114)
at com.android.commands.dpm.Dpm.onRun(Dpm.java:82)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
at com.android.commands.dpm.Dpm.main(Dpm.java:38)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:257)
</code></pre>
<p>Why is this error happening and how can I remove this? I had earlier tried to set different apps as device owner but I think I did not manage to pull them off entirely and there were always some errors while completing the entire procedure of getting the app running on the device.</p>
| 0debug
|
Hi, it's Satof how i can add EditText in android studio/Kotlin with delete button in same EditText : how i can add EditText in android studio/Kotlin with delete button in same EditText
the button visible if the edit text have Text
and Invisible if Not
Thanks...
| 0debug
|
static uint64_t qemu_opt_get_number_helper(QemuOpts *opts, const char *name,
uint64_t defval, bool del)
{
QemuOpt *opt = qemu_opt_find(opts, name);
uint64_t ret = defval;
if (opt == NULL) {
const QemuOptDesc *desc = find_desc_by_name(opts->list->desc, name);
if (desc && desc->def_value_str) {
parse_option_number(name, desc->def_value_str, &ret, &error_abort);
}
return ret;
}
assert(opt->desc && opt->desc->type == QEMU_OPT_NUMBER);
ret = opt->value.uint;
if (del) {
qemu_opt_del_all(opts, name);
}
return ret;
}
| 1threat
|
def rectangle_area(l,b):
area=l*b
return area
| 0debug
|
static void console_putchar(TextConsole *s, int ch)
{
TextCell *c;
int y1, i;
int x, y;
switch(s->state) {
case TTY_STATE_NORM:
switch(ch) {
case '\r':
s->x = 0;
break;
case '\n':
console_put_lf(s);
break;
case '\b':
if (s->x > 0)
s->x--;
break;
case '\t':
if (s->x + (8 - (s->x % 8)) > s->width) {
s->x = 0;
console_put_lf(s);
} else {
s->x = s->x + (8 - (s->x % 8));
}
break;
case '\a':
break;
case 14:
break;
case 15:
break;
case 27:
s->state = TTY_STATE_ESC;
break;
default:
if (s->x >= s->width) {
s->x = 0;
console_put_lf(s);
}
y1 = (s->y_base + s->y) % s->total_height;
c = &s->cells[y1 * s->width + s->x];
c->ch = ch;
c->t_attrib = s->t_attrib;
update_xy(s, s->x, s->y);
s->x++;
break;
}
break;
case TTY_STATE_ESC:
if (ch == '[') {
for(i=0;i<MAX_ESC_PARAMS;i++)
s->esc_params[i] = 0;
s->nb_esc_params = 0;
s->state = TTY_STATE_CSI;
} else {
s->state = TTY_STATE_NORM;
}
break;
case TTY_STATE_CSI:
if (ch >= '0' && ch <= '9') {
if (s->nb_esc_params < MAX_ESC_PARAMS) {
s->esc_params[s->nb_esc_params] =
s->esc_params[s->nb_esc_params] * 10 + ch - '0';
}
} else {
s->nb_esc_params++;
if (ch == ';')
break;
#ifdef DEBUG_CONSOLE
fprintf(stderr, "escape sequence CSI%d;%d%c, %d parameters\n",
s->esc_params[0], s->esc_params[1], ch, s->nb_esc_params);
#endif
s->state = TTY_STATE_NORM;
switch(ch) {
case 'A':
if (s->esc_params[0] == 0) {
s->esc_params[0] = 1;
}
s->y -= s->esc_params[0];
if (s->y < 0) {
s->y = 0;
}
break;
case 'B':
if (s->esc_params[0] == 0) {
s->esc_params[0] = 1;
}
s->y += s->esc_params[0];
if (s->y >= s->height) {
s->y = s->height - 1;
}
break;
case 'C':
if (s->esc_params[0] == 0) {
s->esc_params[0] = 1;
}
s->x += s->esc_params[0];
if (s->x >= s->width) {
s->x = s->width - 1;
}
break;
case 'D':
if (s->esc_params[0] == 0) {
s->esc_params[0] = 1;
}
s->x -= s->esc_params[0];
if (s->x < 0) {
s->x = 0;
}
break;
case 'G':
s->x = s->esc_params[0] - 1;
if (s->x < 0) {
s->x = 0;
}
break;
case 'f':
case 'H':
s->x = s->esc_params[1] - 1;
if (s->x < 0) {
s->x = 0;
}
s->y = s->esc_params[0] - 1;
if (s->y < 0) {
s->y = 0;
}
break;
case 'J':
switch (s->esc_params[0]) {
case 0:
for (y = s->y; y < s->height; y++) {
for (x = 0; x < s->width; x++) {
if (y == s->y && x < s->x) {
continue;
}
console_clear_xy(s, x, y);
}
}
break;
case 1:
for (y = 0; y <= s->y; y++) {
for (x = 0; x < s->width; x++) {
if (y == s->y && x > s->x) {
break;
}
console_clear_xy(s, x, y);
}
}
break;
case 2:
for (y = 0; y <= s->height; y++) {
for (x = 0; x < s->width; x++) {
console_clear_xy(s, x, y);
}
}
break;
}
break;
case 'K':
switch (s->esc_params[0]) {
case 0:
for(x = s->x; x < s->width; x++) {
console_clear_xy(s, x, s->y);
}
break;
case 1:
for (x = 0; x <= s->x; x++) {
console_clear_xy(s, x, s->y);
}
break;
case 2:
for(x = 0; x < s->width; x++) {
console_clear_xy(s, x, s->y);
}
break;
}
break;
case 'm':
console_handle_escape(s);
break;
case 'n':
break;
case 's':
s->x_saved = s->x;
s->y_saved = s->y;
break;
case 'u':
s->x = s->x_saved;
s->y = s->y_saved;
break;
default:
#ifdef DEBUG_CONSOLE
fprintf(stderr, "unhandled escape character '%c'\n", ch);
#endif
break;
}
break;
}
}
}
| 1threat
|
int nbd_init(int fd, int csock, uint32_t flags, off_t size, size_t blocksize)
{
TRACE("Setting NBD socket");
if (ioctl(fd, NBD_SET_SOCK, csock) < 0) {
int serrno = errno;
LOG("Failed to set NBD socket");
errno = serrno;
return -1;
}
TRACE("Setting block size to %lu", (unsigned long)blocksize);
if (ioctl(fd, NBD_SET_BLKSIZE, blocksize) < 0) {
int serrno = errno;
LOG("Failed setting NBD block size");
errno = serrno;
return -1;
}
TRACE("Setting size to %zd block(s)", (size_t)(size / blocksize));
if (ioctl(fd, NBD_SET_SIZE_BLOCKS, size / blocksize) < 0) {
int serrno = errno;
LOG("Failed setting size (in blocks)");
errno = serrno;
return -1;
}
if (flags & NBD_FLAG_READ_ONLY) {
int read_only = 1;
TRACE("Setting readonly attribute");
if (ioctl(fd, BLKROSET, (unsigned long) &read_only) < 0) {
int serrno = errno;
LOG("Failed setting read-only attribute");
errno = serrno;
return -1;
}
}
if (ioctl(fd, NBD_SET_FLAGS, flags) < 0
&& errno != ENOTTY) {
int serrno = errno;
LOG("Failed setting flags");
errno = serrno;
return -1;
}
TRACE("Negotiation ended");
return 0;
}
| 1threat
|
perl code to decode json array to find the last value of a variable : I have a Json array of objects that I am trying to decode in perl. The json array looks like this :
[
{ "name":"a123",
"enroll":"12a123",
"cs":{
"year1":{
"status"{
"oldvalue":"pending",
"new value": "complete"
}
}
}
},
{ "name":"b123",
"enroll":"12b123",
"ecm":{
"year1":{
"flag"{
"oldvalue":"null",
"new value": "ok"
}
}
}
},
{ "name":"c123",
"enroll":"12c123",
"cs":{
"year1":{
"status"{
"oldvalue":"complete",
"new value": "run new"
}
}
}
}
]
I want to find the value of the {"status"}->{"new value"} from the last occurrence in the Json file.The output here should be "run new". FYI : not all fields are present in every object. Any help on how to parse this array will be highly appreciated.
Thanks in advance.
| 0debug
|
Float divs in bootstrap : <p>How can i get the result, that you can see on the picture? I the col-md-4 divs, i want the 2 divs next to each other. The ikon to the left side, and text next to the ikon.</p>
<p>What i tried, witout any custom css:
Whit this code, the to divs are under each other, and not floating.</p>
<pre><code>echo '<div class="col-md-4 elony">
<div class="elony_ikon_div pull-left">'.$elony['elony_ikon'].'</div>
<div class="pull-right">
<span class="elony_nev">'.$elony['elony_nev'].'</span>
<p class="elony_text">'.$elony['elony_text'].'</p>
</div>
<div class="clearfix"></div>
</div>';
</code></pre>
<p><a href="https://i.stack.imgur.com/HYsAf.jpg" rel="nofollow noreferrer">enter image description here</a></p>
| 0debug
|
What does read-after-write consistency really mean on new object PUT in S3? : <p>Amazon documentation (<a href="http://docs.aws.amazon.com/AmazonS3/latest/dev/Introduction.html#ConsistencyModel" rel="noreferrer">http://docs.aws.amazon.com/AmazonS3/latest/dev/Introduction.html#ConsistencyModel</a>) states: </p>
<p>"Amazon S3 provides read-after-write consistency for PUTS of new objects in your S3 bucket in all regions with one caveat." </p>
<p>Ignoring the caveat, this means that a client issuing a GET following a PUT for a new object is guaranteed to get the correct result. My question is, would the guarantee also apply if the GET is issued from a different client not the one which did the PUT (assuming of course the GET follows the PUT chronologically)? In other words, is read-after-write consistency simply read-your-write consistency or it works for all clients? </p>
<p>I suspect the answer is that it works globally but can't find a definitive answer. </p>
| 0debug
|
static void process_incoming_migration_co(void *opaque)
{
QEMUFile *f = opaque;
MigrationIncomingState *mis = migration_incoming_get_current();
PostcopyState ps;
int ret;
mis->from_src_file = f;
mis->largest_page_size = qemu_ram_pagesize_largest();
postcopy_state_set(POSTCOPY_INCOMING_NONE);
migrate_set_state(&mis->state, MIGRATION_STATUS_NONE,
MIGRATION_STATUS_ACTIVE);
ret = qemu_loadvm_state(f);
ps = postcopy_state_get();
trace_process_incoming_migration_co_end(ret, ps);
if (ps != POSTCOPY_INCOMING_NONE) {
if (ps == POSTCOPY_INCOMING_ADVISE) {
postcopy_ram_incoming_cleanup(mis);
} else if (ret >= 0) {
trace_process_incoming_migration_co_postcopy_end_main();
return;
}
}
if (!ret && migration_incoming_enable_colo()) {
mis->migration_incoming_co = qemu_coroutine_self();
qemu_thread_create(&mis->colo_incoming_thread, "COLO incoming",
colo_process_incoming_thread, mis, QEMU_THREAD_JOINABLE);
mis->have_colo_incoming_thread = true;
qemu_coroutine_yield();
qemu_thread_join(&mis->colo_incoming_thread);
}
qemu_fclose(f);
free_xbzrle_decoded_buf();
if (ret < 0) {
migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,
MIGRATION_STATUS_FAILED);
error_report("load of migration failed: %s", strerror(-ret));
migrate_decompress_threads_join();
exit(EXIT_FAILURE);
}
mis->bh = qemu_bh_new(process_incoming_migration_bh, mis);
qemu_bh_schedule(mis->bh);
}
| 1threat
|
How to split domain-part from emailId in android? : I am making validation in email id in which I want to make condition for domain-part after "." not more than 255 character. for this I want to split domain-part after "." like "user@gmail.commmm" in this I want to split after ".".How can I do that
code:-
/*validation for email*/
private boolean isValidEmail(String email) {// validation for email Id
boolean isValid = false;
String expression = "^([_A-Za-z0-9-\\+])+(\\.[_A-Za-z0-9-]+)*@" + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,255})$";
Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(email);
if (matcher.matches()) {
isValid = true;
}
return isValid;
}
| 0debug
|
static double get_qscale(MpegEncContext *s, RateControlEntry *rce, double rate_factor, int frame_num){
RateControlContext *rcc= &s->rc_context;
AVCodecContext *a= s->avctx;
double q, bits;
const int pict_type= rce->new_pict_type;
const double mb_num= s->mb_num;
int i;
double const_values[]={
M_PI,
M_E,
rce->i_tex_bits*rce->qscale,
rce->p_tex_bits*rce->qscale,
(rce->i_tex_bits + rce->p_tex_bits)*(double)rce->qscale,
rce->mv_bits/mb_num,
rce->pict_type == B_TYPE ? (rce->f_code + rce->b_code)*0.5 : rce->f_code,
rce->i_count/mb_num,
rce->mc_mb_var_sum/mb_num,
rce->mb_var_sum/mb_num,
rce->pict_type == I_TYPE,
rce->pict_type == P_TYPE,
rce->pict_type == B_TYPE,
rcc->qscale_sum[pict_type] / (double)rcc->frame_count[pict_type],
a->qcompress,
rcc->i_cplx_sum[I_TYPE] / (double)rcc->frame_count[I_TYPE],
rcc->i_cplx_sum[P_TYPE] / (double)rcc->frame_count[P_TYPE],
rcc->p_cplx_sum[P_TYPE] / (double)rcc->frame_count[P_TYPE],
rcc->p_cplx_sum[B_TYPE] / (double)rcc->frame_count[B_TYPE],
(rcc->i_cplx_sum[pict_type] + rcc->p_cplx_sum[pict_type]) / (double)rcc->frame_count[pict_type],
0
};
bits= ff_parse_eval(rcc->rc_eq_eval, const_values, rce);
if (isnan(bits)) {
av_log(s->avctx, AV_LOG_ERROR, "Error evaluating rc_eq \"%s\"\n", s->avctx->rc_eq);
return -1;
}
rcc->pass1_rc_eq_output_sum+= bits;
bits*=rate_factor;
if(bits<0.0) bits=0.0;
bits+= 1.0;
for(i=0; i<s->avctx->rc_override_count; i++){
RcOverride *rco= s->avctx->rc_override;
if(rco[i].start_frame > frame_num) continue;
if(rco[i].end_frame < frame_num) continue;
if(rco[i].qscale)
bits= qp2bits(rce, rco[i].qscale);
else
bits*= rco[i].quality_factor;
}
q= bits2qp(rce, bits);
if (pict_type==I_TYPE && s->avctx->i_quant_factor<0.0)
q= -q*s->avctx->i_quant_factor + s->avctx->i_quant_offset;
else if(pict_type==B_TYPE && s->avctx->b_quant_factor<0.0)
q= -q*s->avctx->b_quant_factor + s->avctx->b_quant_offset;
return q;
}
| 1threat
|
how to pass id from javacript to laravel php script? : <p>i am technically new to javascript and trying to pass a value to php script to use it in where clause...</p>
<p><strong>Blade html</strong> </p>
<pre><code> <div class="tab-content blog_tabs">
<div class="tab-pane" name="schedule" id="" >
<?php
$tabSchedule = App\Schedule::where('route_id', )
->latest()
->get();
?>
@foreach ($tabSchedule as $schedule)
<ul class="list-group">
<li class="list-group-item">{{ $schedule->schedule_number}}</li>
</ul>
@endforeach
</div>
</div>
</div>
</code></pre>
<p><strong>javascript</strong></p>
<pre><code>$("ul.nav-tabs > li > a").click(function() {
var id = $(this).attr("href").replace("#", "");
console.log(id);
if(id) {
$.ajax({
url: "{{ route('user.schedule.getId') }}",
type: "GET",
data:{'id':id},
dataType: "json",
success:function(data) {
var route_id = 1;
}
});
}
});
</code></pre>
<p>So here is a picture of what i want to pass:</p>
<p><a href="https://i.stack.imgur.com/oJuNi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oJuNi.png" alt="enter image description here"></a></p>
<p><strong><em>As picture tells i am trying to pass route_id to laravel php script to use it in where clause</em></strong></p>
<p>If any one, please help me out? thanks!</p>
| 0debug
|
void uninit_opts(void)
{
int i;
for (i = 0; i < AVMEDIA_TYPE_NB; i++)
av_freep(&avcodec_opts[i]);
av_freep(&avformat_opts->key);
av_freep(&avformat_opts);
#if CONFIG_SWSCALE
av_freep(&sws_opts);
#endif
for (i = 0; i < opt_name_count; i++) {
if (opt_values[i]) {
av_freep(&opt_names[i]);
av_freep(&opt_values[i]);
}
}
av_freep(&opt_names);
av_freep(&opt_values);
}
| 1threat
|
Find default pip index-url : <p>Is there a way to find which url(s) my pip command will look for when running something like <code>pip install <package></code>?</p>
<p>You can configure files like <code>.pip/pip.conf</code> and <code>.pypirc</code> to modify that default but I'd like to know if there is a way to know the mirror priority.</p>
<p>Can I look for something specific running a command with the verbose flag (<code>-v</code>)?</p>
| 0debug
|
Fast impertive pointers (static, unboxing, etc.) with Struct library : <p>I am interested in using more efficient pointers for a project implementing an imperative language in Haskell. There is already a <a href="https://github.com/ekmett/structs" rel="noreferrer">library for that: Struct</a>. There is a <a href="https://www.schoolofhaskell.com/user/edwardk/unlifted-structures" rel="noreferrer">blog post</a> on it and <a href="http://ekmett.github.io/structs/Data-Struct.html" rel="noreferrer">brief documentation</a>.</p>
<p>The problem is there is only a quite sophisticated example of <a href="https://github.com/ekmett/structs/blob/master/src/Data/Struct/Internal/LinkCut.hs" rel="noreferrer">linkcut trees</a>. For someone like me who doesn't use Haskell on a daily basis, it is quite exhausting to battle little documented code, template haskell, etc.</p>
<p>I would need a simpler example to get started, along the lines of expressing either of those two data types:</p>
<pre><code>import Data.IORef
data DLL a = DLL a (Maybe (IORef (DLL a))) (Maybe (IORef (DLL a)))
data DLLINT = DLLINT Int (Maybe (IORef DLLINT)) (Maybe (IORef DLLINT))
</code></pre>
<p>This should be just a few simple lines for someone who is fluent in Haskell/GHC.</p>
<p>How do I express one of the data types above with the Struct library?</p>
| 0debug
|
Refreshing data periodically using SignalR rather than broadcasting to clients : <p>I display some of the data i.e. Sum, Average and Total on a page and want to update them after the data changed using SignalR. Most of the examples uses the following approach that broadcast all of the clients after create / update / delete methods (that change data) are executed:</p>
<pre><code>private void BroadcastDataChange(Data data)
{
Clients.All.dataChanged();
}
</code></pre>
<p>However, I am wondering if there is a smarter approach that let me update the data i.e. periodically refreshing without broadcast in each of the create-update-delete methods (I do not use SqlDependency, etc, juts using SignalR). On the other hand, I am not sure this kind of approach is contradictory to the SignalR logic. This is the first time I use SİgnalR and I am too confused :( Any help would be appreciated.</p>
| 0debug
|
Enable select2 multi-select search box : <p>I need to be able to add a search box to my multi-select fields using select2.</p>
<p>For whatever reason, while search boxes appear as expected in single-select fields, the same select2() call on a multi-select field does not add a search box.</p>
<pre><code>var data = []; // Programatically-generated options array with > 5 options
var placeholder = "select";
$(".mySelect").select2({
data: data,
placeholder: placeholder,
allowClear: false,
minimumResultsForSearch: 5});
</code></pre>
<p>Does select2 not support search boxes with multi-selects? Does anyone have a good similarly-functioning alternative?</p>
| 0debug
|
start_xmit(E1000State *s)
{
PCIDevice *d = PCI_DEVICE(s);
dma_addr_t base;
struct e1000_tx_desc desc;
uint32_t tdh_start = s->mac_reg[TDH], cause = E1000_ICS_TXQE;
if (!(s->mac_reg[TCTL] & E1000_TCTL_EN)) {
DBGOUT(TX, "tx disabled\n");
return;
}
while (s->mac_reg[TDH] != s->mac_reg[TDT]) {
base = tx_desc_base(s) +
sizeof(struct e1000_tx_desc) * s->mac_reg[TDH];
pci_dma_read(d, base, &desc, sizeof(desc));
DBGOUT(TX, "index %d: %p : %x %x\n", s->mac_reg[TDH],
(void *)(intptr_t)desc.buffer_addr, desc.lower.data,
desc.upper.data);
process_tx_desc(s, &desc);
cause |= txdesc_writeback(s, base, &desc);
if (++s->mac_reg[TDH] * sizeof(desc) >= s->mac_reg[TDLEN])
s->mac_reg[TDH] = 0;
if (s->mac_reg[TDH] == tdh_start) {
DBGOUT(TXERR, "TDH wraparound @%x, TDT %x, TDLEN %x\n",
tdh_start, s->mac_reg[TDT], s->mac_reg[TDLEN]);
break;
}
}
set_ics(s, 0, cause);
}
| 1threat
|
connection.query('SELECT * FROM users WHERE username = ' + input_string)
| 1threat
|
Error - php propel init : I guys! I have a problem when I start my project with Propel.
I leave the error below, Thanks!
<!-- begin snippet: js hide: false -->
<!-- language: lang-html -->
Nicolass-MacBook-Pro:api Nico$ php propel init
Fatal error: Class 'Symfony\Component\Console\Helper\DialogHelper' not found in /Applications/XAMPP/xamppfiles/htdocs/rmanager/api/vendor/propel/propel/src/Propel/Generator/Command/Helper/DialogHelper.php on line 8
<!-- end snippet -->
| 0debug
|
go time.Parse, format "02/01/2006" is valid but "02/01/2003" not : <p>Why the first format is valid but the second not</p>
<pre><code>package main
import (
"fmt"
"time"
)
func main() {
date := "21/07/1993"
in := "02/01/2006"
out := "02-01-2006"
dt, err := time.Parse(in, date)
if err != nil {
fmt.Println(err)
}
fmt.Println(dt.Format(out))
date = "21/07/1993"
in = "02/01/2003"
out = "02-01-2003"
dt, err = time.Parse(in, date)
if err != nil {
fmt.Println(err)
}
fmt.Println(dt.Format(out))
}
</code></pre>
<p>Output</p>
<pre><code>21-07-1993
parsing time "21/07/1993" as "02/01/2003": cannot parse "93" as "0"
01-01-1012
</code></pre>
<p><a href="https://play.golang.org/p/Ht0XZVs54ta" rel="nofollow noreferrer">https://play.golang.org/p/Ht0XZVs54ta</a></p>
| 0debug
|
Please help me to understand below groovy script function? : def writeTestCasePropertiesToFile = {
//Get the test case properties as Properties object
def properties = context.testCase.properties.keySet().inject([:]){map, key -> map[key] = context.testCase.getPropertyValue(key); map as Properties}
log.info properties
assert properties instanceof Properties
properties?.store(new File(propFileName).newWriter(), null)
}
| 0debug
|
How to read QR code from static image : <p>I know that you can use <code>AVFoundation</code> to scan a QR code using the device's camera. Now here comes the problem, how can I do this from an static <code>UIImage</code> object?</p>
| 0debug
|
Crash with java.lang.NoClassDefFoundError after migrating to AndroidX : <p>I'm trying to compile and run a demo app that was written for an old Android version.</p>
<p>I have updated all the files to use the new androidx libraries. That included the gradle.build the manifest and layout files.
It compiles properly but crashes on the main activity on <code>setContentView(R.layout.activity_main);</code></p>
<p>From looking at the stack trace I can deduce that its related to the layout.xml file as the app crash when it set for the first time.
But I could not find any problem with the layout file after migrating the FloatingActionButton from the old to the new deisgn librarey.</p>
<p>Any ideas?</p>
<p>Stack:</p>
<pre><code>I/zygote: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2423)
at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:750)
at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:630)
at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:529)
at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:161)
at void com.example.android.emojify.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:75)
at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6975)
at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1213)
at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2770)
at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2892)
I/zygote: at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1593)
I/zygote: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
at void android.os.Looper.loop() (Looper.java:164)
at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6541)
at java.lang.Object
</code></pre>
<p>build.gradle:</p>
<pre><code>apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.android.emojify"
minSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.google.android.material:material:1.1.0-alpha07'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.gms:play-services-vision:17.0.2'
implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
implementation 'com.jakewharton.timber:timber:4.7.1'
testImplementation 'junit:junit:4.12'
}
</code></pre>
<p>and layout file:</p>
<pre><code><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:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.android.emojify.MainActivity">
<ImageView
android:id="@+id/image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/view_margin"
android:contentDescription="@string/imageview_description"
android:scaleType="fitStart" />
<TextView
android:id="@+id/title_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/emojify_button"
android:layout_centerHorizontal="true"
android:layout_margin="@dimen/view_margin"
android:text="@string/emojify_me"
android:textAppearance="@style/TextAppearance.AppCompat.Display1" />
<Button
android:id="@+id/emojify_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/go"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/clear_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/ic_clear"
android:visibility="gone"
app:backgroundTint="@android:color/white"
app:fabSize="mini" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/save_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="@dimen/fab_margins"
android:layout_marginEnd="@dimen/fab_margins"
android:layout_marginRight="@dimen/fab_margins"
android:src="@drawable/ic_save"
android:visibility="gone"
app:backgroundTint="@android:color/white" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/share_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="@dimen/fab_margins"
android:layout_marginLeft="@dimen/fab_margins"
android:layout_marginStart="@dimen/fab_margins"
android:src="@drawable/ic_share"
android:visibility="gone"
app:backgroundTint="@android:color/white" />
</RelativeLayout>
</code></pre>
| 0debug
|
void cpu_exec_exit(CPUState *cpu)
{
if (cpu->cpu_index == -1) {
return;
}
bitmap_clear(cpu_index_map, cpu->cpu_index, 1);
cpu->cpu_index = -1;
}
| 1threat
|
How to Replace a PHP File With an Existing PHP File : <p>So currently I have two PHP files, they are identical. There is a function that updates the current file being used to add data and also a clear function. I want the clear function on the first file to replace itself with the content of the second. </p>
| 0debug
|
connection.query('SELECT * FROM users WHERE username = ' + input_string)
| 1threat
|
static int update_wrap_reference(AVFormatContext *s, AVStream *st, int stream_index)
{
if (s->correct_ts_overflow && st->pts_wrap_bits != 64 &&
st->pts_wrap_reference == AV_NOPTS_VALUE && st->first_dts != AV_NOPTS_VALUE) {
int i;
int64_t pts_wrap_reference = st->first_dts - av_rescale(60, st->time_base.den, st->time_base.num);
int pts_wrap_behavior = (st->first_dts < (1LL<<st->pts_wrap_bits) - (1LL<<st->pts_wrap_bits-3)) ||
(st->first_dts < (1LL<<st->pts_wrap_bits) - av_rescale(60, st->time_base.den, st->time_base.num)) ?
AV_PTS_WRAP_ADD_OFFSET : AV_PTS_WRAP_SUB_OFFSET;
AVProgram *first_program = av_find_program_from_stream(s, NULL, stream_index);
if (!first_program) {
int default_stream_index = av_find_default_stream_index(s);
if (s->streams[default_stream_index]->pts_wrap_reference == AV_NOPTS_VALUE) {
for (i=0; i<s->nb_streams; i++) {
s->streams[i]->pts_wrap_reference = pts_wrap_reference;
s->streams[i]->pts_wrap_behavior = pts_wrap_behavior;
}
}
else {
st->pts_wrap_reference = s->streams[default_stream_index]->pts_wrap_reference;
st->pts_wrap_behavior = s->streams[default_stream_index]->pts_wrap_behavior;
}
}
else {
AVProgram *program = first_program;
while (program) {
if (program->pts_wrap_reference != AV_NOPTS_VALUE) {
pts_wrap_reference = program->pts_wrap_reference;
pts_wrap_behavior = program->pts_wrap_behavior;
break;
}
program = av_find_program_from_stream(s, program, stream_index);
}
program = first_program;
while(program) {
if (program->pts_wrap_reference != pts_wrap_reference) {
for (i=0; i<program->nb_stream_indexes; i++) {
s->streams[program->stream_index[i]]->pts_wrap_reference = pts_wrap_reference;
s->streams[program->stream_index[i]]->pts_wrap_behavior = pts_wrap_behavior;
}
program->pts_wrap_reference = pts_wrap_reference;
program->pts_wrap_behavior = pts_wrap_behavior;
}
program = av_find_program_from_stream(s, program, stream_index);
}
}
return 1;
}
return 0;
}
| 1threat
|
Using await within a Promise : <p>There seems something inherently wrong with having to define a Promise's callback as asynchronous:</p>
<pre><code>return new Promise(async (resolve, reject) => {
const value = await somethingAsynchronous();
if (value === something) {
return resolve('It worked!');
} else {
return reject('Nope. Try again.');
}
});
</code></pre>
<p>This is apparently an <a href="https://stackoverflow.com/questions/23803743/what-is-the-explicit-promise-construction-antipattern-and-how-do-i-avoid-it">antipattern</a> and there are coding <a href="https://stackoverflow.com/questions/43036229/using-async-await-inside-new-promise-constructor#43050114">problems which can arise from it</a>. I understand that it becomes easier to fail to catch errors here, even when placing <code>await</code> statements inside <code>try</code>/<code>catch</code> blocks.</p>
<p>My first question is, what's the best way to code something like this, when one wants to forward a Promise with different resolve/reject values? With then/catch? I.e.</p>
<pre><code>return new Promise((resolve, reject) => {
somethingAsynchronous().then(value => {
if (value === something) {
return resolve('It worked!');
} else {
return reject('Nope. Try again.');
}
}); // errors would now be propagated up
});
</code></pre>
<p>Or do you just take it out the Promise constructor altogether as suggested <a href="https://stackoverflow.com/questions/43036229/using-async-await-inside-new-promise-constructor#43050114">here</a>?</p>
<pre><code>async function outerFunction() {
const value = await somethingAsynchronous();
return new Promise((resolve, reject) => {
if (value === something) {
return resolve('It worked!');
} else {
return reject('Nope. Try again.');
}
});
}
</code></pre>
<p>But what if you have several await statements in the outerFunction(), i.e. a linear code block calling several asynchronous functions. Would you then have to create and return a new Promise every time?</p>
<p>But then how do you account for code such as this?</p>
<pre><code>async function outerFunction() {
if (someSynchronousCheck()) {
return 'Nope. Try again.' // another reject case
}
const value = await somethingAsynchronous();
// ...
}
</code></pre>
<p>I have the feeling that I'm making this more complicated than it should be. I'm trying to avoid nesting callbacks/chaining then/catch blocks without creating more problems in the future.</p>
<p>My final question is, why is the callback passed to a Promise not inherently <code>async</code>? It is already wrapped within a promise and expects the resolve/reject functions to be called asynchronously.</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.