problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
how to join multiple csv files without repetition? : <p>I have 3 csv files they all should have the same date column like that:</p>
<pre><code>file1.csv file2.csv file3.csv
date,price1 date,price2 date,price3
2017-03-03,1900 2017-03-03,1200 2017-03-03,1220
2017-03-04,2900 2017-03-04,2200 2017-03-04,2233
2017-03-04,1300 2017-03-04,1549 2017-03-04,1520
</code></pre>
<p>I want to join them and get this using python:</p>
<pre><code>file4.csv
date,price1,price2,price3
2017-03-03,1900,1200,1220
2017-03-04,2900,2200,2233
2017-03-04,1300,1549,1520
</code></pre>
| 0debug
|
How do you shift a signal to reference a virtual ground in an instrumentation amplifier? : <p>I'm working on a circuit that needs to amplify a signal based on a changing resistance. The hardware that I have to work with can only make an offset square wave, but I need an input that is centered around 0V. I have tried using an instrumentation amplifier with one voltage set as the excitation signal and the other is the virtual ground, but it still fails to center the signal.</p>
<p>Any ideas of what to do to shift the signal?<a href="https://i.stack.imgur.com/1XhlI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1XhlI.png" alt="circuit"></a></p>
| 0debug
|
static void render_memory_region(FlatView *view,
MemoryRegion *mr,
target_phys_addr_t base,
AddrRange clip)
{
MemoryRegion *subregion;
unsigned i;
target_phys_addr_t offset_in_region;
uint64_t remain;
uint64_t now;
FlatRange fr;
AddrRange tmp;
base += mr->addr;
tmp = addrrange_make(base, mr->size);
if (!addrrange_intersects(tmp, clip)) {
return;
}
clip = addrrange_intersection(tmp, clip);
if (mr->alias) {
base -= mr->alias->addr;
base -= mr->alias_offset;
render_memory_region(view, mr->alias, base, clip);
return;
}
QTAILQ_FOREACH(subregion, &mr->subregions, subregions_link) {
render_memory_region(view, subregion, base, clip);
}
if (!mr->terminates) {
return;
}
offset_in_region = clip.start - base;
base = clip.start;
remain = clip.size;
for (i = 0; i < view->nr && remain; ++i) {
if (base >= addrrange_end(view->ranges[i].addr)) {
continue;
}
if (base < view->ranges[i].addr.start) {
now = MIN(remain, view->ranges[i].addr.start - base);
fr.mr = mr;
fr.offset_in_region = offset_in_region;
fr.addr = addrrange_make(base, now);
fr.dirty_log_mask = mr->dirty_log_mask;
flatview_insert(view, i, &fr);
++i;
base += now;
offset_in_region += now;
remain -= now;
}
if (base == view->ranges[i].addr.start) {
now = MIN(remain, view->ranges[i].addr.size);
base += now;
offset_in_region += now;
remain -= now;
}
}
if (remain) {
fr.mr = mr;
fr.offset_in_region = offset_in_region;
fr.addr = addrrange_make(base, remain);
fr.dirty_log_mask = mr->dirty_log_mask;
flatview_insert(view, i, &fr);
}
}
| 1threat
|
void helper_restore_mode (void)
{
env->ps = (env->ps & ~0xC) | env->saved_mode;
}
| 1threat
|
How many Windows users have UTF-8 set as the code page? : <p>In my understanding, the use of Windows filesystem functions accepting bytes (those with an <code>A</code> suffix) is discouraged (I didn’t find an official deprecation notice, but for example <a href="https://bugs.python.org/issue13374" rel="nofollow noreferrer">Python</a> deprecated their use).</p>
<p>On Unix-derived systems, file names are stored as bytes. The encoding isn’t defined, but many systems are configured to interpret file names as UTF-8.</p>
<p>Since recently, it seems to be possible on Windows to set the code page to UTF-8. Is it possible to estimate how many Windows users have that code page set? Does it make sense to use the bytes-accepting filesystem API on Windows similar to how the POSIX API is used on Unix-derived systems (e.g. when porting some application from Linux to Windows)?</p>
| 0debug
|
How to return all users in Django : <p>I don't know how to print names of all users in my system. I got code like this:</p>
<pre><code> from django.contrib.auth.models import User
users = User.objects.all()
return Response(len(users))
</code></pre>
<p>This returns only number of users but I want to get their names. What should I add to return all users names?? </p>
| 0debug
|
static int net_vhost_chardev_opts(void *opaque,
const char *name, const char *value,
Error **errp)
{
VhostUserChardevProps *props = opaque;
if (strcmp(name, "backend") == 0 && strcmp(value, "socket") == 0) {
props->is_socket = true;
} else if (strcmp(name, "path") == 0) {
props->is_unix = true;
} else if (strcmp(name, "server") == 0) {
} else {
error_setg(errp,
"vhost-user does not support a chardev with option %s=%s",
name, value);
return -1;
}
return 0;
}
| 1threat
|
PHP - Entering data into a database : <p>I've recently trying to add data into a database, (New to php), I've looked over to see where I've gone wrong, but can't find anything. The error is:</p>
<pre><code>Unknown column 'FUMUKU' in 'field list'
</code></pre>
<p>Code:</p>
<pre><code>$dbhost = 'localhost';
$dbuser = 'evocityi_admin';
$dbpass = 'password';
$database = 'evocityi_stocks';
$conn = mysql_connect($dbhost, $dbuser, $dbpass, $database);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$Dtime = "30/04/16";
$StockName = "FUMUKU";
$FUMUKUPrice = 1000;
$sql = "INSERT INTO stocks".
"(Stock,Price, TimeD) ".
"VALUES ".
"('$StockName,$FUMUKUPrice, $DTime')";
mysql_select_db('evocityi_stocks');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not enter data: ' . mysql_error());
}
echo "Entered data successfully\n";
mysql_close($conn);
?>
</code></pre>
<p>SQL Database:
<a href="https://gyazo.com/fc97b686cfea79ea773d1796e912551e" rel="nofollow">https://gyazo.com/fc97b686cfea79ea773d1796e912551e</a></p>
| 0debug
|
How to fix column heigth and width using CSS : i'm developping an e-commerce web site where all the products are displayed in the same page in "cols"
the problem is that i couldn't fix the col width or height using CSS
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<div class="container">
<div class="row">
<!-- BEGIN PRODUCTS -->
<div
class="col-md-3 col-sm-6 col-equal"
*ngFor="let p of (titres | sort: titreSort)"
>
<span class="thumbnail">
<img src="{{ p.URL_couv }}" alt="{{ p.id }}" />
<h4>
<label style="display: block; width: 600px;"
>{{ p.titre }} n° {{ p.numero }}</label
>
</h4>
<p></p>
<hr class="line" />
<div class="row">
<div class="col-md-6 col-sm-6">
<p class="price"></p>
</div>
<div class="col-md-6 col-sm-6"></div>
</div>
</span>
</div>
</div>
</div>
<!-- end snippet -->
this is my code
and this is how the products are showing
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/12k2K.png
and this is my CSS code
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.side-body {
margin-left: 310px;}
.right {
float: right;
border-bottom: 2px solid #4b8e4b;
}
.thumbnail {
-webkit-transition: all 0.5s;
transition: all 0.5s;
}
.thumbnail:hover {
opacity: 1;
box-shadow: 0px 0px 10px #41d834;
}
.line {
margin-bottom: 5px;
}
@media (max-width: 768px) {
.col-equal {
margin: auto;
display: flex;
display: -webkit-flex;
flex-wrap: wrap;
}
}
<!-- end snippet -->
Any help please ?
Thank you
| 0debug
|
Whatsapp api to let visitors contact us on whatsapp : <p>In my holiday site I want to add whatsapp communication with visitor. I need whatsapp api to let visitors contact us on whatsapp. I have check multiple solution for this but don't find any solution yet for this.</p>
<p>I need functionality like below </p>
<p><a href="https://i.stack.imgur.com/g6ar9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g6ar9.png" alt="whatsapp"></a></p>
| 0debug
|
How to test a C program with multiple inputs? : <p>I have Linux Ubuntu, and I want to test my program, for which someone gave me .txt file of multiple inputs. Now I want to run this program with inputs written in the .txt file. Theres a lot of inputs so I dont want to input them by hand. Is there some command in Linux Terminal to run a C with inputs written in a file?
thank you for your answers</p>
| 0debug
|
MigrationState *tcp_start_outgoing_migration(const char *host_port,
int64_t bandwidth_limit,
int async)
{
struct sockaddr_in addr;
FdMigrationState *s;
int ret;
if (parse_host_port(&addr, host_port) < 0)
return NULL;
s = qemu_mallocz(sizeof(*s));
if (s == NULL)
return NULL;
s->mig_state.cancel = tcp_cancel;
s->mig_state.get_status = tcp_get_status;
s->mig_state.release = tcp_release;
s->state = MIG_STATE_ACTIVE;
s->detach = !async;
s->bandwidth_limit = bandwidth_limit;
s->fd = socket(PF_INET, SOCK_STREAM, 0);
if (s->fd == -1) {
qemu_free(s);
return NULL;
}
fcntl(s->fd, F_SETFL, O_NONBLOCK);
if (s->detach == 1) {
dprintf("detaching from monitor\n");
monitor_suspend();
s->detach = 2;
}
do {
ret = connect(s->fd, (struct sockaddr *)&addr, sizeof(addr));
if (ret == -1)
ret = -errno;
if (ret == -EINPROGRESS)
qemu_set_fd_handler2(s->fd, NULL, NULL, tcp_wait_for_connect, s);
} while (ret == -EINTR);
if (ret < 0 && ret != -EINPROGRESS) {
dprintf("connect failed\n");
close(s->fd);
qemu_free(s);
s = NULL;
} else if (ret >= 0)
tcp_connect_migrate(s);
return &s->mig_state;
}
| 1threat
|
What is the purpose of `nil` private methods in ruby? : <p>Using ruby 2.3, and pry REPL, I have this funny result I cannot understand:</p>
<pre><code>nil.private_methods
# [:DelegateClass, :Digest, :sprintf, :format, :Integer, :Float, :String, :Array, :Hash, :throw, :iterator?, :block_given?, :catch, :loop, :Rational, :trace_var, :untrace_var, :Complex, :at_exit, :gem_original_require, :URI, :set_trace_func, :select, :caller, :caller_locations, :test, :fork, :`, :exit, :sleep, :respond_to_missing?, :load, :exec, :exit!, :syscall, :open, :printf, :print, :putc, :puts, :readline, :readlines, :p, :abort, :gets, :system, :spawn, :proc, :lambda, :srand, :pp, :rand, :initialize_copy, :initialize_clone, :initialize_dup, :Pathname, :trap, :gem, :BigDecimal, :require, :require_relative, :autoload, :autoload?, :binding, :local_variables, :warn, :raise, :fail, :global_variables, :__method__, :__callee__, :__dir__, :eval, :method_missing, :singleton_method_added, :singleton_method_removed, :singleton_method_undefined, :initialize]
</code></pre>
<p>It looks likes those private methods are linked to modules loaded:</p>
<pre><code>methods = nil.private_methods.dup
require "json"
nil.private_methods - methods
# [:j, :JSON, :jj]
</code></pre>
<p>I'm wondering about the purpose of those private methods and didn't find anything relevant on the internet.</p>
| 0debug
|
How to Merge two videos without re-encoding : <p>I am trying to Merge two video without re-encoding them.</p>
<p>Currently i use a approach which is too much time consuming and resource as well. I just want to merge without re-encoding them. Currently i am using</p>
<pre><code> exec ( "cpulimit -l 90 ffmpeg -i $filename1 -qscale 0 $intermediate1 &> stream1.log" );
exec ( "cpulimit -l 90 ffmpeg -i $filename2 -qscale 0 $intermediate2 &> stream2.log" );
$output = '/var/www/html/myserver/merg/'.uniqid().'_merge.'.$ext;
exec ( "cpulimit -l 90 cat $intermediate1 $intermediate2 | ffmpeg -i - -qscale 0 $output &> stream3.log" );
</code></pre>
<p>Above takes a lot of time.. I want a quick way to do it.</p>
| 0debug
|
How to use Sub and GetAtt functions at the same time in CloudFormation template? : <p>I create CloudFormation yaml template and I need to use <code>!GetAtt "TestLambda.Arn"</code> as part of <code>!Sub</code> function in "AWS::ApiGateway::Method" Integration Uri:</p>
<pre><code>...
Type: "AWS::ApiGateway::Method"
Properties:
RestApiId:
Ref: "RestApi"
ResourceId:
Ref: "TestResource"
HttpMethod: "GET"
AuthorizationType: "NONE"
Integration:
Type: "AWS_PROXY"
IntegrationHttpMethod: "POST"
Uri: !Sub "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/[[place where I want to use !GetAtt "TestLambda.Arn"]]/invocations"
...
</code></pre>
<p>As result I want to get a value something like that:</p>
<pre><code>"arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/my-endpoint-lambda/invocations"
</code></pre>
<p>How can I use these functions together and get desired result?</p>
| 0debug
|
Button with a image, is possible? : <p>I am develop an <code>UWP</code> app and I want a button with a image, but I dont know how I make this. This is possible? </p>
<p>I want a button that has an image, or an image where it is possible to click on it! </p>
<p>I have tried several ways, and I dont know! I am using <code>XAML</code> and <code>C#</code>, in Visual Studio 2015</p>
| 0debug
|
How to Sum String int Value : I have String like = `24.5 km10.1 km30.9 km`. I want to sum it into double but I'm not able to sum it's value i'm getting exception "not a number" in my log d.
below is my code
double sumValue=0.0;
Log.d("my string is", stringValue);
try {
sumVaue=Double.parseDouble(s1);
Log.d("distance there plus", String.valueOf(sumVaue));
}catch (NumberFormatException e){
System.out.println("not a number");
}
| 0debug
|
I want to collect datas in websites and store them in a database using php : i am working on a personnal web project with php. i want to collect some type of information from website and store them in a table of my database. these informations are related to products and services in sale on these website. these informations are presented differently on the websites i want to use. how can somebody give me clues about how to perform it ?
Thanks.
| 0debug
|
Is there a way to set default value of range input to be empty? : <p>I have a HTML5 range input</p>
<pre><code><input name="testing" type="range" min="0" max="10" step="1">
</code></pre>
<p>When there is no attribute "value" set, it sets the default value to the middle (i.e. 5 in this case). Is there a way to make it empty so that I know if the user has actively input something?</p>
<p>I have another div for value display. At the beginning the value will be "?", so the user will know they haven't input anything. The problem is to prevent the input from submitting value to backend if value is not actively set.</p>
| 0debug
|
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
| 1threat
|
static void tcg_target_init(TCGContext *s)
{
#ifdef CONFIG_GETAUXVAL
unsigned long hwcap = getauxval(AT_HWCAP);
if (hwcap & PPC_FEATURE_ARCH_2_06) {
have_isa_2_06 = true;
}
#endif
tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffffffff);
tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I64], 0, 0xffffffff);
tcg_regset_set32(tcg_target_call_clobber_regs, 0,
(1 << TCG_REG_R0) |
#ifdef __APPLE__
(1 << TCG_REG_R2) |
#endif
(1 << TCG_REG_R3) |
(1 << TCG_REG_R4) |
(1 << TCG_REG_R5) |
(1 << TCG_REG_R6) |
(1 << TCG_REG_R7) |
(1 << TCG_REG_R8) |
(1 << TCG_REG_R9) |
(1 << TCG_REG_R10) |
(1 << TCG_REG_R11) |
(1 << TCG_REG_R12)
);
tcg_regset_clear(s->reserved_regs);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_R0);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_R1);
#ifndef __APPLE__
tcg_regset_set_reg(s->reserved_regs, TCG_REG_R2);
#endif
tcg_regset_set_reg(s->reserved_regs, TCG_REG_R13);
tcg_add_target_add_op_defs(ppc_op_defs);
}
| 1threat
|
Concatenate NPM Script Commands? : <p>I understand that it's possible to chain NPM scripts with <code>&&</code>, <code>pre-</code> and <code>post-</code> hooks, but is it possible to simply separate lengthy script lines into a single, concatenated line?</p>
<p>For example, I'd like to convert this:</p>
<pre><code>"script": {
"build": "--many --commands --are --required --on --a --single --line"
}
</code></pre>
<p>into this:</p>
<pre><code>"script": {
"part1": "--many --commands",
"part2": "--are --required",
"part3": "--on --a",
"part4": "--single --line",
"build": "part1 + part2 + part3 + part4"
}
</code></pre>
<p>So when I enter <code>npm run build</code> it will merge all the parts of the command on one line.</p>
<p>I'm also familiar with config variables, but they are not a cross platform solution so I will avoid using them.</p>
| 0debug
|
static CharDriverState *text_console_init(ChardevVC *vc)
{
CharDriverState *chr;
QemuConsole *s;
unsigned width = 0;
unsigned height = 0;
chr = g_malloc0(sizeof(CharDriverState));
if (vc->has_width) {
width = vc->width;
} else if (vc->has_cols) {
width = vc->cols * FONT_WIDTH;
}
if (vc->has_height) {
height = vc->height;
} else if (vc->has_rows) {
height = vc->rows * FONT_HEIGHT;
}
trace_console_txt_new(width, height);
if (width == 0 || height == 0) {
s = new_console(NULL, TEXT_CONSOLE);
} else {
s = new_console(NULL, TEXT_CONSOLE_FIXED_SIZE);
s->surface = qemu_create_displaysurface(width, height);
}
if (!s) {
g_free(chr);
return NULL;
}
s->chr = chr;
chr->opaque = s;
chr->chr_set_echo = text_console_set_echo;
chr->explicit_be_open = true;
if (display_state) {
text_console_do_init(chr, display_state);
}
return chr;
}
| 1threat
|
how to set json data in table view : <p>I want to get data from Json and put it in the table and display it from the API via Alamofire through the 'Post' process that has parameters containing the page number</p>
<p>I want get "results" .. </p>
<p>{
"responseCode": 200,
"message": null,
"status": true,
"results": [
{
"id": 971,
"title": "ST201972362",
"cdate": "07/31/2019",
"summary": "test",
"address": "",
"timer": "77876203",
"lat": "31.515934",
"lng": "34.4494066",
"source": "2",
"CreatedOn": "2019-07-31T13:38:46.927",
"done_940": null
},
{
"id": 970,
"title": "ST201972356",
"cdate": "07/30/2019",
"summary": "ov",
"address": "",
"timer": "0",
"lat": "31.5159315",
"lng": "34.4493925",
"source": "2",
"CreatedOn": "2019-07-30T15:26:00.077",
"done_940": null
},
{
"id": 964,
"title": "ST201972341",
"cdate": "07/29/2019",
"summary": "تجربة بلاغ ",
"address": "",
"timer": "0",
"lat": "21.5066086",
"lng": "39.1758587",
"source": "2",
"CreatedOn": "2019-07-29T19:06:58.817",
"done_940": null
},
{
"id": 959,
"title": "ST201972820252314",
"cdate": "07/28/2019",
"summary": "اااااا",
"address": "",
"timer": "0",
"lat": "21.5066716",
"lng": "39.1758483",
"source": "1",
"CreatedOn": "2019-07-28T11:45:02.493",
"done_940": null
},
{
"id": 957,
"title": "ST201972312",
"cdate": "07/28/2019",
"summary": "تمتمتم",
"address": "",
"timer": "0",
"lat": "31.5397884",
"lng": "34.4544891",
"source": "2",
"CreatedOn": "2019-07-28T08:56:43.577",
"done_940": null
},
{
"id": 956,
"title": "ST201972312",
"cdate": "07/28/2019",
"summary": "لا تنام",
"address": "",
"timer": "0",
"lat": "31.5397238",
"lng": "34.4540829",
"source": "2",
"CreatedOn": "2019-07-28T08:56:00.15",
"done_940": null
},
{
"id": 955,
"title": "ST201972311",
"cdate": "07/28/2019",
"summary": "تجربه جديد",
"address": "",
"timer": "0",
"lat": "31.5395001",
"lng": "34.4542211",
"source": "2",
"CreatedOn": "2019-07-28T08:52:09.81",
"done_940": null
},
{
"id": 953,
"title": "ST201972309",
"cdate": "07/28/2019",
"summary": "يلا",
"address": "",
"timer": "0",
"lat": "31.5110196",
"lng": "34.4784933",
"source": "2",
"CreatedOn": "2019-07-28T05:30:29.647",
"done_940": null
},
{
"id": 952,
"title": "ST201972309",
"cdate": "07/28/2019",
"summary": "ماك ١",
"address": "",
"timer": "0",
"lat": "31.5110291",
"lng": "34.4785841",
"source": "2",
"CreatedOn": "2019-07-28T05:29:09.943",
"done_940": null
},
{
"id": 949,
"title": "ST201972307",
"cdate": "07/28/2019",
"summary": "مرحبا",
"address": "",
"timer": "0",
"lat": "31.5443154",
"lng": "34.4585304",
"source": "2",
"CreatedOn": "2019-07-28T00:20:42.753",
"done_940": null
}
],
"done_940": "2/811"
}</p>
| 0debug
|
void pci_register_bar(PCIDevice *pci_dev, int region_num,
uint8_t type, MemoryRegion *memory)
{
PCIIORegion *r;
uint32_t addr;
uint64_t wmask;
pcibus_t size = memory_region_size(memory);
assert(region_num >= 0);
assert(region_num < PCI_NUM_REGIONS);
if (size & (size-1)) {
fprintf(stderr, "ERROR: PCI region size must be pow2 "
"type=0x%x, size=0x%"FMT_PCIBUS"\n", type, size);
exit(1);
}
r = &pci_dev->io_regions[region_num];
r->addr = PCI_BAR_UNMAPPED;
r->size = size;
r->type = type;
r->memory = memory;
r->address_space = type & PCI_BASE_ADDRESS_SPACE_IO
? pci_dev->bus->address_space_io
: pci_dev->bus->address_space_mem;
wmask = ~(size - 1);
if (region_num == PCI_ROM_SLOT) {
wmask |= PCI_ROM_ADDRESS_ENABLE;
}
addr = pci_bar(pci_dev, region_num);
pci_set_long(pci_dev->config + addr, type);
if (!(r->type & PCI_BASE_ADDRESS_SPACE_IO) &&
r->type & PCI_BASE_ADDRESS_MEM_TYPE_64) {
pci_set_quad(pci_dev->wmask + addr, wmask);
pci_set_quad(pci_dev->cmask + addr, ~0ULL);
} else {
pci_set_long(pci_dev->wmask + addr, wmask & 0xffffffff);
pci_set_long(pci_dev->cmask + addr, 0xffffffff);
}
}
| 1threat
|
Vue template or render function not defined yet I am using neither? : <p>This is my main javascript file:</p>
<pre><code>import Vue from 'vue'
new Vue({
el: '#app'
});
</code></pre>
<p>My HTML file:</p>
<pre><code><body>
<div id="app"></div>
<script src="{{ mix('/js/app.js') }}"></script>
</body>
</code></pre>
<p>Webpack configuration of Vue.js with the runtime build:</p>
<pre><code>alias: {
'vue$': 'vue/dist/vue.runtime.common.js'
}
</code></pre>
<p>I am still getting this well known error:</p>
<blockquote>
<p>[Vue warn]: Failed to mount component: template or render function not defined.
(found in root instance)</p>
</blockquote>
<p>How come when I don't even have a single thing inside my #app div where I mount Vue, I am still getting a render/template error? It says <code>found in root</code> but there is nothing to be found because it does not even have any content?</p>
<p>How am I suppose to mount if this does not work?</p>
<p><strong>Edit:</strong></p>
<p>I have tried it like this which seems to work:</p>
<pre><code>new Vue(App).$mount('#app');
</code></pre>
<p>It make sense because using the <code>el</code> property implies you are 'scanning' that dom element for any components and it's useless because the runtime build does not have a compiler. </p>
<p>Still it is an extremely strange error message to throw, especially when I have my entire #app div emptied out.</p>
<p>Hopefully somebody could confirm my thoughts.</p>
| 0debug
|
static void pm_write_config(PCIDevice *d,
uint32_t address, uint32_t val, int len)
{
DPRINTF("pm_write_config address 0x%x val 0x%x len 0x%x \n",
address, val, len);
pci_default_write_config(d, address, val, len);
}
| 1threat
|
void uuid_generate(uuid_t out)
{
memset(out, 0, sizeof(uuid_t));
}
| 1threat
|
import math
def largest_triangle(a,b):
if (a < 0 or b < 0):
return -1
area = (3 * math.sqrt(3) * pow(a, 2)) / (4 * b);
return area
| 0debug
|
header function filename is not working in php : header function filename is not working in php. i try to export a csv file but it always download the page name only like export.php
i try so many code and force download. but i can't. plz anyone hlp me
enter code here
if(isset($_POST["export"]))
{ include 'database/config.php';
include "database/database.php";
$db = new database();
$fn = "csv_".uniqid().".csv";
$file = fopen($fn, "w");
$query = "SELECT * from wp_terms";
$read = $db -> select($query);
fputcsv($file, array('ID', 'Name', 'slug', 'term group'));
if($read) {
while ($row = $read->fetch_assoc()) {
fputcsv($file, $row);
}
}
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename="'.$fn);
fclose($file);
}
| 0debug
|
static void hda_codec_device_class_init(ObjectClass *klass, void *data)
{
DeviceClass *k = DEVICE_CLASS(klass);
k->realize = hda_codec_dev_realize;
k->exit = hda_codec_dev_exit;
set_bit(DEVICE_CATEGORY_SOUND, k->categories);
k->bus_type = TYPE_HDA_BUS;
k->props = hda_props;
}
| 1threat
|
How can Click the button to create a multi tag in Html with Javascript : I have a form of registration with some drop down and label and etc...
I want when user click on button '+' then create all of this on the form between `<fieldset>` tag and after `<h2>` tag
For more explanation I will add all of my code here
thank you for your help .
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
<script>
function myFunction() {
var x = document.createElement("INPUT");
x.setAttribute("type", "file");
document.body.appendChild(x);
}
</script>
<!-- language: lang-css -->
/*basic reset*/
* {margin: 0; padding: 0;}
html {
height: 100%;
/*Image only BG fallback*/
background: #F7F7F7;
}
body {
font-family: 'B Nazanin', arial, verdana;
width: 100%;
overflow-x: hidden;
}
/*form styles*/
.steps {
width: 70%;
margin: 50px auto;
position: relative;
}
.steps fieldset {
background: #fff;
border: 0 none;
border-radius: 3px;
box-shadow: 0 17px 41px -21px rgb(0, 0, 0);
padding: 20px 30px;
border-top: 9px solid #FF0000;
box-sizing: border-box;
width: 80%;
margin: 0 10%;
direction: rtl !important;
/*stacking fieldsets above each other*/
position: absolute;
}
/*Hide all except first fieldset*/
.steps fieldset:not(:first-of-type) {
display: none;
}
/*inputs*/
.steps label{
color: #333333;
text-align: left !important;
font-size: 15px;
font-weight: 200;
padding-bottom: 7px;
padding-top: 12px;
display: inline-block;
}
.steps input, .steps textarea , .steps select {
outline: none;
display: block;
width: 100%;
margin: 0 0 20px;
padding: 10px 15px;
border: 1px solid #d9d9d9;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
color: #837E7E;
font-family: "B Nazanin";
-webkti-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
font-size: 14px;
font-wieght: 400;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-transition: all 0.3s linear 0s;
-moz-transition: all 0.3s linear 0s;
-ms-transition: all 0.3s linear 0s;
-o-transition: all 0.3s linear 0s;
transition: all 0.3s linear 0s;
}
.steps input:focus, .steps textarea:focus{
color: #333333;
border: 1px solid #333333;
}
.error1{
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-moz-box-shadow: 0 0 0 transparent;
-webkit-box-shadow: 0 0 0 transparent;
box-shadow: 0 0 0 transparent;
position: absolute;
right: 95%;
margin-top: -58px;
padding: 0 10px;
height: 39px;
display: block;
color: #ffffff;
background: #FF0000;
border: 0;
font: 15px "b nazanin", "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", "Bitstream Vera Sans", "Liberation Sans", Verdana, "Verdana Ref", sans-serif;
line-height: 39px;
white-space: nowrap;
font-weight: bold;
}
.error1:before{
width: 0;
height: 0;
right: -8px;
top: 14px;
content: '';
position: absolute;
border-top: 6px solid transparent;
border-left: 8px solid #FF0000;
border-bottom: 6px solid transparent;
}
.error-log{
margin: 5px 5px 5px 0;
font-size: 19px;
position: relative;
bottom: -2px;
}
.question-log {
margin: 5px 1px 5px 0;
font-size: 15px;
position: relative;
bottom: -2px;
}
/*buttons*/
.steps .action-button, .action-button {
width: 100px !important;
background: #FF0000;
font-weight: bold;
color: white;
border: 0 none #fff;
border-radius: 30px;
cursor: pointer;
padding: 10px 5px;
margin: 10px auto;
-webkit-transition: all 0.3s linear 0s;
-moz-transition: all 0.3s linear 0s;
-ms-transition: all 0.3s linear 0s;
-o-transition: all 0.3s linear 0s;
transition: all 0.3s linear 0s;
display: block;
}
.steps .next, .steps .submit{
float:left;
}
.steps .previous{
float:right;
}
.steps .action-button:hover, .steps .action-button:focus, .action-button:hover, .action-button:focus {
background:#333333;;
}
.steps .explanation{
display: block;
clear: both;
width: 100%;
background: #f2f2f2;
position: relative;
margin-left: -30px;
padding: 22px 0px;
margin-bottom: -10px;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
top: 10px;
text-align: center;
color: #333333;
font-size: 12px;
font-weight: 200;
cursor:pointer;
}
/*headings*/
.fs-title {
text-transform: uppercase;
margin: 0 0 5px;
line-height: 1;
color: #FF0000;
font-size: 18px;
font-weight: 400;
text-align:center;
}
.fs-subtitle {
font-weight: normal;
font-size: 13px;
color: #837E7E;
margin-bottom: 20px;
text-align: center;
}
/*progressbar*/
#progressbar {
margin-bottom: 30px;
overflow: hidden;
/*CSS counters to number the steps*/
counter-reset: step;
width:100%;
text-align: center;
}
#progressbar li {
list-style-type: none;
color: rgb(51, 51, 51);
text-transform: uppercase;
font-size: 13px;
width: 10%;
float: right;
position: relative;
}
#progressbar li:before {
content: counter(step);
counter-increment: step;
width: 20px;
line-height: 20px;
display: block;
font-size: 10px;
color: #333;
background: #dddada;
border-radius: 3px;
margin: 0 auto 5px auto;
}
/*progressbar connectors*/
#progressbar li:after {
content: '';
width: 100%;
height: 2px;
background: #dddada;
position: absolute;
left: 50%;
top: 9px;
z-index: -1; /*put it behind the numbers*/
}
#progressbar li:first-child:after {
/*connector not needed before the first step*/
content: none;
}
/*marking active/completed steps green*/
/*The number of the step and the connector before it = green*/
#progressbar li.active:before, #progressbar li.active:after{
background: #FF0000;
color: white;
}
/* my modal */
.modal p{
font-size: 15px;
font-weight: 100;
font-family: "B Nazanin";
color: #3C3B3B;
line-height: 21px;
text-align: right;
}
.modal {
position: fixed;
top: 50%;
left: 50%;
width: 50%;
max-width: 630px;
min-width: 320px;
height: auto;
z-index: 2000;
visibility: hidden;
-moz-backface-visibility: hidden;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.modal.modal-show {
visibility: visible;
}
.lt-ie9 .modal {
top: 0;
margin-left: -315px;
}
.modal-content {
background: #ffffff;
position: relative;
margin: 0 auto;
padding: 40px;
border-radius: 3px;
}
.modal-overlay {
background: #000000;
position: fixed;
visibility: hidden;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1000;
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0);
opacity: 0;
-moz-transition-property: visibility, opacity;
-o-transition-property: visibility, opacity;
-webkit-transition-property: visibility, opacity;
transition-property: visibility, opacity;
-moz-transition-delay: 0.5s, 0.1s;
-o-transition-delay: 0.5s, 0.1s;
-webkit-transition-delay: 0.5s, 0.1s;
transition-delay: 0.5s, 0.1s;
-moz-transition-duration: 0, 0.5s;
-o-transition-duration: 0, 0.5s;
-webkit-transition-duration: 0, 0.5s;
transition-duration: 0, 0.5s;
}
.modal-show .modal-overlay {
visibility: visible;
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=60);
opacity: 0.6;
-moz-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
-webkit-transition: opacity 0.5s;
transition: opacity 0.5s;
}
/*slide*/
.modal[data-modal-effect|=slide] .modal-content {
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0);
opacity: 0;
-moz-transition: all 0.5s 0;
-o-transition: all 0.5s 0;
-webkit-transition: all 0.5s 0;
transition: all 0.5s 0;
}
.modal[data-modal-effect|=slide].modal-show .modal-content {
filter: progid:DXImageTransform.Microsoft.Alpha(enabled=false);
opacity: 1;
-moz-transition: all 0.5s 0.1s;
-o-transition: all 0.5s 0.1s;
-webkit-transition: all 0.5s;
-webkit-transition-delay: 0.1s;
transition: all 0.5s 0.1s;
}
.modal[data-modal-effect=slide-top] .modal-content {
-moz-transform: translateY(-300%);
-ms-transform: translateY(-300%);
-webkit-transform: translateY(-300%);
transform: translateY(-300%);
}
.modal[data-modal-effect=slide-top].modal-show .modal-content {
-moz-transform: translateY(0);
-ms-transform: translateY(0);
-webkit-transform: translateY(0);
transform: translateY(0);
}
/* RESPONSIVE */
/* moves error logs in tablet/smaller screens */
@media (max-width:1000px){
/*brings inputs down in size */
.steps input, .steps textarea {
outline: none;
display: block;
width: 100% !important;
}
/*brings errors in */
.error1 {
left: 345px;
margin-top: -58px;
}
}
@media (max-width:675px){
/*mobile phone: uncollapse all fields: remove progress bar*/
.steps {
width: 100%;
margin: 50px auto;
position: relative;
}
#progressbar{
display:none;
}
/*move error logs */
.error1 {
position: relative;
left: 0 !important;
margin-top: 24px;
top: -11px;
}
.error1:before {
width: 0;
height: 0;
left: 14px;
top: -14px;
content: '';
position: absolute;
border-left: 6px solid transparent;
border-bottom: 8px solid #FF0000;
border-right: 6px solid transparent;
}
/*show hidden fieldsets */
.steps fieldset:not(:first-of-type) {
display: block;
}
.steps fieldset{
position:relative;
width: 100%;
margin:0 auto;
margin-top: 45px;
}
.steps .next, .steps .previous{
display:none;
}
.steps .explanation{
display:none;
}
.steps .submit {
float: right;
margin: 28px auto 10px;
width: 100% !important;
}
}
/* Info */
.info {
width: 300px;
margin: 35px auto;
text-align: center;
font-family: 'B Nazanin', sans-serif;
}
.info h1 {
margin: 0;
padding: 0;
font-size: 28px;
font-weight: 400;
color: #333333;
padding-bottom: 5px;
}
.info span {
color:#666666;
font-size: 13px;
margin-top:20px;
}
.info span a {
color: #666666;
text-decoration: none;
}
.info span .fa {
color: rgb(226, 168, 16);
font-size: 19px;
position: relative;
left: -2px;
}
.info span .spoilers {
color: #999999;
margin-top: 5px;
font-size: 10px;
}
.btn1 {
background-color: DodgerBlue;
border: none;
color: white;
padding: 4px 8px;
font-size: 16px;
cursor: pointer;
margin: 20px 5px 0 0;
}
/* Darker background on mouse-over */
.btn1:hover {
background-color: RoyalBlue;
}
<!-- language: lang-html -->
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Information Form</title>
</head>
<body>
<fieldset>
<h2 class="fs-title">Registration Form</h2>
<div class="form-item webform-component webform-component-textfield hs_average_gift_size_in_year_2 field hs-form-field" id="webform-component-cultivation--amount-2">
<div style="width: 17%;float: right;">
<!-- Begin W_Language Field -->
<label for="W_Language">LANGUAGE</label>
<select id="W_Language" class="form-control" name="W_Language">
<option selected>NONE</option>
<option>EN</option>
<option>FR</option>
<option>GE</option>
<option>AR</option>
</select>
<!-- End W_Language Field -->
</div>
<div style="width: 17%;float: right;">
<!-- Begin exam Field -->
<label for="W_exam">EXAM</label>
<select id="W_exam" class="form-control" name="W_exam">
<option selected>NONE</option>
<option>IELTS</option>
<option>TOEFL</option>
<option>GRE</option>
<option>KET</option>
<option>FCE</option>
<option>MSRT</option>
<option>TOLIMO</option>
<option>MCHE</option>
<option>CPE</option>
</select>
<!-- End W_exam Field -->
</div>
<div style="width: 8%;float: left;">
<!-- Begin W_Language Field -->
<button onclick="myFunction();return false" class="btn1" >+</button>
</div>
<div style="width: 12%;float: left;">
<!-- Begin W_Language Field -->
<label for="W_Speack">speck</label>
<select id="W_Language" class="form-control" name="W_Language">
<option selected>4</option>
<option>4.5</option>
<option>5</option>
<option>5.5</option>
<option>6</option>
<option>6.5</option>
<option>7</option>
<option>7.5</option>
<option>8</option>
<option>8.5</option>
<option>9</option>
</select>
<!-- End W_Language Field -->
</div>
<div style="width: 12%;float: left;">
<!-- Begin W_Language Field -->
<label for="W_Listen">listening</label>
<select id="W_Language" class="form-control" name="W_Language">
<option selected>4</option>
<option>4.5</option>
<option>5</option>
<option>5.5</option>
<option>6</option>
<option>6.5</option>
<option>7</option>
<option>7.5</option>
<option>8</option>
<option>8.5</option>
<option>9</option>
</select>
<!-- End Language Field -->
</div>
<div style="width: 12%;float: left;">
<!-- Begin Language Field -->
<label for="W_Reading">reading</label>
<select id="Language" class="form-control" name="Language">
<option selected>4</option>
<option>4.5</option>
<option>5</option>
<option>5.5</option>
<option>6</option>
<option>6.5</option>
<option>7</option>
<option>7.5</option>
<option>8</option>
<option>8.5</option>
<option>9</option>
</select>
<!-- End Language Field -->
</div>
<div style="width: 12%;float: left;">
<!-- Begin W_Writing Field -->
<label for="W_Writing">writing</label>
<select id="W_Writing" class="form-control" name="W_Writing">
<option selected>4</option>
<option>4.5</option>
<option>5</option>
<option>5.5</option>
<option>6</option>
<option>6.5</option>
<option>7</option>
<option>7.5</option>
<option>8</option>
<option>8.5</option>
<option>9</option>
</select>
<!-- End W_Writing Field -->
</div>
</div>
</fieldset>
</body>
</html>
<!-- end snippet -->
| 0debug
|
What encryption is used to encrypt the password : <p>Hello this is a perl script that will create a file inside a folder in the server
it will ask the user to input username password and email
when the account is created it will be created like that
username.txt </p>
<p>inside the file will be
username
password
email</p>
<p>however the password will be encrypted if I put 123456 that will be encrypted to
cb897EaMgDZy6</p>
<p>I am trying to know what kinda of encryption is used </p>
| 0debug
|
static int64_t mkv_write_seekhead(AVIOContext *pb, mkv_seekhead *seekhead)
{
ebml_master metaseek, seekentry;
int64_t currentpos;
int i;
currentpos = avio_tell(pb);
if (seekhead->reserved_size > 0)
if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0)
return -1;
metaseek = start_ebml_master(pb, MATROSKA_ID_SEEKHEAD, seekhead->reserved_size);
for (i = 0; i < seekhead->num_entries; i++) {
mkv_seekhead_entry *entry = &seekhead->entries[i];
seekentry = start_ebml_master(pb, MATROSKA_ID_SEEKENTRY, MAX_SEEKENTRY_SIZE);
put_ebml_id(pb, MATROSKA_ID_SEEKID);
put_ebml_num(pb, ebml_id_size(entry->elementid), 0);
put_ebml_id(pb, entry->elementid);
put_ebml_uint(pb, MATROSKA_ID_SEEKPOSITION, entry->segmentpos);
end_ebml_master(pb, seekentry);
}
end_ebml_master(pb, metaseek);
if (seekhead->reserved_size > 0) {
uint64_t remaining = seekhead->filepos + seekhead->reserved_size - avio_tell(pb);
put_ebml_void(pb, remaining);
avio_seek(pb, currentpos, SEEK_SET);
currentpos = seekhead->filepos;
}
av_free(seekhead->entries);
av_free(seekhead);
return currentpos;
}
| 1threat
|
Can anyone help me with the below code as it is working fine without flask in local system but not with FLASK? : <p>Code is running fine with local system but I'm getting the following error whenever I try to submit data to my Flask form:</p>
<p>Error: Method Not Allowed The method is not allowed for the requested URL.</p>
<p>Relevant parts of my code are as follows:</p>
<pre><code>pytesseract.pytesseract.tesseract_cmd = 'C:\\Users\\Abhi\\AppData\\Local\\Programs\\Python\\Python37-32\\Lib\\site-packages\\pytesseract\\Tesseract-OCR\\tesseract.exe'
#Poppler executable file is mandatory to load
PDFTOPPMPATH = r"C:\Users\Abhi\Downloads\poppler-0.68.0_x86\poppler-0.68.0\bin\pdftoppm.exe"
PDFFILE = "C:\\Users\\Abhi\\rep.pdf"
subprocess.Popen('"%s" -png "%s" out' % (PDFTOPPMPATH, PDFFILE))
app = Flask(__name__)
@app.route('/', methods=['POST'])
def predict():
im = Image.open("out-2.png")
rgb_im = im.convert('RGB')
rgb_im.save('m.jpg')
im = Image.open("m.jpg")
text1 = pytesseract.image_to_string(im, lang = 'eng')
with open("report.txt","w") as f:
f.write(text1)
para = ["Emissivity","Refl. temp.","Distance","Relative humidity","Atmospheric temperature","Transmission"]
f=open('report.txt')
lines=f.readlines()
#lines.remove("\n")
for i in range(0,len(lines)):
if "jpg" in lines[i]:
end1 = i-1
if "MEASUREMENTS (°C)" in lines[i]:
start1 = i+1
if "Report" in lines[i]:
end2 = i-1
if "Transmission" in lines[i]:
trans = i+1
#print(str(start1) + " " + str(end1)+" " +str(trans) + " " + str(end2))
for i in range(start1-1,trans):
return str(lines[i])
if __name__ == '__main__':
#p = int(os.getenv('PORT', 5000))
#app.run(debug = True, port=p, host='0.0.0.0')
#app.run()
app.run(debug=True, use_reloader=False)
</code></pre>
| 0debug
|
Java servets response.getMethod() not working : Hello I am trying to create a simple servlet as follows
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Form extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter p=res.getWriter();
p.println("<html><head></head><body bgcolor=\"red\">The request came from"+req.getMethod()+"</body></html>");
}
}
I am taking the request from an html file coded as follows.
{html}
{body}
{form action="http://localhost:8080/Form" method="GET"}
First Name: {input type="text" name="name"}
{br }
{input type="submit" value="Enter"}
{/form}
{/body}
{/html}
| 0debug
|
What does negative index mean in a data frame? : <p>Recently I read a R statement somewhere, which said:</p>
<pre><code>mtcars[-1]
</code></pre>
<p>What does -1 imply here? I do understand the following statement:</p>
<pre><code>mtcars[1]
</code></pre>
<p>which means select the first column from the data frame, but I just could not infer the negative sign in the index?</p>
| 0debug
|
static int eject_device(Monitor *mon, BlockDriverState *bs, int force)
{
if (!bdrv_is_removable(bs)) {
qerror_report(QERR_DEVICE_NOT_REMOVABLE, bdrv_get_device_name(bs));
return -1;
}
if (!force && bdrv_dev_is_medium_locked(bs)) {
qerror_report(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs));
return -1;
}
bdrv_close(bs);
return 0;
}
| 1threat
|
static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, DBCtx *ctx)
{
if (hc->current + 1 >= hc->length) {
av_log(NULL, AV_LOG_ERROR, "Tree size exceeded!\n");
return AVERROR_INVALIDDATA;
}
if(!get_bits1(gb)){
int val, i1, i2;
i1 = ctx->v1->table ? get_vlc2(gb, ctx->v1->table, SMKTREE_BITS, 3) : 0;
i2 = ctx->v2->table ? get_vlc2(gb, ctx->v2->table, SMKTREE_BITS, 3) : 0;
if (i1 < 0 || i2 < 0)
return AVERROR_INVALIDDATA;
val = ctx->recode1[i1] | (ctx->recode2[i2] << 8);
if(val == ctx->escapes[0]) {
ctx->last[0] = hc->current;
val = 0;
} else if(val == ctx->escapes[1]) {
ctx->last[1] = hc->current;
val = 0;
} else if(val == ctx->escapes[2]) {
ctx->last[2] = hc->current;
val = 0;
}
hc->values[hc->current++] = val;
return 1;
} else {
int r = 0, r_new, t;
t = hc->current++;
r = smacker_decode_bigtree(gb, hc, ctx);
if(r < 0)
return r;
hc->values[t] = SMK_NODE | r;
r++;
r_new = smacker_decode_bigtree(gb, hc, ctx);
if (r_new < 0)
return r_new;
return r + r_new;
}
}
| 1threat
|
static inline void libopenjpeg_copyto16(AVFrame *picture, opj_image_t *image) {
int *comp_data;
uint16_t *img_ptr;
int index, x, y;
int adjust[4];
for (x = 0; x < image->numcomps; x++)
adjust[x] = FFMAX(FFMIN(av_pix_fmt_desc_get(picture->format)->comp[x].depth_minus1 + 1 - image->comps[x].prec, 8), 0);
for (index = 0; index < image->numcomps; index++) {
comp_data = image->comps[index].data;
for (y = 0; y < image->comps[index].h; y++) {
img_ptr = (uint16_t*) (picture->data[index] + y * picture->linesize[index]);
for (x = 0; x < image->comps[index].w; x++) {
*img_ptr = 0x8000 * image->comps[index].sgnd + (*comp_data << adjust[index]);
img_ptr++;
comp_data++;
}
}
}
}
| 1threat
|
Need help really bad, trying to create a gui with python tkinter : Hi I'm currently trying to write a python code that help me with my job.
Basically i want a gui interface with buttons for sending daily reports of staff. i got pretty far but im completely stuck now, im able to create the buttons but, i cant seem to get it to write into the tkinter text. im able to make the buttons and most of the gui interface but i cant seem to get it to write on to the tkintertext function.
here is the script -
from tkinter import*
import random
import time;
import sys
root = Tk()
root.geometry("1600x800+0+0")
root.configure(background = "powder blue")
root.title("Report system")
text_Input = StringVar()
ADD = "0"
Tops = Frame(root, width = 1600,height = 700,bg="powder blue", relief=SUNKEN)
Tops.configure(background = "powder blue")
Tops.pack(side=TOP)
f1 = Frame(root, width = 650,height = 700,bg="powder blue", relief=SUNKEN)
f1.pack(side=RIGHT)
f2 = Frame(root, width = 950,height = 700,bg="powder blue", relief=SUNKEN)
f2.pack(side=LEFT)
#======================Time==================================================
localtime=time.asctime(time.localtime(time.time()))
#============================Info============================================
TitleH = Label(Tops, font=('arial', 60, 'bold'),text="COMPANY", fg="blue4",bd=10, anchor='w')
TitleH.configure(background = "powder blue")
TitleH.grid(row=0, column=0)
TitleT = Label(Tops, font=('arial', 60, 'bold'),text=localtime, fg="blue4",bd=10, anchor='w')
TitleT.configure(background = "powder blue")
TitleT.grid(row=1, column=0)
#==========================Buttondef=======================
def btnClick(PrimeOperator):
global operator
operator = str(PrimeOperator)
text_Input.set(PrimeOperator)
textDisplay = Entry(f2, font=('arial', 20, 'bold'), textvariable=text_Input, bd=30, insertwidth=4,
bg="powder blue", justify='center')
textDisplay.grid(columnspan=4)
#============================text===========================================
statusDisplay = Text(f1, font=('arial', 20, 'bold'), bd=60, width = 30, height = 10,
bg="powder blue")
statusDisplay.grid(columnspan=4)
btnadd=Button(f2,padx=16,pady=16,bd=8, fg="black", font=("arial",20,'bold'),
text="add", bg="powder blue", command=lambda: statusDisplay.insert(INSERT, 'text_input').grid(row=4,column=2))
#===================OPERATOR=================================
btnop19=Button(f2,padx=16,pady=16,bd=8, fg="black", font= ("arial",20,'bold'),
text="OpTH19", bg="powder blue", command=lambda: btnClick("OpTH19")).grid(row=2,column=0)
btnop18=Button(f2,padx=16,pady=16,bd=8, fg="black", font=("arial",20,'bold'),
text="OpTH18", bg="powder blue", command=lambda:
btnClick("OpTH18")).grid(row=2,column=1)
btnop8=Button(f2,padx=16,pady=16,bd=8, fg="black", font=("arial",20,'bold'),
text="OpTH08", bg="powder blue", command=lambda:
btnClick("OpTH8")).grid(row=2,column=2)
btnop7=Button(f2,padx=16,pady=16,bd=8, fg="black", font=("arial",20,'bold'),
text="OpTH07", bg="powder blue", command=lambda:
btnClick("OpTH7")).grid(row=3,column=0)
btnop5=Button(f2,padx=16,pady=16,bd=8, fg="black", font=("arial",20,'bold'),
text="OpTH05", bg="powder blue", command=lambda:
btnClick("OpTH5")).grid(row=3,column=1)
btnop4=Button(f2,padx=16,pady=16,bd=8, fg="black", font=("arial",20,'bold'),
text="OpTH04", bg="powder blue", command=lambda:
btnClick("OpTH4")).grid(row=3,column=2)
btnop3=Button(f2,padx=16,pady=16,bd=8, fg="black", font=("arial",20,'bold'),
text="OpTH03", bg="powder blue", command=lambda: btnClick("OpTH3")).grid(row=4,column=1)
#=================================status======================================
btnontime=Button(f2,padx=16,pady=16,bd=8, fg="black", font= ("arial",20,'bold'),
text="On time", bg="powder blue", command=lambda: btnClick("On Time")).grid(row=2,column=3)
btnlate=Button(f2,padx=16,pady=16,bd=8, fg="black", font=("arial",20,'bold'),
text="Is Late", bg="powder blue", command=lambda: btnClick("Late")).grid(row=3,column=3)
btnonleave=Button(f2,padx=16,pady=16,bd=8, fg="black", font= ("arial",20,'bold'),
text="On leave", bg="powder blue", command=lambda: btnClick("On leave")).grid(row=4,column=3)
#=================================Print=======================================
btnadd=Button(f2,padx=16,pady=16,bd=8, fg="black", font=("arial",20,'bold'),
text="add", bg="powder blue",
command='C').grid(row=4,column=2)
root.mainloop()
so basically i will click on the ontime first then i want to click on the add so it adds ontime to the left side which is a tkinter text. then i will click on op who comes on time and clicked add for each one of op. so i want it to look like : ontime opth3 opth4 etc.. etc..
If you have any suggestioh please tell me and thank you.
| 0debug
|
hi whats is wrong with the layer 84 written " time.sleep(length) " : What is the problem by line 84? syntaxerror: time.sleep(length) i got.
what is false?
thanks
time.sleep(length)
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
buzzer_pin = 17
sensor_pin = 18
GPIO.setup(sensor_pin, GPIO.IN)
GPIO.setup(buzzer_pin, GPIO.IN)
GPIO.setup(buzzer_pin, GPIO.OUT)
notes = {
'B0' : 31,
'C1' : 33, 'CS1' : 35,
'D1' : 37, 'DS1' : 39,
'EB1' : 39,
'E1' : 41,
'F1' : 44, 'FS1' : 46,
'G1' : 49, 'GS1' : 52,
'A1' : 55, 'AS1' : 58,
'BB1' : 58,
'B1' : 62,
'C2' : 65, 'CS2' : 69,
'D2' : 73, 'DS2' : 78,
'EB2' : 78,
'E2' : 82,
'F2' : 87, 'FS2' : 93,
'G2' : 98, 'GS2' : 104,
'A2' : 110, 'AS2' : 117,
'BB2' : 123,
'B2' : 123,
'C3' : 131, 'CS3' : 139,
'D3' : 147, 'DS3' : 156,
'EB3' : 156,
'E3' : 165,
'F3' : 175, 'FS3' : 185,
'G3' : 196, 'GS3' : 208,
'A3' : 220, 'AS3' : 233,
'BB3' : 233,
'B3' : 247,
'C4' : 262, 'CS4' : 277,
'D4' : 294, 'DS4' : 311,
'EB4' : 311,
'E4' : 330,
'F4' : 349, 'FS4' : 370,
'G4' : 392, 'GS4' : 415,
'A4' : 440, 'AS4' : 466,
'BB4' : 466,
'B4' : 494,
'C5' : 523, 'CS5' : 554,
'D5' : 587, 'DS5' : 622,
'EB5' : 622,
'E5' : 659,
'F5' : 698, 'FS5' : 740,
'G5' : 784, 'GS5' : 831,
'A5' : 880, 'AS5' : 932,
'BB5' : 932,
'B5' : 988,
'C6' : 1047, 'CS6' : 1109,
'D6' : 1175, 'DS6' : 1245,
'EB6' : 1245,
'E6' : 1319,
'F6' : 1397, 'FS6' : 1480,
'G6' : 1568, 'GS6' : 1661,
'A6' : 1760, 'AS6' : 1865,
'BB6' : 1865,
'B6' : 1976,
'C7' : 2093, 'CS7' : 2217,
'D7' : 2349, 'DS7' : 2489,
'EB7' : 2489,
'E7' : 2637,
'F7' : 2794, 'FS7' : 2960,
'G7' : 3136, 'GS7' : 3322,
'A7' : 3520, 'AS7' : 3729,
'BB7' : 3729,
'B7' : 3951,
'C8' : 4186, 'CS8' : 4435,
'D8' : 4699, 'DS8' : 4978
}
def buzz(frequency, length):
if(frequency==0):
time.sleep(length)
return
period = 1.0 / frequency
delayValue = period / 2
numCycles = int(length * frequency)
for i in range(numCycles):
GPIO.output(buzzer_pin, True)
time.sleep(delayValue)
GPIO.output(buzzer_pin, False)
time.sleep(delayValue)
def play():
buzz(notes['A3'], 0.5)
buzz(notes['A3'], 0.5)
buzz(notes['A3'], 0.5)
buzz(notes['F3'], 0.35)
buzz(notes['C4'], 0.15)
buzz(notes['A3'], 0.5)
buzz(notes['F3'], 0.35)
buzz(notes['C4'], 0.15)
buzz(notes['A3'], 1.0)
while True:
if GPIO.input(sensor_pin):
print("Ses Alarmi!")
play()
time.sleep(0.5)
| 0debug
|
I want to use bat to split string which use ; as delims : i want to delete a special path using bat,i cannt use set somevar=" %path:specialstr=%",because the specialstr has dynamic part。 can I use bat to remove strings which are produced by %cd% from a large string like %path%?
| 0debug
|
Why are non-placement `new` and `delete` built into the language and not just regular functions? : <p>Why were the non-placement <a href="http://en.cppreference.com/w/cpp/language/new" rel="noreferrer"><code>new</code> expression</a> and the <a href="http://en.cppreference.com/w/cpp/language/delete" rel="noreferrer"><code>delete</code> expression</a> implemented as language built-in instead of regular functions?</p>
<p>If we have...</p>
<ul>
<li><p>a way of requesting/giving back memory to the OS</p></li>
<li><p>a way of explicitly invoking a constructor <em>(placement <code>new</code>)</em></p></li>
<li><p>a way of explicitly invoking a destructor <em>(<code>~T()</code>)</em></p></li>
</ul>
<p>...why couldn't non-placement <code>new</code> and <code>delete</code> just be regular functions in the Standard Library? Example:</p>
<pre><code>template <typename T, typename... Ts>
T* library_new(Ts&&... xs)
{
auto* ptr = /* request enough memory for `T` from OS */;
new (ptr) T(std::forward<Ts>(xs)...);
return ptr;
}
template <typename T>
void library_delete(T* ptr)
{
ptr->~T();
/* reclaim memory for `T` from OS */
}
</code></pre>
| 0debug
|
How do I point a docker image to my .m2 directory for running maven in docker on a mac? : <p>When you look at the <a href="https://github.com/carlossg/docker-maven/blob/40cbcd2edc2719c64062af39baac6ae38d0becf9/jdk-7/Dockerfile" rel="noreferrer">Dockerfile for a maven build</a> it contains the line:</p>
<pre><code>VOLUME /root/.m2
</code></pre>
<p>Now this would be great if this is where my <code>.m2</code> repository was on my mac - but it isn't - it's in</p>
<pre><code>/Users/myname/.m2
</code></pre>
<p>Now I could do:</p>
<p>But then the linux implementation in Docker wouldn't know to look there. I want to map the linux location to the mac location, and have that as part of my <code>vagrant init</code>. Kind of like:</p>
<pre><code>ln /root/.m2 /Users/myname/.m2
</code></pre>
<p>My question is: <strong>How do I point a docker image to my .m2 directory for running maven in docker on a mac?</strong></p>
| 0debug
|
static void isa_mmio_writeb (void *opaque, target_phys_addr_t addr,
uint32_t val)
{
cpu_outb(addr & IOPORTS_MASK, val);
}
| 1threat
|
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
| 1threat
|
static ioreq_t *cpu_get_ioreq(XenIOState *state)
{
int i;
evtchn_port_t port;
port = xc_evtchn_pending(state->xce_handle);
if (port == state->bufioreq_local_port) {
timer_mod(state->buffered_io_timer,
BUFFER_IO_MAX_DELAY + qemu_clock_get_ms(QEMU_CLOCK_REALTIME));
return NULL;
}
if (port != -1) {
for (i = 0; i < max_cpus; i++) {
if (state->ioreq_local_port[i] == port) {
break;
}
}
if (i == max_cpus) {
hw_error("Fatal error while trying to get io event!\n");
}
xc_evtchn_unmask(state->xce_handle, port);
state->send_vcpu = i;
return cpu_get_ioreq_from_shared_memory(state, i);
}
return NULL;
}
| 1threat
|
Need help overriding a tostring method in Java : Ok, so on my assignment that I am working on, I have a file that has the instructions commented, and below that is the code I wrote. I think I am good on everything EXCEPT overriding the ToString method. I think I'm starting the line good, I just cant figure out how to get the output going.
These are the instructions:
// Instruction 4
//TODO: Override the toString() method to return the account number,
// account name, and account balance. The returned string should look
// like:
// Account: 10001 - General Expenses
// Balance: 450.67
This is what I have so far:
public String toString(){
return "Accounts: " + accountNumber + " " + accountName + " " + accountBalance;
| 0debug
|
Pnotify show when page is loaded : I have a page which i want to display a notification using **Pnotify**.
How can i call a function on *JavaScript* or *Jquery* to call the div that i want to display the notification with Pnotify.
| 0debug
|
Can i remove inline styles with jQuery? : <p>I want to remove <strong>inline style</strong> from a <strong>span</strong> or <strong>div</strong> or <strong>...</strong></p>
<pre><code><span style="font-size: 8pt;">some texts</span>
</code></pre>
<p>Can i remove <strong>font-size</strong> from <strong>span</strong> with jQuery ?</p>
| 0debug
|
i use odoo v10 to do some task but this errior is apearing please can any one help my? : #model.py
# -*- coding: utf-8 -*-
from openerp import models, fields
class fleet_vehicle_direction(models.Model):
_name = 'fleet.vehicle.direction'
name = fields.Char(related='vehicle_id.name', string='vehicle name', store=True)
vehicle_id = fields.Many2one('fleet.vehicle', 'select vehicle name', required=True, help='select vehicle name')
Quotations_id = fields.One2many('sale.order', 'name', 'Quotation', required=True,help='select Quotation name')
[enter image description here][1]
#error when add a new Quotation
[enter image description here][2]
[1]: https://i.stack.imgur.com/8oiHG.png
[2]: https://i.stack.imgur.com/G6Clr.png
| 0debug
|
php remove words from a string : <p>Suppose i have the following strin</p>
<pre><code>assigned order 1234
</code></pre>
<p>I would like to remove the words</p>
<pre><code>assigned order
</code></pre>
<p>So my final output should be </p>
<pre><code>1234
</code></pre>
<p>How do i go about this in php</p>
<p>SO something like</p>
<pre><code>$string = "assigned order 1234";
</code></pre>
<p>$newstring = //stuck here</p>
<p>NOte that the value 1234 can also be 767as33 BUT THE PART assigned order always remains constant</p>
| 0debug
|
How to remove escape-sequence from list elements in python? : <p>I have a list and every element of list consists of an escape sequence "\n" .. How to remove these "\n" from the elements?</p>
| 0debug
|
static void test_dummy_createcmdl(void)
{
QemuOpts *opts;
DummyObject *dobj;
Error *err = NULL;
const char *params = TYPE_DUMMY \
",id=dev0," \
"bv=yes,sv=Hiss hiss hiss,av=platypus";
qemu_add_opts(&qemu_object_opts);
opts = qemu_opts_parse(&qemu_object_opts, params, true, &err);
g_assert(err == NULL);
g_assert(opts);
dobj = DUMMY_OBJECT(user_creatable_add_opts(opts, &err));
g_assert(err == NULL);
g_assert(dobj);
g_assert_cmpstr(dobj->sv, ==, "Hiss hiss hiss");
g_assert(dobj->bv == true);
g_assert(dobj->av == DUMMY_PLATYPUS);
user_creatable_del("dev0", &err);
g_assert(err == NULL);
error_free(err);
g_assert_null(qemu_opts_find(&qemu_object_opts, "dev0"));
}
| 1threat
|
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
| 1threat
|
static void phys_section_destroy(MemoryRegion *mr)
{
memory_region_unref(mr);
if (mr->subpage) {
subpage_t *subpage = container_of(mr, subpage_t, iomem);
object_unref(OBJECT(&subpage->iomem));
g_free(subpage);
}
}
| 1threat
|
difference between isNothing and (== Nothing) in Haskell? : <p>I'm confused about why the two functions below involving <code>Nothing</code> are different:</p>
<pre><code>coalesce m1 m2 = if isNothing m1 then m2 else m1
coalesce' m1 m2 = if (m1 == Nothing) then m2 else m1
</code></pre>
<p>The first one has type:</p>
<pre><code>λ> :t coalesce
coalesce :: Maybe a -> Maybe a -> Maybe a
</code></pre>
<p>as expected. But the second one has:</p>
<pre><code>λ> :t coalesce'
coalesce' :: Eq a => Maybe a -> Maybe a -> Maybe a
</code></pre>
<p>Why does using <code>(==Nothing)</code> introduce the <code>Eq a</code> constraint? </p>
<p>(GHC 8.2.2)</p>
| 0debug
|
merge data frame based on column names in r : I have 4 data frames all with the same number of columns and identical column names. The order of the columns is different. I want to combine all 4 data frames together and match them with the column name.
| 0debug
|
static void coroutine_fn wait_for_overlapping_requests(BlockDriverState *bs,
int64_t offset, unsigned int bytes)
{
BdrvTrackedRequest *req;
int64_t cluster_offset;
unsigned int cluster_bytes;
bool retry;
round_bytes_to_clusters(bs, offset, bytes, &cluster_offset, &cluster_bytes);
do {
retry = false;
QLIST_FOREACH(req, &bs->tracked_requests, list) {
if (tracked_request_overlaps(req, cluster_offset, cluster_bytes)) {
assert(qemu_coroutine_self() != req->co);
qemu_co_queue_wait(&req->wait_queue);
retry = true;
break;
}
}
} while (retry);
}
| 1threat
|
MongoDB to BigQuery : <p>What is the best way to export data from MongoDB hosted in mlab to google bigquery?</p>
<p>Initially, I am trying to do one time load from MongoDB to BigQuery and later on I am thinking of using Pub/Sub for real time data flow to bigquery.</p>
<p>I need help with first one time load from mongodb to bigquery.</p>
| 0debug
|
How to make a simple login page in using a bootstrap and JS? : <p>Hello everyone I am starting to learn step by step in web programming. I am planning to create a simple log-in form using a bootstrap and Javascript. What is the way to achieve it?.</p>
| 0debug
|
prbplem in get fetch data in react-native : i am beginner of react native. i get data from server but i want display . my data that get is :
[{"id":"1","tmb":"23\/5\/96","name":"ehsan","family":"kharaman"}]
my code is:
```
import React, {Component} from 'react';
import {View, Text} from 'react-native';
class App extends Component {
state = {
data: '',
};
componentDidMount = () => {
fetch('http://192.168.1.34/karbar/select.php', {
method: 'GET',
})
.then(response => response.json())
.then(responseJson => {
console.log(responseJson);
this.setState({
data: responseJson,
});
})
.catch(error => {
console.error(error);
});
};
render() {
return (
<View>
<Text>{this.state.data.name}</Text>
</View>
);
}
}
export default App;
```
| 0debug
|
firing different sensor threads which sends data to same socket : My obvious search related to my problem have been this link so far
http://stackoverflow.com/questions/1523916/how-to-handle-same-socket-in-different-threads but it didnt help me in my pursuit. I have several sensor threads which are fired at random intervals to a client socket which in turn sends that data to the server socket.But i get issue when the sensor threads are fired at the same time then the data of those threads mixed up.I dont want that behaviour to happen.I want all those threads to be fired distinctly without being fired at the same point at any time.Please suggest me methods in order to achieve this.I have been trying to put sleep on the sensor threads but i dont get the desired result
P.S-: I am emulating a test bench environment where the sensors are fired in different threads (as if attached to client socket) to send data to this client on a different topics to the broker.
| 0debug
|
it must be a function, usually from React.PropTypes : <p>I want to pass string from Main to Header. It succeeds but warning. I'm a beginner of React so I can not figure out what <code>it must be a function</code> means.</p>
<p>Anyone knows how to solve this warning?</p>
<p>The warning is:</p>
<p><a href="https://i.stack.imgur.com/4baOJ.png"><img src="https://i.stack.imgur.com/4baOJ.png" alt="enter image description here"></a></p>
<p>And my code is below:</p>
<p><em>Main.js</em></p>
<pre><code>import React from 'react';
import Header from './Header';
import AppList from './AppList/AppList';
import Footer from './Footer';
const propTypes = {
mainInfo: React.PropTypes.shape({
title: React.PropTypes.string.isRequired,
apps: React.PropTypes.array.isRequired,
}),
};
class Main extends React.Component {
static methodsAreOk() {
return true;
}
render() {
return (
<div>
<Header title={this.props.mainInfo.title} />
<AppList apps={this.props.mainInfo.apps} />
<Footer />
</div>
);
}
}
Main.propTypes = propTypes;
export default Main;
</code></pre>
<p><em>Header.js</em></p>
<pre><code>import React from 'react';
const propTypes = {
title: React.PropTypes.string.isRequred,
};
class Header extends React.Component {
static methodsAreOk() {
return true;
}
render() {
return (
<div className="header">
<h1>{this.props.title}</h1>
</div>
);
}
}
Header.propTypes = propTypes;
export default Header;
</code></pre>
| 0debug
|
How to fix 'Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.' : <p>I recently uninstalled and reinstalled Postgres10. I then went to run a Node/Express/React application that relies on connecting to a Postgres database (and communicating with it using Sequelize). </p>
<p>Initially it could not connect to the database. I realized the uninstall process removed my old databases, so then I went and re-created a new one with the name that this application connects to. Then when I restarted the app (both server and client), front-end interaction with the database was working again like normal - writing new users and reading them for authentication etc.</p>
<p>However, I now have the following error in the Chrome Dev Tools console on every page-load of the app:</p>
<blockquote>
<p>Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist</p>
</blockquote>
<p>This error makes a reference to localhost/:1. When I hover over this, it shows <a href="http://localhost:3000/" rel="noreferrer">http://localhost:3000/</a>, the address I'm viewing the app at in the browser.</p>
<p>Anyone have an idea what is going on? Most of the other threads I've found that bring up this error seem to be related to someone trying to develop a Chrome Extension, and even then they tend to have very few responses.</p>
| 0debug
|
static void spapr_powerdown_req(Notifier *n, void *opaque)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
struct rtas_error_log *hdr;
struct rtas_event_log_v6 *v6hdr;
struct rtas_event_log_v6_maina *maina;
struct rtas_event_log_v6_mainb *mainb;
struct rtas_event_log_v6_epow *epow;
struct epow_log_full *new_epow;
new_epow = g_malloc0(sizeof(*new_epow));
hdr = &new_epow->hdr;
v6hdr = &new_epow->v6hdr;
maina = &new_epow->maina;
mainb = &new_epow->mainb;
epow = &new_epow->epow;
hdr->summary = cpu_to_be32(RTAS_LOG_VERSION_6
| RTAS_LOG_SEVERITY_EVENT
| RTAS_LOG_DISPOSITION_NOT_RECOVERED
| RTAS_LOG_OPTIONAL_PART_PRESENT
| RTAS_LOG_TYPE_EPOW);
hdr->extended_length = cpu_to_be32(sizeof(*new_epow)
- sizeof(new_epow->hdr));
spapr_init_v6hdr(v6hdr);
spapr_init_maina(maina, 3 );
mainb->hdr.section_id = cpu_to_be16(RTAS_LOG_V6_SECTION_ID_MAINB);
mainb->hdr.section_length = cpu_to_be16(sizeof(*mainb));
mainb->subsystem_id = 0xa0;
mainb->event_severity = 0x00;
mainb->event_subtype = 0xd0;
epow->hdr.section_id = cpu_to_be16(RTAS_LOG_V6_SECTION_ID_EPOW);
epow->hdr.section_length = cpu_to_be16(sizeof(*epow));
epow->hdr.section_version = 2;
epow->sensor_value = RTAS_LOG_V6_EPOW_ACTION_SYSTEM_SHUTDOWN;
epow->event_modifier = RTAS_LOG_V6_EPOW_MODIFIER_NORMAL;
epow->extended_modifier = RTAS_LOG_V6_EPOW_XMODIFIER_PARTITION_SPECIFIC;
rtas_event_log_queue(RTAS_LOG_TYPE_EPOW, new_epow);
qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr),
rtas_event_log_to_irq(spapr,
RTAS_LOG_TYPE_EPOW)));
}
| 1threat
|
Generic Object type in typescript : <p>In typescript is there any way to assign a variable a generic object type.
Here's what I mean by 'generic Object type'</p>
<pre><code>let myVariable: GenericObject = 1 // Should throw an error
= 'abc' // Should throw an error
= {} // OK
= {name: 'qwerty'} //OK
</code></pre>
<p>i.e. It should only allow javascript objects to be assigned to the variable and no other type of data(number, string, boolean) </p>
| 0debug
|
variable used like a type : <p>the error is coming in return statement " 'mydata' is a variable but is used like a type "
how to fix the error? </p>
<pre><code> [HttpGet]
public JsonResult NewData()
{
List<mydatasample> mydata = new List<mydatasample>();
mydata.Add(new mydatasample { bookName = "test1", publisherName = "yum3", publishYear = 2018 });
mydata.Add(new mydatasample { bookName = "test1", publisherName = "yum3", publishYear = 2018 });
mydata.Add(new mydatasample { bookName = "test2", publisherName = "yum3", publishYear = 2018 });
mydata.Add(new mydatasample { bookName = "test1", publisherName = "yum3", publishYear = 2018 });
mydata.Add(new mydatasample { bookName = "test1", publisherName = "yum3", publishYear = 2018 });
mydata.Add(new mydatasample { bookName = "test1", publisherName = "yum3", publishYear = 2018 });
mydata.Add(new mydatasample { bookName = "test1", publisherName = "yum3", publishYear = 2018 });
mydata.Add(new mydatasample { bookName = "test1", publisherName = "yum3", publishYear = 2018 });
mydata.Add(new mydatasample { bookName = "test1", publisherName = "yum3", publishYear = 2018 });
mydata.Add(new mydatasample { bookName = "test1", publisherName = "yum3", publishYear = 2018 });
return Json(new mydata { }, JsonRequestBehavior.AllowGet);
}
</code></pre>
| 0debug
|
get last firday SQL : How to get last friday of a week in SQL Server..
<br/>
Some clues... select (7 -datePart(dw, getdate()+3)) +1
| 0debug
|
R : creating new data from column with string variable name : <p>I have string variable, <code>str</code>, with the value <code>"car"</code>. I would like to create a new column in my data frame using <code>str</code>, but creates a column with the name <code>"car"</code>. Below is a short example. </p>
<pre><code>a<-c("Bill", "Jo", "Sue")
b<-c(3,4,10)
d<-c("Red", "Blue", "Yellow")
df<-data.frame(b,d,row.names=a)
colnames(df)<-c("age","favorite_color")
df
age favorite_color
Bill 3 Red
Jo 4 Blue
Sue 10 Yellow
str<-"car"
df$str<-character(nrow(df))
df
age favorite_color str
Bill 3 Red
Jo 4 Blue
Sue 10 Yellow
</code></pre>
<p>Is there a way to evaluate <code>str</code> while creating the new data frame column such that the column name is <code>"car"</code>.</p>
| 0debug
|
START_TEST(qdict_destroy_simple_test)
{
QDict *qdict;
qdict = qdict_new();
qdict_put_obj(qdict, "num", QOBJECT(qint_from_int(0)));
qdict_put_obj(qdict, "str", QOBJECT(qstring_from_str("foo")));
QDECREF(qdict);
}
| 1threat
|
static QDict *parse_json_filename(const char *filename, Error **errp)
{
QObject *options_obj;
QDict *options;
int ret;
ret = strstart(filename, "json:", &filename);
assert(ret);
options_obj = qobject_from_json(filename);
if (!options_obj) {
error_setg(errp, "Could not parse the JSON options");
return NULL;
}
if (qobject_type(options_obj) != QTYPE_QDICT) {
qobject_decref(options_obj);
error_setg(errp, "Invalid JSON object given");
return NULL;
}
options = qobject_to_qdict(options_obj);
qdict_flatten(options);
return options;
}
| 1threat
|
Why is my program printing out only the last object value of the array? : <p>Candidate class: </p>
<pre><code>public class Candidate
{
private static String name;
private static int numVotes;
Candidate(String name, int numVotes)
{
Candidate.name = name;
Candidate.numVotes = numVotes;
}
public String toString()
{
return name + " recieved " + numVotes + " votes.";
}
public static int getVotes()
{
return numVotes;
}
public static void setVotes(int inputVotes)
{
numVotes = inputVotes;
}
public static String getName()
{
return name;
}
public static void setName(String inputName)
{
name = inputName;
}
}
</code></pre>
<p>TestCandidate class:</p>
<pre><code>public class TestCandidate
{
public static Candidate[] election = new Candidate[5];
public static void addCandidates(Candidate[] election)
{
election[0] = new Candidate("John Smith", 5000);
election[1] = new Candidate("Mary Miller", 4000);
election[2] = new Candidate("Michael Duffy", 6000);
election[3] = new Candidate("Tim Robinson", 2500);
election[4] = new Candidate("Joe Ashton", 1800);
}
public static int getTotal(Candidate[] election)
{
int total = 0;
for (Candidate i : election)
{
total += Candidate.getVotes();
}
return total;
}
public static void printResults(Candidate[] election)
{
System.out.printf("%s%12s%25s", "Candidate", "Votes", "Percentage of Votes\n");
for (Candidate i: election)
{
System.out.printf("\n%s%10s%10s", Candidate.getName(), Candidate.getVotes(), ((double)Candidate.getVotes()/getTotal(election) * 100));
}
System.out.println("\n\nTotal Number of Votes: " + getTotal(election));
}
public static void main (String args[])
{
addCandidates(election);
printResults(election);
}
}
</code></pre>
<p>Whenever I run the TestCandidate class, it outputs this: </p>
<pre><code>Candidate Votes Percentage of Votes
Joe Ashton 1800 20.0
Joe Ashton 1800 20.0
Joe Ashton 1800 20.0
Joe Ashton 1800 20.0
Joe Ashton 1800 20.0
Total Number of Votes: 9000
</code></pre>
<p>The point of the program is to output all of the candidates and calculate averages based on everyone. I believe it's an issue within my for-each loops. Any help with this would be appreciated.</p>
| 0debug
|
Comparing two string to see if their pattern matches : I have two arrays one outputting
$a = ( [0] => a [1] => b [2] => b [3] => a )
and the other outputting
$b = ( [0] => dog [1] => cat [2] => cat [3] => dog )
how can i compare the pattern in both arrays.
| 0debug
|
Resize an image without distortion OpenCV : <p>I am using python 3 and latest version of openCV. I am trying to resize an image using the resize function provided but after resizing the image is very distorted. Code :</p>
<pre><code>import cv2
file = "/home/tanmay/Desktop/test_image.png"
img = cv2.imread(file , 0)
print(img.shape)
cv2.imshow('img' , img)
k = cv2.waitKey(0)
if k == 27:
cv2.destroyWindow('img')
resize_img = cv2.resize(img , (28 , 28))
cv2.imshow('img' , resize_img)
x = cv2.waitKey(0)
if x == 27:
cv2.destroyWindow('img')
</code></pre>
<p>The original image is 480 x 640 (RGB therefore i passed the 0 to get it to grayscale)</p>
<p>Is there any way i could resize it and avoid the distortion using OpenCV or any other library perhaps? I intend to make a handwritten digit recogniser and i have trained my neural network using the MNIST data therefore i need the image to be 28x28.</p>
| 0debug
|
int ff_rtsp_setup_output_streams(AVFormatContext *s, const char *addr)
{
RTSPState *rt = s->priv_data;
RTSPMessageHeader reply1, *reply = &reply1;
int i;
char *sdp;
AVFormatContext sdp_ctx, *ctx_array[1];
s->start_time_realtime = av_gettime();
sdp = av_mallocz(SDP_MAX_SIZE);
if (sdp == NULL)
return AVERROR(ENOMEM);
sdp_ctx = *s;
ff_url_join(sdp_ctx.filename, sizeof(sdp_ctx.filename),
"rtsp", NULL, addr, -1, NULL);
ctx_array[0] = &sdp_ctx;
if (avf_sdp_create(ctx_array, 1, sdp, SDP_MAX_SIZE)) {
av_free(sdp);
return AVERROR_INVALIDDATA;
}
av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
ff_rtsp_send_cmd_with_content(s, "ANNOUNCE", rt->control_uri,
"Content-Type: application/sdp\r\n",
reply, NULL, sdp, strlen(sdp));
av_free(sdp);
if (reply->status_code != RTSP_STATUS_OK)
return AVERROR_INVALIDDATA;
for (i = 0; i < s->nb_streams; i++) {
RTSPStream *rtsp_st;
AVStream *st = s->streams[i];
rtsp_st = av_mallocz(sizeof(RTSPStream));
if (!rtsp_st)
return AVERROR(ENOMEM);
dynarray_add(&rt->rtsp_streams, &rt->nb_rtsp_streams, rtsp_st);
st->priv_data = rtsp_st;
rtsp_st->stream_index = i;
av_strlcpy(rtsp_st->control_url, rt->control_uri, sizeof(rtsp_st->control_url));
av_strlcatf(rtsp_st->control_url, sizeof(rtsp_st->control_url),
"/streamid=%d", i);
}
return 0;
}
| 1threat
|
static void patch_call(VAPICROMState *s, X86CPU *cpu, target_ulong ip,
uint32_t target)
{
uint32_t offset;
offset = cpu_to_le32(target - ip - 5);
patch_byte(cpu, ip, 0xe8);
cpu_memory_rw_debug(CPU(cpu), ip + 1, (void *)&offset, sizeof(offset), 1);
}
| 1threat
|
Downloading website get requests : <p>I am working on a school project where we write a program that looks into a website, downloads all the GET requests made by that website, and then pulls those downloads into a local file. The website is not static as it has constantly changing information so I can't just run a scraper through it. Is there a way to use Java or C# so that I can programmatically do this? Also, I can't give you the website because it is under my professor's name and she only wants her students to use it for teaching purposes.</p>
<p>p.s. I know you can manually do this by inspecting the element of a page and choosing the network tab, but I am having issues doing this with a program.</p>
| 0debug
|
Webpack with requirejs/AMD : <p>I'm working on a new module for an existing project that still uses requireJS for module loading. I'm trying to use new technologies for my new module like webpack (which allows me to use es6 loaders using es6 imports). It seems like webpack can't reconcile with requireJS syntax. It will say things like: "Module not found: Error: Can't resolve in ".</p>
<p><strong>Problem</strong>: Webpack won't bundle files with requireJS/AMD syntax in them.<br>
<strong>Question</strong>: Is there any way to make webpack play nice with requireJS?</p>
<p>My final output must be in AMD format in order for the project to properly load it. Thanks.</p>
| 0debug
|
Post FB comment as page : <p>I have administrator account of a Facebook page, i would like to know whether it is possible to post a comment as page (the one i manage) using graph api and how to do it ?</p>
<p>Thanks in advance </p>
| 0debug
|
def divisor(n):
for i in range(n):
x = len([i for i in range(1,n+1) if not n % i])
return x
| 0debug
|
static void opt_format(const char *arg)
{
if (!strcmp(arg, "pgmyuv")) {
opt_image_format(arg);
arg = "image";
}
file_iformat = av_find_input_format(arg);
file_oformat = guess_format(arg, NULL, NULL);
if (!file_iformat && !file_oformat) {
fprintf(stderr, "Unknown input or output format: %s\n", arg);
exit(1);
}
}
| 1threat
|
You must call removeView() on the child's parent first. (Error occurred when i try to add rows dynamically) :Android : The above error occurred while i try to add row dynamically to my tableview
Main code of activity
I have tried many solutions available in stackoverflow. But nothing solved my problem
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
package com.example.bhramaram.myapplication;
import android.content.Context;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.ViewGroup;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import com.example.bhramaram.myapplication.Dbhelper;
import com.example.bhramaram.myapplication.R;
public class jav extends AppCompatActivity {
TableLayout tb;
TableRow tableRow;
Dbhelper dbhelper;
@Override
public void onCreate(Bundle savedInstanceState){
int day=0;
super.onCreate(savedInstanceState);
setContentView(R.layout.timetable);
getvalues();
}
private void getvalues() {
tb=(TableLayout)findViewById(R.id.timetble);
TextView textView1,textView2,textView3,textView4,textView5,textView0;
textView0=new TextView(this);textView1=new TextView(this);
textView2=new TextView(this);textView3=new TextView(this);
textView4=new TextView(this);textView5=new TextView(this);
TableRow.LayoutParams lp = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT);
textView0.setLayoutParams(lp);textView1.setLayoutParams(lp);
textView2.setLayoutParams(lp);textView3.setLayoutParams(lp);
textView4.setLayoutParams(lp);textView5.setLayoutParams(lp);
dbhelper= new Dbhelper(jav.this);
Cursor cursor= dbhelper.recieveData();
if(cursor.getCount()==0){
alert("Nothing","Nothing to show");
return;}
int i=0;
while (cursor.moveToNext())
{
tableRow=new TableRow(this);
TableLayout.LayoutParams lp1=new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,TableLayout.LayoutParams.MATCH_PARENT);
textView0.setText((cursor.getString(0)));textView1.setText((cursor.getString(1)));
textView2.setText((cursor.getString(2)));textView3.setText((cursor.getString(3)));
textView4.setText((cursor.getString(4)));textView5.setText((cursor.getString(5)));
tableRow.setLayoutParams(lp);
//Error occurred here
tableRow.addView(textView0);tableRow.addView(textView1);
tableRow.addView(textView2);tableRow.addView(textView3);
tableRow.addView(textView4);tableRow.addView(textView5);
tb.addView(tableRow,lp1);
}
}
private void alert(String title, String alert) {
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setCancelable(true);
builder.setTitle(title);
builder.setMessage(alert);
}
}
<!-- end snippet -->
corresponding xml file
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableLayout
android:id="@+id/timetble"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp"
tools:ignore="MissingConstraints">
</TableLayout>
</android.support.constraint.ConstraintLayout>
<!-- end snippet -->
Error details<br/>
Process: com.example.bhramaram.myapplication, PID: 14266
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.bhramaram.myapplication/com.example.bhramaram.myapplication.jav}: 'java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.'
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.view.ViewGroup.addViewInner(ViewGroup.java:4460)
at android.view.ViewGroup.addView(ViewGroup.java:4301)
at android.view.ViewGroup.addView(ViewGroup.java:4241)
at android.view.ViewGroup.addView(ViewGroup.java:4214)
at com.example.bhramaram.myapplication.jav.getvalues(jav.java:60)
at com.example.bhramaram.myapplication.jav.onCreate(jav.java:29)
at android.app.Activity.performCreate(Activity.java:6705)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
Please tell me the reason why i am getting this error. I am stuck here for 2 days.<br/>
Also I am a newcomer to android developers community. This project is about an app that uses local sqlite database to store and display time table. I follow the method which i found from the web to show the results in table. It will be helpful to me if you can suggest more efficient methods for this code snippet
| 0debug
|
Define function / method if not defined before c++ : <p>I don't use C++11 yet, so I wrote the functions <code>to_string(whatever)</code> by myself. They should only be compiled if they don't exist. If I switch to C++11, they should be skipped. I have something like this:</p>
<pre><code>#ifndef to_string
string to_string(int a){
string ret;
stringstream b;
b << a;
b >> ret;
return ret;
}
string to_string(double a){
string ret;
stringstream b;
b << a;
b >> ret;
return ret;
}
#endif
</code></pre>
<p>This doesn't work apparently. Is something like this possible and if yes, how?</p>
| 0debug
|
Hi i want to transfer the output of a javascript for loop on a an array from vertical to horizontal : <p>As well as how to use java script to manipulate numbers from whole numbers to float and vice versa.<br>
Thank you very much </p>
| 0debug
|
Operator '&&' cannot be applied to operands of type 'System.Collections.Generic.IEnumerable<char>' and 'System.Collections.Generic.IEnumerable<char>' : While executing below code, getting this error:
>Operator '&&' cannot be applied to operands of type 'System.Collections.Generic.IEnumerable(char)' and 'System.Collections.Generic.IEnumerable(char)'
public ActionResult HolidayIndex()
{
IEnumerable<HOLIDAY_MASTER> hdms = null;
hdms = db.HOLIDAY_MASTER.ToList().Where(h => h.HOLIDAY_NAME.Except("Sunday") && h.HOLIDAY_NAME.Except("Saturday") && h.HOLIDAY_DEL.Equals(0) && h.REGION_ID.Equals(RegionID)).OrderBy(h => h.DOH);
return PartialView("HolidayIndex", hdms);
}
Error shows under `h.HOLIDAY_NAME.Except("Sunday") && h.HOLIDAY_NAME.Except("Saturday")`.
| 0debug
|
dshow_cycle_formats(AVFormatContext *avctx, enum dshowDeviceType devtype,
IPin *pin, int *pformat_set)
{
struct dshow_ctx *ctx = avctx->priv_data;
IAMStreamConfig *config = NULL;
AM_MEDIA_TYPE *type = NULL;
int format_set = 0;
void *caps = NULL;
int i, n, size;
if (IPin_QueryInterface(pin, &IID_IAMStreamConfig, (void **) &config) != S_OK)
return;
if (IAMStreamConfig_GetNumberOfCapabilities(config, &n, &size) != S_OK)
goto end;
caps = av_malloc(size);
if (!caps)
goto end;
for (i = 0; i < n && !format_set; i++) {
IAMStreamConfig_GetStreamCaps(config, i, &type, (void *) caps);
#if DSHOWDEBUG
ff_print_AM_MEDIA_TYPE(type);
#endif
if (devtype == VideoDevice) {
VIDEO_STREAM_CONFIG_CAPS *vcaps = caps;
BITMAPINFOHEADER *bih;
int64_t *fr;
const AVCodecTag *const tags[] = { avformat_get_riff_video_tags(), NULL };
#if DSHOWDEBUG
ff_print_VIDEO_STREAM_CONFIG_CAPS(vcaps);
#endif
if (IsEqualGUID(&type->formattype, &FORMAT_VideoInfo)) {
VIDEOINFOHEADER *v = (void *) type->pbFormat;
fr = &v->AvgTimePerFrame;
bih = &v->bmiHeader;
} else if (IsEqualGUID(&type->formattype, &FORMAT_VideoInfo2)) {
VIDEOINFOHEADER2 *v = (void *) type->pbFormat;
fr = &v->AvgTimePerFrame;
bih = &v->bmiHeader;
} else {
goto next;
}
if (!pformat_set) {
enum AVPixelFormat pix_fmt = dshow_pixfmt(bih->biCompression, bih->biBitCount);
if (pix_fmt == AV_PIX_FMT_NONE) {
enum AVCodecID codec_id = av_codec_get_id(tags, bih->biCompression);
AVCodec *codec = avcodec_find_decoder(codec_id);
if (codec_id == AV_CODEC_ID_NONE || !codec) {
av_log(avctx, AV_LOG_INFO, " unknown compression type 0x%X", (int) bih->biCompression);
} else {
av_log(avctx, AV_LOG_INFO, " vcodec=%s", codec->name);
}
} else {
av_log(avctx, AV_LOG_INFO, " pixel_format=%s", av_get_pix_fmt_name(pix_fmt));
}
av_log(avctx, AV_LOG_INFO, " min s=%ldx%ld fps=%g max s=%ldx%ld fps=%g\n",
vcaps->MinOutputSize.cx, vcaps->MinOutputSize.cy,
1e7 / vcaps->MaxFrameInterval,
vcaps->MaxOutputSize.cx, vcaps->MaxOutputSize.cy,
1e7 / vcaps->MinFrameInterval);
continue;
}
if (ctx->video_codec_id != AV_CODEC_ID_RAWVIDEO) {
if (ctx->video_codec_id != av_codec_get_id(tags, bih->biCompression))
goto next;
}
if (ctx->pixel_format != AV_PIX_FMT_NONE &&
ctx->pixel_format != dshow_pixfmt(bih->biCompression, bih->biBitCount)) {
goto next;
}
if (ctx->framerate) {
int64_t framerate = ((int64_t) ctx->requested_framerate.den*10000000)
/ ctx->requested_framerate.num;
if (framerate > vcaps->MaxFrameInterval ||
framerate < vcaps->MinFrameInterval)
goto next;
*fr = framerate;
}
if (ctx->requested_width && ctx->requested_height) {
if (ctx->requested_width > vcaps->MaxOutputSize.cx ||
ctx->requested_width < vcaps->MinOutputSize.cx ||
ctx->requested_height > vcaps->MaxOutputSize.cy ||
ctx->requested_height < vcaps->MinOutputSize.cy)
goto next;
bih->biWidth = ctx->requested_width;
bih->biHeight = ctx->requested_height;
}
} else {
AUDIO_STREAM_CONFIG_CAPS *acaps = caps;
WAVEFORMATEX *fx;
#if DSHOWDEBUG
ff_print_AUDIO_STREAM_CONFIG_CAPS(acaps);
#endif
if (IsEqualGUID(&type->formattype, &FORMAT_WaveFormatEx)) {
fx = (void *) type->pbFormat;
} else {
goto next;
}
if (!pformat_set) {
av_log(avctx, AV_LOG_INFO, " min ch=%lu bits=%lu rate=%6lu max ch=%lu bits=%lu rate=%6lu\n",
acaps->MinimumChannels, acaps->MinimumBitsPerSample, acaps->MinimumSampleFrequency,
acaps->MaximumChannels, acaps->MaximumBitsPerSample, acaps->MaximumSampleFrequency);
continue;
}
if (ctx->sample_rate) {
if (ctx->sample_rate > acaps->MaximumSampleFrequency ||
ctx->sample_rate < acaps->MinimumSampleFrequency)
goto next;
fx->nSamplesPerSec = ctx->sample_rate;
}
if (ctx->sample_size) {
if (ctx->sample_size > acaps->MaximumBitsPerSample ||
ctx->sample_size < acaps->MinimumBitsPerSample)
goto next;
fx->wBitsPerSample = ctx->sample_size;
}
if (ctx->channels) {
if (ctx->channels > acaps->MaximumChannels ||
ctx->channels < acaps->MinimumChannels)
goto next;
fx->nChannels = ctx->channels;
}
}
if (IAMStreamConfig_SetFormat(config, type) != S_OK)
goto next;
format_set = 1;
next:
if (type->pbFormat)
CoTaskMemFree(type->pbFormat);
CoTaskMemFree(type);
}
end:
IAMStreamConfig_Release(config);
if (caps)
av_free(caps);
if (pformat_set)
*pformat_set = format_set;
}
| 1threat
|
How to have 2 background behind div : I would like to have 2 separate backgrounds behind my div, and i don'nt know how i can do that.
Can someone help me?
https://imgur.com/a/CtvJi
| 0debug
|
Unable to trigger state restoration code for BLE on iOS : <p>I am trying to get my app to respond relaunch into the background is response to discovering an advertising peripheral.</p>
<p>The following code currently works in my app (in foreground + background, even after many hours of being backgrounded):</p>
<pre><code>[self.centralManager scanForPeripheralsWithServices:self.services options:nil];
</code></pre>
<p>Generally, my app does not have any pending connection requests, as I want to scan for new advertisements in the background. The following documentation leads me to believe that this is still possible:</p>
<blockquote>
<p><em>it is important to keep in mind that the app will be relaunched and restored if and only if it is pending on a specific Bluetooth event or action (like scanning, connecting, or a subscribed notification characteristic), and this event has occurred.</em> (from <a href="https://developer.apple.com/library/content/qa/qa1962/_index.html" rel="noreferrer">https://developer.apple.com/library/content/qa/qa1962/_index.html</a>)</p>
</blockquote>
<p>and</p>
<blockquote>
<p><em>The system keeps track of...The services the central manager was scanning for (and any scan options specified when the scan started)</em> (from <a href="https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html" rel="noreferrer">https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html</a>)</p>
</blockquote>
<h1>Implementation</h1>
<p>I am following the steps outlined in this last link ^ under the section "Adding Support for State Preservation and Restoration", by doing the following things:</p>
<ol>
<li><p>Instantiating the central manager as directed:</p>
<p>self.centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:@{ CBCentralManagerOptionRestoreIdentifierKey:@"myCentralManagerIdentifier" }];</p></li>
<li><p>Reinstantiate Your Central and Peripheral Managers</p></li>
</ol>
<p>Here I've actually not done anything else, since <code>didFinishLaunchingWithOptions</code> is called and the central will be reinitialized with the same identifier. (Is there something else to be done here that I'm missing?)</p>
<ol start="3">
<li><p>Implementing the restoration function:</p>
<p>(void)centralManager:(CBCentralManager *)central willRestoreState:(NSDictionary *)state {
// Breakpoint set here but never reached...
NSLog(@"...");
}</p></li>
</ol>
<h1>How I am testing state preservation / restoration</h1>
<p>I have set a breakpoint in the restore function (from step 3) and also inserted an <code>NSLog</code>.</p>
<p>By clicking "stop", as suggested in <a href="https://stackoverflow.com/questions/33130124/how-to-trigger-core-bluetooth-state-preservation-and-restoration/33137848#33137848">How to trigger Core Bluetooth state preservation and restoration</a>, I was hoping that I could trigger the code by advertising with my peripheral as I would do normally (this discovery/connection flow is working perfectly when the app is running in the background). But nothing really happens that I can tell.</p>
<p>My general question is: why is the breakpoint not triggered / NSLogs not printed? Is there a preferred way to debug the restoration feature?</p>
<p>Finally, as a sanity check, am I reading the docs correctly that discovery of an advertising peripheral should trigger the re-launch of the app into the background for the app to handle?</p>
| 0debug
|
static void *rcu_q_reader(void *arg)
{
long long j, n_reads_local = 0;
struct list_element *el;
*(struct rcu_reader_data **)arg = &rcu_reader;
atomic_inc(&nthreadsrunning);
while (goflag == GOFLAG_INIT) {
g_usleep(1000);
}
while (goflag == GOFLAG_RUN) {
rcu_read_lock();
QLIST_FOREACH_RCU(el, &Q_list_head, entry) {
j = atomic_read(&el->val);
(void)j;
n_reads_local++;
if (goflag == GOFLAG_STOP) {
break;
}
}
rcu_read_unlock();
g_usleep(100);
}
atomic_add(&n_reads, n_reads_local);
return NULL;
}
| 1threat
|
Swift default AlertViewController breaking constraints : <p>I am trying to use a default AlertViewController with style <strong>.actionSheet</strong>. For some reason, the alert causes a <strong>constraint error</strong>. As long as the alertController is not triggered (displayed) through a button, there are no constraint errors on the whole view. Could it be that this is a <strong>bug of Xcode?</strong></p>
<p>The exact error I get looks like this:</p>
<pre><code>2019-04-12 15:33:29.584076+0200 Appname[4688:39368] [LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x6000025a1e50 UIView:0x7f88fcf6ce60.width == - 16 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x6000025a1e50 UIView:0x7f88fcf6ce60.width == - 16 (active)>
</code></pre>
<p>This is the code I use:</p>
<pre><code>@objc func changeProfileImageTapped(){
print("ChangeProfileImageButton tapped!")
let alert = UIAlertController(title: "Change your profile image", message: nil, preferredStyle: .actionSheet)
alert.addAction(UIAlertAction(title: "Photo Library", style: .default, handler: nil))
alert.addAction(UIAlertAction(title: "Online Stock Library", style: .default, handler: nil))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
alert.view.tintColor = ColorCodes.logoPrimaryColor
self.present(alert, animated: true)
}
</code></pre>
<p>As you can see, it is <strong>very basic</strong>. That's why I am very confused about the strange behavior I get as this <strong>default implementation</strong> should not cause any errors, right?</p>
<p><a href="https://i.stack.imgur.com/FTZFV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FTZFV.png" alt="Output I get"></a></p>
<p>Although, through breaking the constraints, the alert displays properly on all screen sizes I would be really thankful for any help I get.</p>
| 0debug
|
static int ppc_hash32_translate(CPUPPCState *env, struct mmu_ctx_hash32 *ctx,
target_ulong eaddr, int rwx)
{
int ret;
target_ulong sr;
if (((rwx == 2) && (msr_ir == 0)) || ((rwx != 2) && (msr_dr == 0))) {
ctx->raddr = eaddr;
ctx->prot = PAGE_READ | PAGE_EXEC | PAGE_WRITE;
return 0;
}
if (env->nb_BATs != 0) {
ret = ppc_hash32_get_bat(env, ctx, eaddr, rwx);
if (ret == 0) {
return 0;
}
}
sr = env->sr[eaddr >> 28];
if (sr & SR32_T) {
return ppc_hash32_direct_store(env, sr, eaddr, rwx,
&ctx->raddr, &ctx->prot);
}
ctx->nx = !!(sr & SR32_NX);
if ((rwx == 2) && ctx->nx) {
return -3;
}
ret = find_pte32(env, ctx, sr, eaddr, rwx);
return ret;
}
| 1threat
|
Angular 2 - reading json objects and display in tree view : Below is the result in AngularJS
how can i achieve the same in angular 2 . I am able to read the json objects sucessfully. I have tried few solutions but not able to achieve the same result in angular 2.any help will be appreciated
https://plnkr.co/edit/mokM1ILRY8HbF7BAVa5R?p=preview `enter code here`
| 0debug
|
static void free_buffers(VP8Context *s)
{
int i;
if (s->thread_data)
for (i = 0; i < MAX_THREADS; i++) {
av_freep(&s->thread_data[i].filter_strength);
av_freep(&s->thread_data[i].edge_emu_buffer);
}
av_freep(&s->thread_data);
av_freep(&s->macroblocks_base);
av_freep(&s->intra4x4_pred_mode_top);
av_freep(&s->top_nnz);
av_freep(&s->top_border);
s->macroblocks = NULL;
}
| 1threat
|
int coroutine_fn thread_pool_submit_co(ThreadPool *pool, ThreadPoolFunc *func,
void *arg)
{
ThreadPoolCo tpc = { .co = qemu_coroutine_self(), .ret = -EINPROGRESS };
assert(qemu_in_coroutine());
thread_pool_submit_aio(pool, func, arg, thread_pool_co_cb, &tpc);
qemu_coroutine_yield();
return tpc.ret;
}
| 1threat
|
Click: "Got unexpected extra arguments" when passing string : <pre><code>import click
@cli.command()
@click.argument("namespace", nargs=1)
def process(namespace):
.....
@cli.command()
def run():
for namespace in KEYS.iterkeys():
process(namespace)
</code></pre>
<p>Running <code>run('some string')</code> produces:</p>
<p><code>Error: Got unexpected extra arguments (o m e s t r i n g)</code></p>
<p>As if Click passes string argument by one character. Printing an argument shows correct result.</p>
<p>PS: KEYS dictionary defined and working as expected.</p>
| 0debug
|
static void decode_subband(DiracContext *s, GetBitContext *gb, int quant,
int slice_x, int slice_y, int bits_end,
SubBand *b1, SubBand *b2)
{
int left = b1->width * slice_x / s->num_x;
int right = b1->width *(slice_x+1) / s->num_x;
int top = b1->height * slice_y / s->num_y;
int bottom = b1->height *(slice_y+1) / s->num_y;
int qfactor = qscale_tab[quant & 0x7f];
int qoffset = qoffset_intra_tab[quant & 0x7f] + 2;
uint8_t *buf1 = b1->ibuf + top * b1->stride;
uint8_t *buf2 = b2 ? b2->ibuf + top * b2->stride: NULL;
int x, y;
if (get_bits_count(gb) >= bits_end)
return;
if (s->pshift) {
for (y = top; y < bottom; y++) {
for (x = left; x < right; x++) {
PARSE_VALUES(int32_t, x, gb, bits_end, buf1, buf2);
}
buf1 += b1->stride;
if (buf2)
buf2 += b2->stride;
}
}
else {
for (y = top; y < bottom; y++) {
for (x = left; x < right; x++) {
PARSE_VALUES(int16_t, x, gb, bits_end, buf1, buf2);
}
buf1 += b1->stride;
if (buf2)
buf2 += b2->stride;
}
}
}
| 1threat
|
Function Ranking in R : <p>I have two columns x and y. I want to have one column which contains the ranking for both columns. I thought about sum both column and then get it ranked, does any one have a function that rank two columns in r?</p>
<p>Many thanks</p>
| 0debug
|
How to use scikit-learn for Q&A chatbot : <p>I want to create a chatbot for question answering purposes. I have my set of questions and answers. I already got a bot that only uses nltk with keyword recognition, but it has its limits. I would like to use machine learning to have a better chatbot.
I know scikit-learn is the best available Python library for ML, but I just don't know how to use it. All the exemples on their website are more about data visualization and not for actual using. For example, <a href="http://scikit-learn.org/stable/auto_examples/classification/plot_digits_classification.html#sphx-glr-auto-examples-classification-plot-digits-classification-py" rel="nofollow noreferrer">this</a> example is "quite close" to mine, in the meaning that we have a dataset and want to classify.</p>
<p>What I want is to know ho to create my own model, like the iris one we can find in a lot of ML examples for noobs, but with my Q&A set. For example, I could have a table referencing the category of the question, its length, number of keywords, which ones, etc, but I don't know to do it. Then, I'm not sure which algorithm to use (I thought of KNN) but more importantly how to train the model and then use it for questions from user input.</p>
<p>Thank you guys.</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.