problem stringlengths 26 131k | labels class label 2
classes |
|---|---|
static void pre_process_video_frame(InputStream *ist, AVPicture *picture, void **bufp)
{
AVCodecContext *dec;
AVPicture *picture2;
AVPicture picture_tmp;
uint8_t *buf = 0;
dec = ist->st->codec;
if (FF_API_DEINTERLACE && do_deinterlace) {
int size;
size = avpicture_get_size(dec->pix_fmt, dec->width, dec->height);
if (size < 0)
return;
buf = av_malloc(size);
if (!buf)
return;
picture2 = &picture_tmp;
avpicture_fill(picture2, buf, dec->pix_fmt, dec->width, dec->height);
if (avpicture_deinterlace(picture2, picture,
dec->pix_fmt, dec->width, dec->height) < 0) {
av_log(NULL, AV_LOG_WARNING, "Deinterlacing failed\n");
av_free(buf);
buf = NULL;
picture2 = picture;
}
} else {
picture2 = picture;
}
if (picture != picture2)
*picture = *picture2;
*bufp = buf;
}
| 1threat |
Where are Heroku apps hosted exactly? : <p>Through <a href="https://devcenter.heroku.com/articles/regions" rel="noreferrer">https://devcenter.heroku.com/articles/regions</a> I see that for heroku common runtime spaces heroku has two available regions: Europe and United States. But I couldn't find exactly in any official documentation which region exactly of United States heroku hosts the application. For example I want to know if it hosts on east, west, north, south.</p>
<p>Thanks</p>
| 0debug |
What is the best way to use webpacker in a Rails engine? : <p>I realise there is some debate about using webpacker in Rails engines but I have a simple usecase and currently have a workaround. Would like to know of a better (the best?) solution.</p>
<p>In this rails engine I have webpacker setup in the "spec/dummy" directory and everything works well in dev:
<a href="https://github.com/RealEstateWebTools/property_web_scraper/tree/master/spec/dummy/config/webpack" rel="noreferrer">https://github.com/RealEstateWebTools/property_web_scraper/tree/master/spec/dummy/config/webpack</a></p>
<p>When the engine is used by a rails app however it will not find the compiled webpack files so each time I have a release ready I compile the webpack files and manually copy them to the vendor directory:
<a href="https://github.com/RealEstateWebTools/property_web_scraper/tree/master/vendor/assets/javascripts" rel="noreferrer">https://github.com/RealEstateWebTools/property_web_scraper/tree/master/vendor/assets/javascripts</a></p>
<p>I then require that file here:
<a href="https://github.com/RealEstateWebTools/property_web_scraper/blob/master/app/assets/javascripts/property_web_scraper/spp_vuetify.js" rel="noreferrer">https://github.com/RealEstateWebTools/property_web_scraper/blob/master/app/assets/javascripts/property_web_scraper/spp_vuetify.js</a></p>
<p>In my layout I use the above file using the good old sprockets "javascript_include_tag": <a href="https://github.com/RealEstateWebTools/property_web_scraper/blob/master/app/views/layouts/property_web_scraper/spp_vuetify.html.erb" rel="noreferrer">https://github.com/RealEstateWebTools/property_web_scraper/blob/master/app/views/layouts/property_web_scraper/spp_vuetify.html.erb</a></p>
<p>In the layout there is a check to see if I'm running the "spec/dummy" app in which case I will user webpacker as it would normally be used in dev.</p>
<p>There must be a better way than this.</p>
| 0debug |
How can memory be allocated to a macro? : <p>For the below piece of code , I have defined a macro <strong>abc</strong> whose value has been redefined twice . When we run the code , the output is some garbage value , I am not getting how the macro is getting a garbage value when it is a macro and memory can't be allocated to a macro <strong>abc</strong> ?</p>
<pre><code> #include<stdio.h>
#define abc 10
#define abc "rd"
int main()
{
printf("%d",abc);
return 0;
}
</code></pre>
| 0debug |
Counting number of integers in text file (undeclared identifier using fin>>x) : <p>I have a text file with an unknown number of integers. I created a dynamic array without trouble, but the numbers have varied spacing and digits. I would normally go through each position to count the number of spaces used, subtracting space from it, but that won't work in this case.</p>
<p>I thought to use something like this: (which similar questions would suggest)</p>
<pre><code> do
{
if (!file.is_open())
{
file.open(donation);
}
fin >> temp;
charCount++;
}
while (file.peek() != EOF);
cout << charCount;
</code></pre>
<p>Now, I have fstream included, and I am using namespace std, and I have no problem opening and reading the text file, but visual studio 2015 tells me:</p>
<p>Error C2065 'fin': undeclared identifier</p>
<p>I don't understand what I am doing that is triggering that type of response from the IDE.</p>
| 0debug |
FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr,
hwaddr data_addr, uint32_t data_width,
hwaddr dma_addr, AddressSpace *dma_as)
{
DeviceState *dev;
SysBusDevice *sbd;
FWCfgState *s;
bool dma_requested = dma_addr && dma_as;
dev = qdev_create(NULL, TYPE_FW_CFG_MEM);
qdev_prop_set_uint32(dev, "data_width", data_width);
if (!dma_requested) {
qdev_prop_set_bit(dev, "dma_enabled", false);
}
fw_cfg_init1(dev);
sbd = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(sbd, 0, ctl_addr);
sysbus_mmio_map(sbd, 1, data_addr);
s = FW_CFG(dev);
if (s->dma_enabled) {
s->dma_as = dma_as;
s->dma_addr = 0;
sysbus_mmio_map(sbd, 2, dma_addr);
}
return s;
}
| 1threat |
static void gen_brcond(DisasContext *dc, TCGCond cond,
TCGv_i32 t0, TCGv_i32 t1, uint32_t offset)
{
int label = gen_new_label();
gen_advance_ccount(dc);
tcg_gen_brcond_i32(cond, t0, t1, label);
gen_jumpi_check_loop_end(dc, 0);
gen_set_label(label);
gen_jumpi(dc, dc->pc + offset, 1);
}
| 1threat |
get the float number's exponents : <p>I just started learning floating point and get to know the SME stuff. I'm still very confused about the mantissa... Can somebody explain to me how can I get the exp part of the float. I am sorry if that's a super stupid and basic question but I am having a hard time understanding it...</p>
<p>Also how do I implement the following function... clearly my implementation is wrong. But how do I do it?</p>
<pre><code>// Extract the 8-bit exponent field of single precision
// floating point number f and return it as an unsigned byte
unsigned char get_exponent_field(float f)
{
// TODO: Your code here.
int bias = 127;
int expp = (int)f;
unsigned char E = expp-bias;
return E;
}
</code></pre>
| 0debug |
Conversion of Java to C# code : <p>All,</p>
<p>I am currently trying to convert some lines of code from Java to C# using Visual Studio 2013. However the lines below is causing me some issues:</p>
<pre><code>final double testdata[][] = {{patientTemperatureDouble, heartRateDouble, coughInteger, skinInteger}};
result[i] = BayesClassifier.CalculateProbability{testdata[k],category[i]};
</code></pre>
<p>Any clarification as to converting the array to a suitable c# format would be greatly appreciated, I have attempted using readonly and sealed but I've had no luck.</p>
<p>Thanks</p>
| 0debug |
Showing json content in HTML : Hi I am new to javascript and i need to show this json into a div on a html page, i can't use jquery can anyone help please.
var data = {
"music": [
{
"id": 1,
"artist": "Oasis",
"album": "Definitely Maybe",
"year": "1997"
},
]
} | 0debug |
iOS - How to debug a Safari ContentBlocker extension? : <p>I've written a very simple Safari Content Blocker and wrapper app. However, I'm at a loss as to how to go about debugging it. I've tried running the wrapper app and then running Safari, both within the iOS simulator. However, I do not see my content blocker being applied. (And, yes, I've enabled it in <code>Settings->Safari</code>) I've added <code>NSLog()</code> methods to my <code>beginRequest(with context: NSExtensionContext)</code> method, but do not see them written to the logs. I've tried adding breakpoints in this method, and Xcode never stops on them. So, it's clear to me that either my content blocker is not being installed properly, or I'm not debugging it properly. </p>
<p>Can anyone give me some guidance as to how to debug this extension?</p>
| 0debug |
Cannot find namespace error : <p>I have the following setup:</p>
<pre><code>// enums.ts
export enum DocumentType {
Email = 0,
Unknown = 1
}
</code></pre>
<p>-</p>
<pre><code>// remote.ts
/// <reference path="./remote.d.ts" />
import enums = require('./enums');
class Remote implements test.IRemote {
public docType: enums.DocumentType;
constructor() {
this.docType = enums.DocumentType.Unknown;
}
}
export = Remote;
</code></pre>
<p>-</p>
<pre><code>// remote.d.ts
import * as enums from './enums';
declare module test {
export interface IRemote {
docType: enums.DocumentType;
}
}
</code></pre>
<p>But when I run tsc over this I get <code>Cannot find namespace 'test'</code> from remotes.ts. What am I missing?</p>
<p>Other information that might be useful: I've recently upgraded from Typescript 1.5 to Typescript 1.8 and replaced the use of const enums with plain enums as in the example. </p>
| 0debug |
Create new array using JSON results with javascript : <p>Hello I have the following JSON result. Its a small snippet from a large JSON file. Theres hundreds of entries.</p>
<pre><code>var jsonResult = [
{
"id": "1",
"name": "one",
},
{
"id": "2",
"name": "two",
},
{
"id": "3",
"name": "three",
}
]
</code></pre>
<p>I would like a way to loop through this data using javascript to create a new array stored in a variable that pulls just the ids. So the new array would look like this:</p>
<pre><code>data = [1, 2, 3];
</code></pre>
<p>If theres 1000 entries, then the array would go from 1-1000.</p>
<p>Thanks!</p>
| 0debug |
How to create yes no confirm box instead of ok cancel upon button click in Javascript/Jquery? : <p>How to create yes no confirm box instead of ok cancel upon button click in Javascript/Jquery ?</p>
| 0debug |
Database Variable Java (Static vs enum) : <p>I'm just going through my code and tidying things up, standardising things etc.</p>
<p>Just a quick questionin my Database class I have declared the database variables at the start of the class. see below:</p>
<pre><code> private static final String DATABASE = ".....";
private static final String DRIVER = "....";
</code></pre>
<p>Is this the best way to do this or would I be best creating an enum and accessing them through that?</p>
<p>Do it really matter at the end of the day?</p>
<p>Thanks
Ian</p>
| 0debug |
Output all data from a MySQL Table PHP : I've been trying to do output all of the data from the table but when I do it, it outputs only the first one. Can anybody please help? This is my code:
$sql = "SELECT * FROM chatStorage";
$result = mysqli_query($conn, $sql);
$able = true;
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_array($result)) {
return $row["user"].": ".$row["chatText"];
}
}
any help? | 0debug |
Cannot redeclare block-scoped variable 'ngDevMode' : <p>My app in on Angular 5. Here is how the package.json looks like</p>
<pre><code>{
"name": "myapp",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"@types/file-saver": "0.0.1",
"angular-2-dropdown-multiselect": "^1.6.0",
"angular2-csv": "^0.2.5",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"file-saver": "^1.3.3",
"ngx-bootstrap": "^1.9.3",
"ngx-clipboard": "^8.1.0",
"ngx-loading": "^1.0.14",
"ngx-pagination": "^3.0.0",
"ngx-toastr": "^6.4.0",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"
},
"devDependencies": {
"@angular/cli": "~1.7.0",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
}
}
</code></pre>
<p>Everything is fine so far. Now I need to use a datepicker in my app. So I installed angular-io-datepicker</p>
<pre><code>npm install angular-io-datepicker --save
</code></pre>
<p>Now, when I do a ng serve (after including the OverlayModule and DatePickerModule in app.module.ts ), it gives me the below error</p>
<pre><code>ERROR in node_modules/@angular/core/src/render3/ng_dev_mode.d.ts(9,11): error TS2451: Cannot redeclare block-scoped variable 'ngDevMode'.
node_modules/angular-io-overlay/node_modules/@angular/core/src/render3/ng_dev_mode.d.ts(9,11): error TS2451: Cannot redeclare block-scoped variable 'ngDevMode'.
</code></pre>
<p>Any suggestions on what could be wrong and how to fix it? I was earlier using this module successfully with Angular 4. Then I upgraded to Angular 5 and it broke. Now even if I rollback to angular 4, this module still gives me the same problem. </p>
| 0debug |
[Verilog]IES error:HDLCompiler:806 : I keep getting errors below in ISE, and can not figure out the real problems. anyone has any clues?
error messages:
ERROR:HDLCompiler:806 - "C:\Users\Ray\Documents\project\QFC\QFC_A.v" Line 29: Syntax error near "posedge".
ERROR:HDLCompiler:806 - "C:\Users\Ray\Documents\project\QFC\QFC_A.v" Line 39: Syntax error near "<=".
ERROR:HDLCompiler:806 - "C:\Users\Ray\Documents\project\QFC\QFC_A.v" Line 43: Syntax error near "<=".
ERROR:HDLCompiler:806 - "C:\Users\Ray\Documents\project\QFC\QFC_A.v" Line 47: Syntax error near "<=".
ERROR:HDLCompiler:806 - "C:\Users\Ray\Documents\project\QFC\QFC_A.v" Line 50: Syntax error near "end".
ERROR:HDLCompiler:806 - "C:\Users\Ray\Documents\project\QFC\QFC_A.v" Line 54: Syntax error near "posedge".
ERROR:HDLCompiler:806 - "C:\Users\Ray\Documents\project\QFC\QFC_A.v" Line 64: Syntax error near "<=".
ERROR:HDLCompiler:806 - "C:\Users\Ray\Documents\project\QFC\QFC_A.v" Line 68: Syntax error near "<=".
ERROR:HDLCompiler:806 - "C:\Users\Ray\Documents\project\QFC\QFC_A.v" Line 72: Syntax error near "<=".
ERROR:HDLCompiler:806 - "C:\Users\Ray\Documents\project\QFC\QFC_A.v" Line 75: Syntax error near "end".
ERROR:HDLCompiler:806 - "C:\Users\Ray\Documents\project\QFC\QFC_A.v" Line 88: Syntax error near "posedge".
ERROR:HDLCompiler:806 - "C:\Users\Ray\Documents\project\QFC\QFC_A.v" Line 98: Syntax error near "<=".
ERROR:HDLCompiler:806 - "C:\Users\Ray\Documents\project\QFC\QFC_A.v" Line 102: Syntax error near "<=".
ERROR:HDLCompiler:806 - "C:\Users\Ray\Documents\project\QFC\QFC_A.v" Line 106: Syntax error near "<=".
ERROR:HDLCompiler:806 - "C:\Users\Ray\Documents\project\QFC\QFC_A.v" Line 109: Syntax error near "end".
ERROR:HDLCompiler:806 - "C:\Users\Ray\Documents\project\QFC\QFC_A.v" Line 113: Syntax error near "posedge".
ERROR:HDLCompiler:806 - "C:\Users\Ray\Documents\project\QFC\QFC_A.v" Line 123: Syntax error near "<=".
ERROR:HDLCompiler:806 - "C:\Users\Ray\Documents\project\QFC\QFC_A.v" Line 127: Syntax error near "<=".
ERROR:HDLCompiler:806 - "C:\Users\Ray\Documents\project\QFC\QFC_A.v" Line 131: Syntax error near "<=".
and here is my code:
`timescale 1ns/1ps
module QFC_A #
(
parameter SPI_CYCLE = 100000,
parameter MASTER_ID = 8'h66,
parameter SLAVE_ID = 8'h66
)
(
input i_axi_lite_s_aclk,
input i_rst,
input i_din,
output o_en,
output o_dout
);
reg [255:0] r_frame_message;
reg [3:0] r_cnt_message;
wire [31:0] w_frame_word_message;
wire w_message_rd_en;
wire w_id_match_message;
wire w_message_empty;
wire w_message_ready;
always @ (posedge i_axi_lite_s_aclk & posedge i_rst)
begin
if (i_rst)
begin
r_frame_message <= 256'h0;
end
else
begin
if (w_id_match_message & (r_cnt_message != 4'hf))
begin
r_frame_message <= {224'h0, w_frame_word_message};
end
else if (w_message_rd_en & w_message_empty)
begin
r_frame_message <= 256'h0;
end
else if (w_message_rd_en)
begin
r_frame_message <= {r_frame_message[223:0], w_frame_word_message};
end
end
end
assign w_id_match_message = (w_frame_word_message[23:16] == MASTER_ID)? 1'b1 : 1'b0;
always @ (posedge i_axi_lite_s_aclk & posedge i_rst)
begin
if (i_rst)
begin
r_cnt_message <= 4'h0;
end
else if (w_message_rd_en)
begin
if (w_id_match_message)
begin
r_cnt_message <= 4'h0;
end
else if (r_cnt_message == 4'hf)
begin
r_cnt_message <= 4'h0;
end
else
begin
r_cnt_message <= r_cnt_message + 4'h1;
end
end
end
assign w_message_ready = (r_cnt_message == 4'hf & ~w_send_ready)? 1'b1 : 1'b0;
reg [255:0] r_frame_data;
reg [3:0] r_cnt_data;
wire [31:0] w_frame_word_data;
wire w_data_rd_en;
wire w_id_match_data;
wire w_data_empty;
wire w_data_ready;
always @ (posedge i_axi_lite_s_aclk & posedge i_rst)
begin
if (i_rst)
begin
r_frame_data <= 256'h0;
end
else
begin
if (w_id_match_data & (r_cnt_data != 4'hf))
begin
r_frame_data <= {224'h0, w_frame_word_data};
end
else if (w_data_rd_en & w_data_empty)
begin
r_frame_data <= 256'h0;
end
else if (w_data_rd_en)
begin
r_frame_data <= {r_frame_data[223:0], w_frame_word_data};
end
end
end
assign w_id_match_data = (w_frame_word_data[23:16] == MASTER_ID)? 1'b1 : 1'b0;
always @ (posedge i_axi_lite_s_aclk & posedge i_rst)
begin
if (i_rst)
begin
r_cnt_data <= 4'h0;
end
else if (w_data_rd_en)
begin
if (w_id_match_data)
begin
r_cnt_data <= 4'h0;
end
else if (r_cnt_data == 4'hf)
begin
r_cnt_data <= 4'h0;
end
else
begin
r_cnt_data <= r_cnt_data + 4'h1;
end
end
end
assign w_data_ready = (r_cnt_data == 4'hf & ~w_send_ready)? 1'b1 : 1'b0;
reg [255:0] r_frame_rec;
reg [3:0] r_cnt_rec;
wire[31:0] w_frame_word_rec;
wire w_rec_en;
wire w_id_match_rec;
wire w_rec_ready;
wire w_rec_success;
always @ (posedge i_axi_lite_s_aclk & posedge i_rst)
begin
if (i_rst)
begin
r_frame_rec <= 256'h0;
end
else
begin
if (w_id_match_rec & (r_cnt_rec != 4'hf))
begin
r_frame_rec <= {224'h0, w_frame_word_rec};
end
else if (w_rec_en)
begin
r_frame_rec <= {r_frame_rec[223:0], w_frame_word_rec};
end
end
end
assign w_id_match_rec = (w_frame_word_rec[23:16] == SLAVE_ID)? 1'b1 : 1'b0;
always @ (posedge i_axi_lite_s_aclk & posedge i_rst)
begin
if (i_rst)
begin
r_cnt_rec <= 4'h0;
end
else if (w_rec_en)
begin
if (w_id_match_rec)
begin
r_cnt_rec <= 4'h0;
end
else if (r_cnt_rec == 4'hf)
begin
r_cnt_rec <= 4'h0;
end
else
begin
r_cnt_rec <= r_cnt_rec + 4'h1;
end
end
end
assign w_rec_ready = (r_cnt_rec == 4'hf)? 1'b1 : 1'b0;
assign w_rec_success = ((w_rec_ready) & (r_frame_rec[251] == 1'b1) & (checksum(r_frame_rec[239:16]) == r_frame_rec[15:0]))? 1'b1 : 1'b0;
reg [2:0] r_current_state;
reg [2:0] r_next_state;
reg [16:0] r_cycle_timer;
reg [14:0] r_trans_timer;
reg [1:0] r_cycle_s;
reg [223:0] r_payload;
reg [255:0] r_frame_send;
wire w_cycle;
wire w_cycle_pos;
wire w_state_start;
localparam IDLE = 3'h0;
localparam SEND_MSG = 3'h1;
localparam RESEND_MSG = 3'h2;
localparam SEND_DATA = 3'h3;
localparam RCG_ACK = 3'h4;
localparam CHANGE_TLG = 3'h5;
localparam ABORT_MSG = 3'h6;
always @ (posedge i_axi_lite_s_aclk & posedge i_rst)
begin
if (i_rst)
begin
r_cycle_timer <= 16'h0;
end
else if (r_cycle_timer < SPI_CYCLE)
begin
r_cycle_timer <= r_cycle_timer + 16'h1;
end
else
begin
r_cycle_timer <= 16'h0;
end
end
assign w_cycle = (r_cycle_timer == SPI_CYCLE)? 1'b1 : 1'b0;
always @ (posedge i_axi_lite_s_aclk & posedge i_rst)
begin
if(i_rst)
begin
r_cycle_s <= 2'h0;
end
else
begin
r_cycle_s <= {r_cycle_s[0], w_cycle};
end
end
assign w_cycle_pos = (~r_cycle_s[1] & r_cycle_s[0]);
function reg [15:0] checksum (input reg [223:0] r_frame)
begin
integer i;
reg [15:0] r_sum_1;
reg [15:0] r_sum_2;
r_sum_1 = 16'hff;
r_sum_2 = 16'hff;
for (i = 0; i < 28; i++)
begin
r_sum_1 = r_sum_1 + r_frame[(223-8*i)-:8];
r_sum_2 = r_sum_1 + r_sum_2;
if (i == 20)
begin
r_sum_1 = ( r_sum_1 >> 8 ) + ( r_sum_1 & 8'hff);
r_sum_2 = ( r_sum_2 >> 8 ) + ( r_sum_2 & 8'hff);
end
end
r_sum_1 = ( r_sum_1 >> 8 ) + ( r_sum_1 & 8'hff);
r_sum_2 = ( r_sum_2 >> 8 ) + ( r_sum_2 & 8'hff);
r_sum_1 = ( r_sum_1 >> 8 ) + ( r_sum_1 & 8'hff);
r_sum_2 = ( r_sum_2 >> 8 ) + ( r_sum_2 & 8'hff);
checksum = (r_sum_1 << 8) | r_sum_2;
end
endfunction
always @ (*)
begin
case (r_current_state)
IDLE: begin
r_next_state = SEND_DATA;
r_frame_send = {8'h90, MASTER_ID, 240'h0};
end
SEND_MSG: begin
r_next_state = RCG_ACK;
if (w_state_start)
begin
w_message_rd_en = 1'b1;
w_send_ready = 1'b0;
w_state_start = 1'b0;
end
if (r_frame_message == 256'h0)
begin
w_message_rd_en = 1'b0;
r_frame_send = {r_frame_send[], MASTER_ID, 240'h0};
end
else if
end
RCG_ACK: begin
if (w_rec_success)
begin
r_next_state = CHANGE_TLG;
end
else if (r_resend_cnt == 2'b11)
begin
r_next_state = ABORT_MSG;
end
end
endcase
end
endmodule
| 0debug |
Activity in androidTest not getting launched by ActivityTestRule : <p>I want to test a fragment in test activity. I added <code>TestTragmentActivity</code> to <code>androidTest</code> along with <code>AndroidManifest.xml</code> file. But when I try to use this activity via an <code>ActivityTestRule</code> it gives following error:</p>
<pre><code>java.lang.RuntimeException: Could not launch activity
at android.support.test.runner.MonitoringInstrumentation.startActivitySync(MonitoringInstrumentation.java:371)
at android.support.test.rule.ActivityTestRule.launchActivity(ActivityTestRule.java:219)
at com.bbm.ui.fragments.StickerPackListFragmentTest.testEmpty(StickerPackListFragmentTest.java:29)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at android.support.test.internal.statement.UiThreadStatement.evaluate(UiThreadStatement.java:55)
at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:270)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:59)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:262)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1887)
Caused by: java.lang.RuntimeException: Unable to resolve activity for: Intent { act=android.intent.action.MAIN flg=0x14000000 cmp=com.bbm.debug/com.bbm.TestFragmentActivity }
at android.app.Instrumentation.startActivitySync(Instrumentation.java:391)
at android.support.test.runner.MonitoringInstrumentation.access$201(MonitoringInstrumentation.java:90)
at android.support.test.runner.MonitoringInstrumentation$5.call(MonitoringInstrumentation.java:351)
at android.support.test.runner.MonitoringInstrumentation$5.call(MonitoringInstrumentation.java:348)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
</code></pre>
<p>The <code>TestFragmentActivity</code> is just an empty activity. Below is the <code>AndroidManifest.xml</code> in the <code>androidTest</code> folder.</p>
<pre><code><manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.bbm">
<application
android:label="@string/app_name"
tools:replace="android:label">
<activity android:name=".TestFragmentActivity"></activity>
</application>
</manifest>
</code></pre>
<p>I tried to get some data about why this is happening. Below is my test:</p>
<pre><code>@RunWith(AndroidJUnit4.class)
public class TestFragment {
@Rule
public ActivityTestRule<TestFragmentActivity> rule =
new ActivityTestRule<>(TestFragmentActivity.class, false, false);
@Test
public void testEmpty() {
// Just for logging purpose
printActivities(InstrumentationRegistry.getTargetContext(), "APP_TARGET_CONTEXT");
printActivities(InstrumentationRegistry.getContext(), "APP_CONTEXT");
// The launch fails....
rule.launchActivity(null);
}
private void printActivities(Context context, String tag) {
try {
ActivityInfo[] infos = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_ACTIVITIES).activities;
for(ActivityInfo info : infos) {
Log.d(tag, info.name);
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
Log.d(tag + "_PACKAGE_NAME", context.getPackageName());
}
}
</code></pre>
<p>The output of above is:</p>
<pre><code>10-06 18:46:45.419 13030-13052/com.example.achhatra.myapplication D/APP_TARGET_CONTEXT: com.example.achhatra.myapplication.MainActivity
10-06 18:46:45.419 13030-13052/com.example.achhatra.myapplication D/APP_TARGET_CONTEXT_PACKAGE_NAME: com.example.achhatra.myapplication
10-06 18:46:45.419 13030-13052/com.example.achhatra.myapplication D/APP_CONTEXT: com.example.achhatra.myapplication.TestFragmentActivity
10-06 18:46:45.419 13030-13052/com.example.achhatra.myapplication D/APP_CONTEXT_PACKAGE_NAME: com.example.achhatra.myapplication.test
</code></pre>
<p>As you can see the <code>TestFragmentActivity</code> is in the <code>androidTest</code> context and not in the target context. That is the reason <code>ActivityTestRule</code> is not able to launch it. </p>
<p>I would like to know how can I launch this <code>TestFragmentActivity</code> in this test.</p>
| 0debug |
void vnc_tight_clear(VncState *vs)
{
int i;
for (i=0; i<ARRAY_SIZE(vs->tight.stream); i++) {
if (vs->tight.stream[i].opaque) {
deflateEnd(&vs->tight.stream[i]);
}
}
buffer_free(&vs->tight.tight);
buffer_free(&vs->tight.zlib);
buffer_free(&vs->tight.gradient);
#ifdef CONFIG_VNC_JPEG
buffer_free(&vs->tight.jpeg);
} | 1threat |
db.execute('SELECT * FROM products WHERE product_id = ' + product_input) | 1threat |
void memory_region_add_eventfd(MemoryRegion *mr,
hwaddr addr,
unsigned size,
bool match_data,
uint64_t data,
EventNotifier *e)
{
MemoryRegionIoeventfd mrfd = {
.addr.start = int128_make64(addr),
.addr.size = int128_make64(size),
.match_data = match_data,
.data = data,
.e = e,
};
unsigned i;
if (size) {
adjust_endianness(mr, &mrfd.data, size);
memory_region_transaction_begin();
for (i = 0; i < mr->ioeventfd_nb; ++i) {
if (memory_region_ioeventfd_before(mrfd, mr->ioeventfds[i])) {
break;
++mr->ioeventfd_nb;
mr->ioeventfds = g_realloc(mr->ioeventfds,
sizeof(*mr->ioeventfds) * mr->ioeventfd_nb);
memmove(&mr->ioeventfds[i+1], &mr->ioeventfds[i],
sizeof(*mr->ioeventfds) * (mr->ioeventfd_nb-1 - i));
mr->ioeventfds[i] = mrfd;
ioeventfd_update_pending |= mr->enabled;
memory_region_transaction_commit(); | 1threat |
void qtest_qmpv_discard_response(QTestState *s, const char *fmt, va_list ap)
{
bool has_reply = false;
int nesting = 0;
socket_sendf(s->qmp_fd, fmt, ap);
while (!has_reply || nesting > 0) {
ssize_t len;
char c;
len = read(s->qmp_fd, &c, 1);
if (len == -1 && errno == EINTR) {
continue;
}
if (len == -1 || len == 0) {
fprintf(stderr, "Broken pipe\n");
exit(1);
}
switch (c) {
case '{':
nesting++;
has_reply = true;
break;
case '}':
nesting--;
break;
}
}
}
| 1threat |
int qio_channel_readv_all(QIOChannel *ioc,
const struct iovec *iov,
size_t niov,
Error **errp)
{
int ret = -1;
struct iovec *local_iov = g_new(struct iovec, niov);
struct iovec *local_iov_head = local_iov;
unsigned int nlocal_iov = niov;
nlocal_iov = iov_copy(local_iov, nlocal_iov,
iov, niov,
0, iov_size(iov, niov));
while (nlocal_iov > 0) {
ssize_t len;
len = qio_channel_readv(ioc, local_iov, nlocal_iov, errp);
if (len == QIO_CHANNEL_ERR_BLOCK) {
qio_channel_wait(ioc, G_IO_IN);
continue;
} else if (len < 0) {
goto cleanup;
} else if (len == 0) {
error_setg(errp,
"Unexpected end-of-file before all bytes were read");
goto cleanup;
}
iov_discard_front(&local_iov, &nlocal_iov, len);
}
ret = 0;
cleanup:
g_free(local_iov_head);
return ret;
}
| 1threat |
Call C header file functions in a Python module : <p>I need to convert cfgmgr32 api header(cfgmgr.h) from C to a python module. So that I can call any the C header functions from other python script</p>
| 0debug |
open new window after cancel confirmation in Java Script : i want when the user clicks on closing the web page window /tab a cancel confirmation should come up and when the users click "OK" the current page closes and a new window in opened, this is what i've dine so far and it doesn't work:
function confirmit(){
var closeit= confirm("شكراً لك :) فقط نرجوا القليل من وقتك لتعبئة الاستبانة");
if (closeit == true){
window.open("https://www.surveymonkey.com/r/3DMJGYX", "الاستبانة");}
else{
window.close();}}
window.onbeforeunload = function(){
$.ajax({
type: 'GET',
url: 'http://gadgetron.store/chatbot/run_python_clear_chatM/',});
confirmit();
}
Thank you, | 0debug |
static void init_excp_602 (CPUPPCState *env)
{
#if !defined(CONFIG_USER_ONLY)
env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100;
env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200;
env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300;
env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400;
env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500;
env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600;
env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700;
env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800;
env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900;
env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00;
env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00;
env->excp_vectors[POWERPC_EXCP_FPA] = 0x00000E00;
env->excp_vectors[POWERPC_EXCP_IFTLB] = 0x00001000;
env->excp_vectors[POWERPC_EXCP_DLTLB] = 0x00001100;
env->excp_vectors[POWERPC_EXCP_DSTLB] = 0x00001200;
env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300;
env->excp_vectors[POWERPC_EXCP_SMI] = 0x00001400;
env->excp_vectors[POWERPC_EXCP_WDT] = 0x00001500;
env->excp_vectors[POWERPC_EXCP_EMUL] = 0x00001600;
env->excp_prefix = 0xFFF00000UL;
env->hreset_vector = 0xFFFFFFFCUL;
#endif
}
| 1threat |
Date Difference between consecutive rows plsql : I have a table with following structure
RetailerCode Orderdate
714 01-JUL-16
838 01-JUL-16
556 04-JUL-16
1003 04-JUL-16
284 01-JUL-16
1205 06-JUL-16
271 06-JUL-16
863 02-JUL-16
640 02-JUL-16
937 02-JUL-16
321 02-JUL-16
1176 06-JUL-16
998 04-JUL-16
237 05-JUL-16
1103 05-JUL-16
417 06-JUL-16
1264 07-JUL-16
462 07-JUL-16
445 07-JUL-16
913 02-JUL-16
859 02-JUL-16
196 04-JUL-16
778 05-JUL-16
i wants this type
1001 10/9/2011 - 12/9/2011 2 days
1001 12/9/2011 - 20/9/2011 8 days
1001 20/9/2011 NA | 0debug |
build_dsdt(GArray *table_data, BIOSLinker *linker,
AcpiPmInfo *pm, AcpiMiscInfo *misc,
Range *pci_hole, Range *pci_hole64, MachineState *machine)
{
CrsRangeEntry *entry;
Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs;
CrsRangeSet crs_range_set;
PCMachineState *pcms = PC_MACHINE(machine);
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(machine);
uint32_t nr_mem = machine->ram_slots;
int root_bus_limit = 0xFF;
PCIBus *bus = NULL;
int i;
dsdt = init_aml_allocator();
acpi_data_push(dsdt->buf, sizeof(AcpiTableHeader));
build_dbg_aml(dsdt);
if (misc->is_piix4) {
sb_scope = aml_scope("_SB");
dev = aml_device("PCI0");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03")));
aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
aml_append(dev, aml_name_decl("_UID", aml_int(1)));
aml_append(sb_scope, dev);
aml_append(dsdt, sb_scope);
build_hpet_aml(dsdt);
build_piix4_pm(dsdt);
build_piix4_isa_bridge(dsdt);
build_isa_devices_aml(dsdt);
build_piix4_pci_hotplug(dsdt);
build_piix4_pci0_int(dsdt);
} else {
sb_scope = aml_scope("_SB");
dev = aml_device("PCI0");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A08")));
aml_append(dev, aml_name_decl("_CID", aml_eisaid("PNP0A03")));
aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
aml_append(dev, aml_name_decl("_UID", aml_int(1)));
aml_append(dev, build_q35_osc_method());
aml_append(sb_scope, dev);
aml_append(dsdt, sb_scope);
build_hpet_aml(dsdt);
build_q35_isa_bridge(dsdt);
build_isa_devices_aml(dsdt);
build_q35_pci0_int(dsdt);
}
if (pcmc->legacy_cpu_hotplug) {
build_legacy_cpu_hotplug_aml(dsdt, machine, pm->cpu_hp_io_base);
} else {
CPUHotplugFeatures opts = {
.apci_1_compatible = true, .has_legacy_cphp = true
};
build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base,
"\\_SB.PCI0", "\\_GPE._E02");
}
build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0", "\\_GPE._E03");
scope = aml_scope("_GPE");
{
aml_append(scope, aml_name_decl("_HID", aml_string("ACPI0006")));
if (misc->is_piix4) {
method = aml_method("_E01", 0, AML_NOTSERIALIZED);
aml_append(method,
aml_acquire(aml_name("\\_SB.PCI0.BLCK"), 0xFFFF));
aml_append(method, aml_call0("\\_SB.PCI0.PCNT"));
aml_append(method, aml_release(aml_name("\\_SB.PCI0.BLCK")));
aml_append(scope, method);
}
if (pcms->acpi_nvdimm_state.is_enabled) {
method = aml_method("_E04", 0, AML_NOTSERIALIZED);
aml_append(method, aml_notify(aml_name("\\_SB.NVDR"),
aml_int(0x80)));
aml_append(scope, method);
}
}
aml_append(dsdt, scope);
crs_range_set_init(&crs_range_set);
bus = PC_MACHINE(machine)->bus;
if (bus) {
QLIST_FOREACH(bus, &bus->child, sibling) {
uint8_t bus_num = pci_bus_num(bus);
uint8_t numa_node = pci_bus_numa_node(bus);
if (!pci_bus_is_root(bus)) {
continue;
}
if (bus_num < root_bus_limit) {
root_bus_limit = bus_num - 1;
}
scope = aml_scope("\\_SB");
dev = aml_device("PC%.02X", bus_num);
aml_append(dev, aml_name_decl("_UID", aml_int(bus_num)));
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03")));
aml_append(dev, aml_name_decl("_BBN", aml_int(bus_num)));
if (pci_bus_is_express(bus)) {
aml_append(dev, build_q35_osc_method());
}
if (numa_node != NUMA_NODE_UNASSIGNED) {
aml_append(dev, aml_name_decl("_PXM", aml_int(numa_node)));
}
aml_append(dev, build_prt(false));
crs = build_crs(PCI_HOST_BRIDGE(BUS(bus)->parent), &crs_range_set);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
aml_append(dsdt, scope);
}
}
scope = aml_scope("\\_SB.PCI0");
crs = aml_resource_template();
aml_append(crs,
aml_word_bus_number(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE,
0x0000, 0x0, root_bus_limit,
0x0000, root_bus_limit + 1));
aml_append(crs, aml_io(AML_DECODE16, 0x0CF8, 0x0CF8, 0x01, 0x08));
aml_append(crs,
aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,
AML_POS_DECODE, AML_ENTIRE_RANGE,
0x0000, 0x0000, 0x0CF7, 0x0000, 0x0CF8));
crs_replace_with_free_ranges(crs_range_set.io_ranges, 0x0D00, 0xFFFF);
for (i = 0; i < crs_range_set.io_ranges->len; i++) {
entry = g_ptr_array_index(crs_range_set.io_ranges, i);
aml_append(crs,
aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,
AML_POS_DECODE, AML_ENTIRE_RANGE,
0x0000, entry->base, entry->limit,
0x0000, entry->limit - entry->base + 1));
}
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
AML_CACHEABLE, AML_READ_WRITE,
0, 0x000A0000, 0x000BFFFF, 0, 0x00020000));
crs_replace_with_free_ranges(crs_range_set.mem_ranges,
range_lob(pci_hole),
range_upb(pci_hole));
for (i = 0; i < crs_range_set.mem_ranges->len; i++) {
entry = g_ptr_array_index(crs_range_set.mem_ranges, i);
aml_append(crs,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
AML_NON_CACHEABLE, AML_READ_WRITE,
0, entry->base, entry->limit,
0, entry->limit - entry->base + 1));
}
if (!range_is_empty(pci_hole64)) {
crs_replace_with_free_ranges(crs_range_set.mem_64bit_ranges,
range_lob(pci_hole64),
range_upb(pci_hole64));
for (i = 0; i < crs_range_set.mem_64bit_ranges->len; i++) {
entry = g_ptr_array_index(crs_range_set.mem_64bit_ranges, i);
aml_append(crs,
aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED,
AML_MAX_FIXED,
AML_CACHEABLE, AML_READ_WRITE,
0, entry->base, entry->limit,
0, entry->limit - entry->base + 1));
}
}
if (misc->tpm_version != TPM_VERSION_UNSPEC) {
aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
}
aml_append(scope, aml_name_decl("_CRS", crs));
dev = aml_device("GPE0");
aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
aml_append(dev, aml_name_decl("_UID", aml_string("GPE0 resources")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, pm->gpe0_blk, pm->gpe0_blk, 1, pm->gpe0_blk_len)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
crs_range_set_free(&crs_range_set);
if (pm->pcihp_io_len) {
dev = aml_device("PHPR");
aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
aml_append(dev,
aml_name_decl("_UID", aml_string("PCI Hotplug resources")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, pm->pcihp_io_base, pm->pcihp_io_base, 1,
pm->pcihp_io_len)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
}
aml_append(dsdt, scope);
scope = aml_scope("\\");
if (!pm->s3_disabled) {
pkg = aml_package(4);
aml_append(pkg, aml_int(1));
aml_append(pkg, aml_int(1));
aml_append(pkg, aml_int(0));
aml_append(pkg, aml_int(0));
aml_append(scope, aml_name_decl("_S3", pkg));
}
if (!pm->s4_disabled) {
pkg = aml_package(4);
aml_append(pkg, aml_int(pm->s4_val));
aml_append(pkg, aml_int(pm->s4_val));
aml_append(pkg, aml_int(0));
aml_append(pkg, aml_int(0));
aml_append(scope, aml_name_decl("_S4", pkg));
}
pkg = aml_package(4);
aml_append(pkg, aml_int(0));
aml_append(pkg, aml_int(0));
aml_append(pkg, aml_int(0));
aml_append(pkg, aml_int(0));
aml_append(scope, aml_name_decl("_S5", pkg));
aml_append(dsdt, scope);
{
uint8_t io_size = object_property_get_bool(OBJECT(pcms->fw_cfg),
"dma_enabled", NULL) ?
ROUND_UP(FW_CFG_CTL_SIZE, 4) + sizeof(dma_addr_t) :
FW_CFG_CTL_SIZE;
scope = aml_scope("\\_SB.PCI0");
dev = aml_device("FWCF");
aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, FW_CFG_IO_BASE, FW_CFG_IO_BASE, 0x01, io_size)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
aml_append(dsdt, scope);
}
if (misc->applesmc_io_base) {
scope = aml_scope("\\_SB.PCI0.ISA");
dev = aml_device("SMC");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("APP0001")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, misc->applesmc_io_base, misc->applesmc_io_base,
0x01, APPLESMC_MAX_DATA_LENGTH)
);
aml_append(crs, aml_irq_no_flags(6));
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
aml_append(dsdt, scope);
}
if (misc->pvpanic_port) {
scope = aml_scope("\\_SB.PCI0.ISA");
dev = aml_device("PEVT");
aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0001")));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, misc->pvpanic_port, misc->pvpanic_port, 1, 1)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(dev, aml_operation_region("PEOR", AML_SYSTEM_IO,
aml_int(misc->pvpanic_port), 1));
field = aml_field("PEOR", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
aml_append(field, aml_named_field("PEPT", 8));
aml_append(dev, field);
aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
method = aml_method("RDPT", 0, AML_NOTSERIALIZED);
aml_append(method, aml_store(aml_name("PEPT"), aml_local(0)));
aml_append(method, aml_return(aml_local(0)));
aml_append(dev, method);
method = aml_method("WRPT", 1, AML_NOTSERIALIZED);
aml_append(method, aml_store(aml_arg(0), aml_name("PEPT")));
aml_append(dev, method);
aml_append(scope, dev);
aml_append(dsdt, scope);
}
sb_scope = aml_scope("\\_SB");
{
Object *pci_host;
PCIBus *bus = NULL;
pci_host = acpi_get_i386_pci_host();
if (pci_host) {
bus = PCI_HOST_BRIDGE(pci_host)->bus;
}
if (bus) {
Aml *scope = aml_scope("PCI0");
build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
if (misc->tpm_version != TPM_VERSION_UNSPEC) {
dev = aml_device("ISA.TPM");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31")));
aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
crs = aml_resource_template();
aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
}
aml_append(sb_scope, scope);
}
}
aml_append(dsdt, sb_scope);
g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len);
build_header(linker, table_data,
(void *)(table_data->data + table_data->len - dsdt->buf->len),
"DSDT", dsdt->buf->len, 1, NULL, NULL);
free_aml_allocator();
}
| 1threat |
The use of T[] as a template parameter : <p>I've recently stumbled upon the use of <code>unique_ptr<T[]></code>, where I understand that the aim is to delete the pointer with <code>delete[]</code>. </p>
<p>What puzzles me is that <code>unique_ptr<T[3]></code> is instead invalid (correct me if I'm wrong). </p>
<p>What is the type of T[] in the template? How is it different from T[3]? These are arrays, so shouldn't they be the same? Is there any other use of T[] as a type in templates?</p>
| 0debug |
Can a lambda in an AWS Step Function know the name of the step it is in? : <p>For a lambda executed within a step function, I kind of expected that I could get the name of the current step from the lambda context, but it doesn't seem to be that simple.</p>
<p>Is there any way to get the name of the current step in a lambda that is executed within a Step Function?</p>
| 0debug |
How to play sound in c++ : <p>I was wondering how to play some default sound in c++. I do not want to download any additional files (programs nor music). Just to play 2 or 3 notes like bip bip. How should I write this code?</p>
| 0debug |
'is not within a known GOPATH/src' error on dep init : <p>When I run <code>dep init</code> in project folder, the error occurs:</p>
<blockquote>
<p>init failed: unable to detect the containing GOPATH: D:\projects\foo is not within a known GOPATH/src</p>
</blockquote>
<p>My projects are located on another drive and not <code>%GOPATH%/src</code> (i.e. <code>%USERPROFILE%\go\src</code>).</p>
<p>It's a known error but it's unclear what is the solution.</p>
<p>How can I use <code>dep</code> without moving Go projects to <code>%GOPATH%/src</code>?</p>
| 0debug |
fork_exec(struct socket *so, const char *ex, int do_pty)
{
int s;
struct sockaddr_in addr;
socklen_t addrlen = sizeof(addr);
int opt;
const char *argv[256];
char *bptr;
const char *curarg;
int c, i, ret;
pid_t pid;
DEBUG_CALL("fork_exec");
DEBUG_ARG("so = %p", so);
DEBUG_ARG("ex = %p", ex);
DEBUG_ARG("do_pty = %x", do_pty);
if (do_pty == 2) {
return 0;
} else {
addr.sin_family = AF_INET;
addr.sin_port = 0;
addr.sin_addr.s_addr = INADDR_ANY;
if ((s = qemu_socket(AF_INET, SOCK_STREAM, 0)) < 0 ||
bind(s, (struct sockaddr *)&addr, addrlen) < 0 ||
listen(s, 1) < 0) {
error_report("Error: inet socket: %s", strerror(errno));
closesocket(s);
return 0;
}
}
pid = fork();
switch(pid) {
case -1:
error_report("Error: fork failed: %s", strerror(errno));
close(s);
return 0;
case 0:
setsid();
getsockname(s, (struct sockaddr *)&addr, &addrlen);
close(s);
s = qemu_socket(AF_INET, SOCK_STREAM, 0);
addr.sin_addr = loopback_addr;
do {
ret = connect(s, (struct sockaddr *)&addr, addrlen);
} while (ret < 0 && errno == EINTR);
dup2(s, 0);
dup2(s, 1);
dup2(s, 2);
for (s = getdtablesize() - 1; s >= 3; s--)
close(s);
i = 0;
bptr = g_strdup(ex);
if (do_pty == 1) {
argv[i++] = "slirp.telnetd";
argv[i++] = "-x";
argv[i++] = bptr;
} else
do {
curarg = bptr;
while (*bptr != ' ' && *bptr != (char)0)
bptr++;
c = *bptr;
*bptr++ = (char)0;
argv[i++] = g_strdup(curarg);
} while (c);
argv[i] = NULL;
execvp(argv[0], (char **)argv);
fprintf(stderr, "Error: execvp of %s failed: %s\n",
argv[0], strerror(errno));
close(0); close(1); close(2);
exit(1);
default:
qemu_add_child_watch(pid);
do {
so->s = accept(s, (struct sockaddr *)&addr, &addrlen);
} while (so->s < 0 && errno == EINTR);
closesocket(s);
socket_set_fast_reuse(so->s);
opt = 1;
qemu_setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));
qemu_set_nonblock(so->s);
if (so->so_m != NULL && do_pty == 1) {
sbappend(so, so->so_m);
so->so_m = NULL;
}
return 1;
}
}
| 1threat |
static void iostatus_bdrv_it(void *opaque, BlockDriverState *bs)
{
bdrv_iostatus_reset(bs);
}
| 1threat |
Updating PostgresSQL table with binary data : I have a `stringstream strs` variable with this serialized binary data:
> �G�{SSF��*>%�����hgRQ;Tjh A "ʐk�R3 1[Z�yA _�Kx
> O��� ���f��' ����t %��+>, ���~� 삾�+/ Tb�Ҷ�7 �(���� �Q1�5m&
> ��( G#�bm 3O�AN ) �DP߇g �0=ʆ�0 ���j�u E�3�� �G�#�" \��!�o%
> L.�� �WMG?B- 3����}& �.�S� (�B� �j&� �@��%&, 65��0 !G�5R
> ��N��0 ��b�� hv) �8�� x<n} Җp{�F ��mŵ8 (��ۡ: ��b=�"
> ��[)�� m�fd�0 [VAl�� �o'9# ����� |'��K{ B��v��+ x����!
> qOwz* T�*�H;a$�� ���� �,m��� D��T ��7 ;:��8� ~��0��
> �>�%7 5e��: w|7ώJ 8���� ����X/ v�c�h2 3��i� o^���
> �A��� �oG��0 +���Ȑ" n�� ���4 F#�>b .��m�=; � �X ��< �
> c(= ���7Y`: �� �� Q��O� w�k�q! �D��G�8 O���l�1 j��DH ��rhJ
> v͑UF� �P���; �| ���h �U��z�* 0 Ԏ��6 @I� ��,K�� �R�B� ��ﲒi
> ��o�H�0 �"�� ���B,� $6QP�@ Y�05 �8�s�� �>���:> ���*� Kp1>�~<
> ����� x�5 05 S?�V�" �m�7 )����z$ �Ye��- �nKPz ~8�쩳 dF �̄5
> �ɼ��% v�x�O�# 9�B�/�6 �5��[. ��P%:� ���V�t `G'�O ��#bQ�9 �����)
> `�0%�[0 f�(? e( �`5 rt �O* �[�۠ �ɴKG� �'$�_s ��g:] Aߞ,�Q
This is the same data after using GDB:
> "\374G\371{SSF\301\251*>\177%\225\201\253i\b\344\206\341hgRQ\016\022\001;Tjh\002\000\000\000A\000\000\000\001\000\000\000\"ʐk\323R3\000\061[Z\272yA\001\000_\340\016K\004x\005\000O\226\f\262\a\375\020\000\346\302\341f\230\235'\000\026\275\367\371\215t\020\000%\356\033\372+>,\000\307\016\361\327~\223\033\000삾\351\254+/\000Tb\335Ҷ\363\067\000\342(\357\336\346\326\017\000\327Q1\320\065m&\000\034\216\377\035\005(\a\000\020G#\345bm\017\000\063O\324AN
> )\000\225DP߇g\a\000\355\060=ʆ\260\060\000\232\377\272j\234u\006\000E\304\063\372\355\v\f\000\223G\353\024#\307\"\000\\\317\327!\270o%\000\005L\035.\345\306\002\000\257WMG?B-\000\063\275\342\373\304}&\000\365\017.\367S\264\031\000(\236\033B\354\255\n\000\316\034j&\321\021\n\000\266@\226\314%&,\000\066\065\236\024\271\033\060\000!G\332\v5R\030\000\372\f\353N\225\201\060\000\331\377\035b\244\263\033\000h\361\205\267\207v)\000\322\027\070\246\212w\b\000x<\001\026n}\034\000Җp{\362F\t\000\370\352m\026ŵ8\000(\366\366ۡ:\017\000\364\026\210b=\235\"\000\251\214[)\262\342\022\000
> m\316fd\345\060\000[VAl\206\233\006\000\035\354o\021'9#\000\363\032\327\372\357\322\034\000|'\256\306K{\021\000B\266\330v\257\332+\000x\346\023\300\315\306!\000qO\016\005wz*\000T\236*\021\272H;\000\ba\006$\376\214\027\000\213\377\a\330\372\023\003\000\361,m\274\300\321\004\000DË\277\272T
> \000\357\231Ţ\355\270\067\000;:\263\303\070\246\022\000~\267\374\060\272\261\r\000\264>\374\021\027%7\000\065\034e\216\305:\006\000w|7ώJ\006\000\070\242\210\310\343\206\n\000\365\263\370\377\005X/\000v\335c\200h\035\062\000\063\225\363\244i\362\r\000o^\371\353\302\n\027\000\000\000\000\000\000\000\000\000\t\224A\207\331\374\024\000\254oG\352\364\177\060\000+\254\332\330Ȑ\"\000n\024\310\360\265?\b\000\004\234\231\006\250\064\016\000F#\225>b\020
> \000.\271\224m\246=;\000\305\t\017\372X\024\024\000\232\023\005\360\277<\017\000\036\242 c\005(=\000\211\200\212\067Y`:\000\273\206\017\n\204\233\027\000\002Q\364\376O\277\033\000w\212\033k\273q!\000\333D\204\241G\331\070\000O\242\306\346l\327\061\000j\224\205DH\033\032\000\270\025\375rhJ\n\000v͑UF\227
> \000\230P\272\211\247\005;\000\372\177\017\310\b|\032\000\367\357\255\352h\n\036\000\226U\230\255z\247*\000\060\000Ԏ\241\301\066\000\315\b@\024I\227\032\000\275\322,K\275\304\034\000\332R\375B\023\376\001\000\331\324ﲒi\r\000\256\353o\237H\205\060\000\353\"\026\025\360\320\n\000\203\306\344B,\200\006\000$6QP\325@\017\000YŽ\036\203\060\065\000\366\070\251s\264\252\017\000\360>\251\310\340:>\000\257\310\326\005*\216\036\000Kp1>\232~<\000\225\002\253\302\365\350\021\000x\341\065\000\060\065\021\000S?\331V\311\"\000\000\356m\307\003\030\067\004\000)\212\265\351\331z$\000\336Ye\217\323\033-\000\215nK\026Pz\v\000~8\273쩳\r\000dF\r\261̄5\000\206\aɼ\303\365%\000v\365x\304O\346#\000\071\210B\373/\264\066\000\324\065\216\003\274[.\000\363\343P%:\311\033\000\244\301\370V\367t\006\000`G\005'\213O\017\000\252\220#bQ\324\071\000\376\272\377\347\016\237)\000`\374\060%\311[0\000\177\rf\357\233(?\000e(\r\204`5\r\000rt\000\005\230O*\000\345[\204۠x\b\000\207ɴKG\224\v\000\273'$\261_s\036\000\215\240\fg:]\002\000Aߞ,\303Q\t\000\000\000\000\000\000\000\000"
I'm trying to upload this data to a PostgresSQL database encoded with `UTF8` and into the `byte_info` column excepting `bytea` using the [libpqxx][1] library:
pqxx::connection Con("My con information");
pqxx::work W(Con);
W.exec("UPDATE " + tableName + " SET byte_info =" + strs.str() + " WHERE id = 1;");
W.commit();
But all I get is this error:
> ERROR: invalid byte sequence for encoding "UTF8": 0xfc
What am I missing here or doing wrong?
[1]: http://pqxx.org/development/libpqxx/ | 0debug |
Whats the longest string i can save and get using firebase? : <p>Whats the max number of characters in a string I can save in firebase?
Is it unlimited?
At what point will It get too slow?</p>
| 0debug |
What does the number beside the icon represent? : <p>What does the number mean in read and why does it increment from 1 to 2? It looks similar to firebugs error count, but there are no errors here.</p>
<p><a href="https://i.stack.imgur.com/Ji3q0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Ji3q0.png" alt="enter image description here"></a></p>
| 0debug |
Remove multiple items from a Python list in just one statement : <p>In python, I know how to remove items from a list.</p>
<pre><code>item_list = ['item', 5, 'foo', 3.14, True]
item_list.remove('item')
item_list.remove(5)
</code></pre>
<p>This above code removes the values 5 and 'item' from item_list.
But when there is a lot of stuff to remove, I have to write many lines of </p>
<pre><code>item_list.remove("something_to_remove")
</code></pre>
<p>If I know the index of what I am removing, I use:</p>
<pre><code>del item_list[x]
</code></pre>
<p>where x is the index of the item I want to remove.</p>
<p>If I know the index of all of the numbers that I want to remove, I'll use some sort of loop to <code>del</code> the items at the indices. </p>
<p>But what if I don't know the indices of the items I want to remove?</p>
<p>I tried <code>item_list.remove('item', 'foo')</code>, but I got an error saying that <code>remove</code> only takes one argument. </p>
<p>Is there a way to remove multiple items from a list in a single statement?</p>
<p>P.S. I've used <code>del</code> and <code>remove</code>. Can someone explain the difference between these two, or are they the same?</p>
<p>Thanks</p>
| 0debug |
when i run this code it give error unexpected else please suggest mi how to write it : <p>when i run this code it give error unexpected else please suggest mi how to write it i am confused with open and close bracket</p>
<pre><code> <?php
}
for ($i = $start_loop; $i <= $end_loop; $i++)
{
//if ($cur_page == $i)
if($i != $page)?>
<a href="javascript:callonce_search( <?php echo $i?>,'<?php echo $txt?>')"> $i </a>
<?php
else
echo " <a class='paginationcurrnt'><b> $i</b>";
}
// TO ENABLE THE NEXT BUTTON
if ($next_btn && $cur_page < $no_of_paginations)
{
$nex = $cur_page + 1; ?>
</code></pre>
| 0debug |
static void draw_curves(AVFilterContext *ctx, AVFilterLink *inlink, AVFrame *out)
{
AudioNEqualizerContext *s = ctx->priv;
char *colors, *color, *saveptr = NULL;
int ch, i, n;
colors = av_strdup(s->colors);
if (!colors)
return;
memset(out->data[0], 0, s->h * out->linesize[0]);
for (ch = 0; ch < inlink->channels; ch++) {
uint8_t fg[4] = { 0xff, 0xff, 0xff, 0xff };
int prev_v = -1;
double f;
color = av_strtok(ch == 0 ? colors : NULL, " |", &saveptr);
if (color)
av_parse_color(fg, color, -1, ctx);
for (f = 0; f < s->w; f++) {
double complex z;
double complex H = 1;
double w;
int v, y, x;
w = M_PI * (s->fscale ? pow(s->w - 1, f / s->w) : f) / (s->w - 1);
z = 1. / cexp(I * w);
for (n = 0; n < s->nb_filters; n++) {
if (s->filters[n].channel != ch ||
s->filters[n].ignore)
continue;
for (i = 0; i < FILTER_ORDER / 2; i++) {
FoSection *S = &s->filters[n].section[i];
H *= (((((S->b4 * z + S->b3) * z + S->b2) * z + S->b1) * z + S->b0) /
((((S->a4 * z + S->a3) * z + S->a2) * z + S->a1) * z + S->a0));
}
}
v = av_clip((1. + -20 * log10(cabs(H)) / s->mag) * s->h / 2, 0, s->h - 1);
x = lrint(f);
if (prev_v == -1)
prev_v = v;
if (v <= prev_v) {
for (y = v; y <= prev_v; y++)
AV_WL32(out->data[0] + y * out->linesize[0] + x * 4, AV_RL32(fg));
} else {
for (y = prev_v; y <= v; y++)
AV_WL32(out->data[0] + y * out->linesize[0] + x * 4, AV_RL32(fg));
}
prev_v = v;
}
}
av_free(colors);
}
| 1threat |
static int mpegts_write_end(AVFormatContext *s)
{
MpegTSWrite *ts = s->priv_data;
MpegTSWriteStream *ts_st;
MpegTSService *service;
AVStream *st;
int i;
for(i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
ts_st = st->priv_data;
if (ts_st->payload_index > 0) {
mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index,
ts_st->payload_pts);
}
}
put_flush_packet(&s->pb);
for(i = 0; i < ts->nb_services; i++) {
service = ts->services[i];
av_freep(&service->provider_name);
av_freep(&service->name);
av_free(service);
}
av_free(ts->services);
for(i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
av_free(st->priv_data);
}
return 0;
}
| 1threat |
Debug Spring boot code from command prompt : <p>Can I debug spring boot code through Spring tool suite(STS), if I it is running from command prompt?</p>
<p>It will help me in fast development.</p>
| 0debug |
sPAPRDRConnector *spapr_dr_connector_new(Object *owner,
sPAPRDRConnectorType type,
uint32_t id)
{
sPAPRDRConnector *drc =
SPAPR_DR_CONNECTOR(object_new(TYPE_SPAPR_DR_CONNECTOR));
g_assert(type);
drc->type = type;
drc->id = id;
drc->owner = owner;
object_property_add_child(owner, "dr-connector[*]", OBJECT(drc), NULL);
object_property_set_bool(OBJECT(drc), true, "realized", NULL);
switch (drc->type) {
case SPAPR_DR_CONNECTOR_TYPE_CPU:
drc->name = g_strdup_printf("CPU %d", id);
break;
case SPAPR_DR_CONNECTOR_TYPE_PHB:
drc->name = g_strdup_printf("PHB %d", id);
break;
case SPAPR_DR_CONNECTOR_TYPE_VIO:
case SPAPR_DR_CONNECTOR_TYPE_PCI:
drc->name = g_strdup_printf("C%d", id);
break;
case SPAPR_DR_CONNECTOR_TYPE_LMB:
drc->name = g_strdup_printf("LMB %d", id);
break;
default:
g_assert(false);
}
if (drc->type == SPAPR_DR_CONNECTOR_TYPE_PCI) {
drc->allocation_state = SPAPR_DR_ALLOCATION_STATE_USABLE;
}
return drc;
}
| 1threat |
Docker: Could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network : <p>When I was trying to deploy my application with docker-compose I got back the following error:</p>
<pre><code>Creating network "<myapplicationnamehere_mycustomnetwork>" with the
default driver
could not find an available, non-overlapping IPv4 address pool among
the defaults to assign to the network
</code></pre>
<p>Now I researched a bit here and there and people suggested to prune unused old docker networks with <code>docker network prune</code>. But since I am running 34 docker containers (about ~30 networks I think), it only prunes one or two old networks before the error occurs again.</p>
<p><strong>My question is: How can I make sure I can run many services without running into docker network allocation problems. (Maybe create smaller subnets somehow?)</strong></p>
<p>My top-key network section of the docker-compose file looks as follows:</p>
<pre><code>#
# Networks section
# Networks:
# - public, represents the network between nginx and the public nginx-proxy (which should be already running)
# - uwsgi, represents the network between nginx and uwsgi
# - postgres, represents the network between uwsgi and postgres
#
networks:
uwsgi:
postgres:
public:
external:
name: nginx-proxy
</code></pre>
| 0debug |
static void pci_ehci_config(void)
{
qpci_io_writew(ehci1.dev, ehci1.base + 0x60, 1);
}
| 1threat |
static void gen_mfc0 (DisasContext *ctx, int reg, int sel)
{
const char *rn = "invalid";
switch (reg) {
case 0:
switch (sel) {
case 0:
gen_op_mfc0_index();
rn = "Index";
break;
case 1:
rn = "MVPControl";
case 2:
rn = "MVPConf0";
case 3:
rn = "MVPConf1";
default:
goto die;
}
break;
case 1:
switch (sel) {
case 0:
gen_op_mfc0_random();
rn = "Random";
break;
case 1:
rn = "VPEControl";
case 2:
rn = "VPEConf0";
case 3:
rn = "VPEConf1";
case 4:
rn = "YQMask";
case 5:
rn = "VPESchedule";
case 6:
rn = "VPEScheFBack";
case 7:
rn = "VPEOpt";
default:
goto die;
}
break;
case 2:
switch (sel) {
case 0:
gen_op_mfc0_entrylo0();
rn = "EntryLo0";
break;
case 1:
rn = "TCStatus";
case 2:
rn = "TCBind";
case 3:
rn = "TCRestart";
case 4:
rn = "TCHalt";
case 5:
rn = "TCContext";
case 6:
rn = "TCSchedule";
case 7:
rn = "TCScheFBack";
default:
goto die;
}
break;
case 3:
switch (sel) {
case 0:
gen_op_mfc0_entrylo1();
rn = "EntryLo1";
break;
default:
goto die;
}
break;
case 4:
switch (sel) {
case 0:
gen_op_mfc0_context();
rn = "Context";
break;
case 1:
rn = "ContextConfig";
default:
goto die;
}
break;
case 5:
switch (sel) {
case 0:
gen_op_mfc0_pagemask();
rn = "PageMask";
break;
case 1:
gen_op_mfc0_pagegrain();
rn = "PageGrain";
break;
default:
goto die;
}
break;
case 6:
switch (sel) {
case 0:
gen_op_mfc0_wired();
rn = "Wired";
break;
case 1:
rn = "SRSConf0";
case 2:
rn = "SRSConf1";
case 3:
rn = "SRSConf2";
case 4:
rn = "SRSConf3";
case 5:
rn = "SRSConf4";
default:
goto die;
}
break;
case 7:
switch (sel) {
case 0:
gen_op_mfc0_hwrena();
rn = "HWREna";
break;
default:
goto die;
}
break;
case 8:
switch (sel) {
case 0:
gen_op_mfc0_badvaddr();
rn = "BadVaddr";
break;
default:
goto die;
}
break;
case 9:
switch (sel) {
case 0:
gen_op_mfc0_count();
rn = "Count";
break;
default:
goto die;
}
break;
case 10:
switch (sel) {
case 0:
gen_op_mfc0_entryhi();
rn = "EntryHi";
break;
default:
goto die;
}
break;
case 11:
switch (sel) {
case 0:
gen_op_mfc0_compare();
rn = "Compare";
break;
default:
goto die;
}
break;
case 12:
switch (sel) {
case 0:
gen_op_mfc0_status();
rn = "Status";
break;
case 1:
gen_op_mfc0_intctl();
rn = "IntCtl";
break;
case 2:
gen_op_mfc0_srsctl();
rn = "SRSCtl";
break;
case 3:
gen_op_mfc0_srsmap();
rn = "SRSMap";
break;
default:
goto die;
}
break;
case 13:
switch (sel) {
case 0:
gen_op_mfc0_cause();
rn = "Cause";
break;
default:
goto die;
}
break;
case 14:
switch (sel) {
case 0:
gen_op_mfc0_epc();
rn = "EPC";
break;
default:
goto die;
}
break;
case 15:
switch (sel) {
case 0:
gen_op_mfc0_prid();
rn = "PRid";
break;
case 1:
gen_op_mfc0_ebase();
rn = "EBase";
break;
default:
goto die;
}
break;
case 16:
switch (sel) {
case 0:
gen_op_mfc0_config0();
rn = "Config";
break;
case 1:
gen_op_mfc0_config1();
rn = "Config1";
break;
case 2:
gen_op_mfc0_config2();
rn = "Config2";
break;
case 3:
gen_op_mfc0_config3();
rn = "Config3";
break;
case 6:
gen_op_mfc0_config6();
rn = "Config6";
break;
case 7:
gen_op_mfc0_config7();
rn = "Config7";
break;
default:
goto die;
}
break;
case 17:
switch (sel) {
case 0:
gen_op_mfc0_lladdr();
rn = "LLAddr";
break;
default:
goto die;
}
break;
case 18:
switch (sel) {
case 0 ... 7:
gen_op_mfc0_watchlo(sel);
rn = "WatchLo";
break;
default:
goto die;
}
break;
case 19:
switch (sel) {
case 0 ...7:
gen_op_mfc0_watchhi(sel);
rn = "WatchHi";
break;
default:
goto die;
}
break;
case 20:
switch (sel) {
case 0:
#ifdef TARGET_MIPS64
gen_op_mfc0_xcontext();
rn = "XContext";
break;
#endif
default:
goto die;
}
break;
case 21:
switch (sel) {
case 0:
gen_op_mfc0_framemask();
rn = "Framemask";
break;
default:
goto die;
}
break;
case 22:
rn = "'Diagnostic";
break;
case 23:
switch (sel) {
case 0:
gen_op_mfc0_debug();
rn = "Debug";
break;
case 1:
rn = "TraceControl";
case 2:
rn = "TraceControl2";
case 3:
rn = "UserTraceData";
case 4:
rn = "TraceBPC";
default:
goto die;
}
break;
case 24:
switch (sel) {
case 0:
gen_op_mfc0_depc();
rn = "DEPC";
break;
default:
goto die;
}
break;
case 25:
switch (sel) {
case 0:
gen_op_mfc0_performance0();
rn = "Performance0";
break;
case 1:
rn = "Performance1";
case 2:
rn = "Performance2";
case 3:
rn = "Performance3";
case 4:
rn = "Performance4";
case 5:
rn = "Performance5";
case 6:
rn = "Performance6";
case 7:
rn = "Performance7";
default:
goto die;
}
break;
case 26:
rn = "ECC";
break;
case 27:
switch (sel) {
case 0 ... 3:
rn = "CacheErr";
break;
default:
goto die;
}
break;
case 28:
switch (sel) {
case 0:
case 2:
case 4:
case 6:
gen_op_mfc0_taglo();
rn = "TagLo";
break;
case 1:
case 3:
case 5:
case 7:
gen_op_mfc0_datalo();
rn = "DataLo";
break;
default:
goto die;
}
break;
case 29:
switch (sel) {
case 0:
case 2:
case 4:
case 6:
gen_op_mfc0_taghi();
rn = "TagHi";
break;
case 1:
case 3:
case 5:
case 7:
gen_op_mfc0_datahi();
rn = "DataHi";
break;
default:
goto die;
}
break;
case 30:
switch (sel) {
case 0:
gen_op_mfc0_errorepc();
rn = "ErrorEPC";
break;
default:
goto die;
}
break;
case 31:
switch (sel) {
case 0:
gen_op_mfc0_desave();
rn = "DESAVE";
break;
default:
goto die;
}
break;
default:
goto die;
}
#if defined MIPS_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "mfc0 %s (reg %d sel %d)\n",
rn, reg, sel);
}
#endif
return;
die:
#if defined MIPS_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "mfc0 %s (reg %d sel %d)\n",
rn, reg, sel);
}
#endif
generate_exception(ctx, EXCP_RI);
}
| 1threat |
C# MessageBoxButtons.YesNo : I've got this problem, if I click the "No" button at MessageBoxButton.YesNo the data that is being typed is still inserting in the database. How should I fix this?
This is my codes:
string insertQuery = "INSERT INTO db_personal(per_image,per_Fname,per_Mname,per_Lname)VALUES(@per_image,@per_Fname,@per_Mname,@per_Lname)";
connection.Open();
MySqlCommand cmd = new MySqlCommand(insertQuery, connection);
cmd.Parameters.AddWithValue("@per_image", newPicture.Image);
cmd.Parameters.AddWithValue("@per_Fname", newFirstName.Text);
cmd.Parameters.AddWithValue("@per_Mname", newMiddleName.Text);
cmd.Parameters.AddWithValue("@per_Lname", newLastName.Text);
try
{
if (cmd.ExecuteNonQuery() == 1)
{
MetroFramework.MetroMessageBox.Show(this, "New student information has been successfully saved.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MetroFramework.MetroMessageBox.Show(this, "Incomplete information. Are you sure you want to save?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
connection.Close();
Your help would highly be appreciated. Thank you. | 0debug |
static int loco_decode_plane(LOCOContext *l, uint8_t *data, int width, int height,
int stride, const uint8_t *buf, int buf_size, int step)
{
RICEContext rc;
int val;
int i, j;
if(buf_size<=0)
return -1;
init_get_bits8(&rc.gb, buf, buf_size);
rc.save = 0;
rc.run = 0;
rc.run2 = 0;
rc.lossy = l->lossy;
rc.sum = 8;
rc.count = 1;
val = loco_get_rice(&rc);
data[0] = 128 + val;
for (i = 1; i < width; i++) {
val = loco_get_rice(&rc);
data[i * step] = data[i * step - step] + val;
}
data += stride;
for (j = 1; j < height; j++) {
val = loco_get_rice(&rc);
data[0] = data[-stride] + val;
for (i = 1; i < width; i++) {
val = loco_get_rice(&rc);
data[i * step] = loco_predict(&data[i * step], stride, step) + val;
}
data += stride;
}
return (get_bits_count(&rc.gb) + 7) >> 3;
}
| 1threat |
How to install libx265 for ffmpeg on Mac OSX : <p>I have tried multiple guides <a href="https://hexeract.wordpress.com/2009/04/12/how-to-compile-ffmpegmplayer-for-macosx/" rel="noreferrer">here</a> (search for "Building libx265") and <a href="http://sinclairmediatech.com/building-ffmpeg-with-libx265/" rel="noreferrer">here</a> with no success. Both times I made sure I uninstalled ffmpeg first, went through the guides, then ran</p>
<p><code>brew install ffmpeg --with-fdk-aac --with-freetype --with-libass --with-libvpx --enable-libx265</code></p>
<p>No matter what when I go to run a command like</p>
<p><code>ffmpeg -i source.mkv -c:v libx265 test1.mkv</code></p>
<p>I get the error:</p>
<p><code>Unknown encoder 'libx265'</code></p>
<p>Has anyone had success building libx265 for use with ffmpeg on OSX and can you please share how you did it?</p>
<p>P.S. I am running OSX 10.11.3</p>
| 0debug |
How to handle multiple routers in react : <p>Let say we have a web application. It has usually many views, like index page, admin panel, help page, contact etc. I handle them using react-router-dom in the main index.js and it just works fine.</p>
<p>However now I faced problem with developing admin panel. It is one of the routes supported by the index.js router, but it contains its own menu with all actions available for admin.</p>
<p>How should I handle this, to only replace the content I need in the admin panel (admin actions menu stays), but not the whole content as I do from index.js router?</p>
<p>I tried to use the in the admin panel place for content replacement, but it either says too much recursion (If I duplicated the route for admin panel itself) or simply does not work saying nothing.</p>
<p>I'm react newbie and I don't even know how to call this problem.</p>
<p>Thanks for suggestions.</p>
| 0debug |
static int coroutine_fn copy_sectors(BlockDriverState *bs,
uint64_t start_sect,
uint64_t cluster_offset,
int n_start, int n_end)
{
BDRVQcowState *s = bs->opaque;
QEMUIOVector qiov;
struct iovec iov;
int n, ret;
if (start_sect + n_end > bs->total_sectors) {
n_end = bs->total_sectors - start_sect;
n = n_end - n_start;
if (n <= 0) {
return 0;
iov.iov_len = n * BDRV_SECTOR_SIZE;
iov.iov_base = qemu_blockalign(bs, iov.iov_len);
qemu_iovec_init_external(&qiov, &iov, 1);
BLKDBG_EVENT(bs->file, BLKDBG_COW_READ);
ret = bs->drv->bdrv_co_readv(bs, start_sect + n_start, n, &qiov);
if (ret < 0) {
goto out;
if (s->crypt_method) {
qcow2_encrypt_sectors(s, start_sect + n_start,
iov.iov_base, iov.iov_base, n, 1,
&s->aes_encrypt_key);
ret = qcow2_pre_write_overlap_check(bs, 0,
cluster_offset + n_start * BDRV_SECTOR_SIZE, n * BDRV_SECTOR_SIZE);
if (ret < 0) {
goto out;
BLKDBG_EVENT(bs->file, BLKDBG_COW_WRITE);
ret = bdrv_co_writev(bs->file, (cluster_offset >> 9) + n_start, n, &qiov);
if (ret < 0) {
goto out;
ret = 0;
out:
qemu_vfree(iov.iov_base);
return ret; | 1threat |
static void spapr_pci_pre_save(void *opaque)
{
sPAPRPHBState *sphb = opaque;
GHashTableIter iter;
gpointer key, value;
int i;
g_free(sphb->msi_devs);
sphb->msi_devs = NULL;
sphb->msi_devs_num = g_hash_table_size(sphb->msi);
if (!sphb->msi_devs_num) {
return;
}
sphb->msi_devs = g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_mig));
g_hash_table_iter_init(&iter, sphb->msi);
for (i = 0; g_hash_table_iter_next(&iter, &key, &value); ++i) {
sphb->msi_devs[i].key = *(uint32_t *) key;
sphb->msi_devs[i].value = *(spapr_pci_msi *) value;
}
if (sphb->pre_2_8_migration) {
sphb->mig_liobn = sphb->dma_liobn[0];
sphb->mig_mem_win_addr = sphb->mem_win_addr;
sphb->mig_mem_win_size = sphb->mem_win_size;
sphb->mig_io_win_addr = sphb->io_win_addr;
sphb->mig_io_win_size = sphb->io_win_size;
if ((sphb->mem64_win_size != 0)
&& (sphb->mem64_win_addr
== (sphb->mem_win_addr + sphb->mem_win_size))) {
sphb->mig_mem_win_size += sphb->mem64_win_size;
}
}
}
| 1threat |
void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data,
BIOSLinker *linker, GArray *dsm_dma_arrea,
uint32_t ram_slots)
{
GSList *device_list;
device_list = nvdimm_get_plugged_device_list();
if (device_list) {
nvdimm_build_nfit(device_list, table_offsets, table_data, linker);
g_slist_free(device_list);
}
if (ram_slots) {
nvdimm_build_ssdt(table_offsets, table_data, linker, dsm_dma_arrea,
ram_slots);
}
}
| 1threat |
Strange Numerical Behaviour of gcc Linker : <p>I have a problem with as simple a C code as the following:</p>
<pre><code>#include <math.h>
#include <stdio.h>
int main () {
printf ("%f\n", exp(1));
}
</code></pre>
<p>Replacing <code>1</code> with numbers smaller than <code>710</code> results in a successful compilation with the expected effect, but for numbers higher than that , I get a linker error, of all things:</p>
<pre><code>/tmp/ccqVnsno.o: In function `main':
test.c:(.text+0x1c): undefined reference to `exp'
collect2: error: ld returned 1 exit status
</code></pre>
<p>I have tested this for numbers under 1000 with the following bash script:</p>
<pre><code>for i in {0..1000}; do
sed -i -r "s:[0-9]+:${i}:" test.c
gcc -o test test.c
./test
done
</code></pre>
<p>Putting the <code>printf</code> statements in a for loop with <code>exp</code> of the index variable results in the same linkage error, regardless of upper bound.</p>
<p>What's going on here? Is the compiler recognizing 710 as some sort of limit for <code>long double</code>? Then why is the linker catching the error? Sorry for credulity, I'm new to C.</p>
| 0debug |
Cant pull data from another worksheet such that it comes in next row if i make a loop for each new oworksheet : Below is the macro which is being called from another macro.
I need to open a dialog box and select a workbook. Then it will copy the data placed in that workbook(which has only 1 sheet with same name all the time).
I want to do the same process for many workbooks by using loop for vbyesno.
But this is the only part which is not working because I want it to paste data under Range("a14"), then loop and then under the data pasted in a14.
Please help using the same methods.
> Sub prompt()
>
> Application.DisplayAlerts = False
> Dim Target_Workbook As Workbook
> Dim Source_Workbook As Workbook
> Dim Target_Path As Range
> d = MsgBox("Add record?", vbYesNoCancel + vbInformation) If d = vbNo Then
> ActiveSheet.Range("a13").Value = "No data Found"
> ActiveSheet.Range("a13").Font.Bold = True
> ThisWorkbook.Save ElseIf d = vbCancel Then
> Sheets("MPSA").Delete
> ThisWorkbook.Save ElseIf d = vbYes Then
>
> Sheets("MPSA").Range("a14").Value = "NAME"
> Sheets("MPSA").Range("b14").Value = "NUMBER"
> Sheets("MPSA").Range("c14").Value = "AGR NUMBER"
> Sheets("MPSA").Range("d14").Value = "ENTITY NAME"
> Sheets("MPSA").Range("e14").Value = "GROUP"
> Sheets("MPSA").Range("f14").Value = "DELIVERABLE"
> Sheets("MPSA").Range("g14").Value = "DELIVERAB"
> Sheets("MPSA").Range("h14").Value = "IS COMPON"
> Sheets("MPSA").Range("i14").Value = "PACKAGE"
> Sheets("MPSA").Range("j14").Value = "ORDERS"
> Sheets("MPSA").Range("k14").Value = "LICNTITY"
> Sheets("MPSA").Range("l14").Value = "QUANTITY"
> Sheets("MPSA").Range("m14").Value = "ORDERANUMBER"
> Sheets("MPSA").Range("n14").Value = "ORDERAM NAME"
> Sheets("MPSA").Range("o14").Value = "PAC NUMBER"
> Sheets("MPSA").Range("p14").Value = "PACKAGAME"
> Sheets("MPSA").Range("q14").Value = "ITTION"
> Sheets("MPSA").Range("r14").Value = "LICENSE TYPE"
> Sheets("MPSA").Range("s14").Value = "ITEM VERSION"
> Sheets("MPSA").Range("t14").Value = "REAGE"
> Sheets("MPSA").Range("u14").Value = "CLIIT"
> Sheets("MPSA").Range("v14").Value = "LICEAME"
> Sheets("MPSA").Range("w14").Value = "ASSATE"
> Sheets("MPSA").Range("x14").Value = "ASSTE"
> Sheets("MPSA").Range("y14").Value = "ENTITTUS"
> Sheets("MPSA").Range("z14").Value = "ASSGORY"
> Sheets("MPSA").Range("aa14").Value = "PURCHAYPE"
> Sheets("MPSA").Range("ab14").Value = "BILLTHOD"
> Sheets("MPSA").Range("ac14").Value = "SALETER"
> Cells.Columns.AutoFit
>
> Target_Path = Application.GetOpenFilename
>
> Set Target_Workbook = Workbooks.Open(Target_Path)
> Set Source_Workbook = ThisWorkbook
>
> Target_Data = Target_Workbook.Sheets(1).Range("A1").CurrentRegion.Copy
> Target_Workbook.Close
> Source_Workbook.Sheets("MPSA").Range("a14").End(xlDown).Offset(1, 0).PasteSpecial = Target_Data
> ActiveCell.EntireRow.Delete
> ThisWorkbook.Save
>
> ThisWorkbook.Save
>
> End If
>
> End Sub | 0debug |
import PDF file and insert some values to particular place in PHP : <p>i have design a template blank PDF file and i get some data witch is generated by using PHP mysql retrieved data i need to merge them into one PDF file and to take print.</p>
<p>Witch PDF plugin is good for generate PDF ?.</p>
| 0debug |
Trying to prevent duplicate values to be added to an array. : <p>Having an issue with my project when it comes to adding a duplicate value to an array on a click event.</p>
<p>when I push the clicked item's value to the array <code>openedCards.push(card);</code> the code allows for multiple item values to be added to the array thus creating a matched value with a single item. </p>
<p>I have tried wrapping this code like so <code>if ($.inArray(card, openedCards) < 0)openedCards.push(card);</code> i see that the match class is no longer being added to matching pairs, or any values for that matter. </p>
<p>here is the <a href="http://jsfiddle.net/logikevcover/8auxLwtm/3/" rel="noreferrer">Here is the jsfiddle</a></p>
| 0debug |
static void scsi_block_class_initfn(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(klass);
sc->realize = scsi_block_realize;
sc->unrealize = scsi_unrealize;
sc->alloc_req = scsi_block_new_request;
sc->parse_cdb = scsi_block_parse_cdb;
dc->fw_name = "disk";
dc->desc = "SCSI block device passthrough";
dc->reset = scsi_disk_reset;
dc->props = scsi_block_properties;
dc->vmsd = &vmstate_scsi_disk_state;
}
| 1threat |
static void scsi_read_complete(void * opaque, int ret)
{
SCSIGenericReq *r = (SCSIGenericReq *)opaque;
SCSIDevice *s = r->req.dev;
int len;
r->req.aiocb = NULL;
if (ret || r->req.io_canceled) {
scsi_command_complete(r, ret);
return;
}
len = r->io_header.dxfer_len - r->io_header.resid;
DPRINTF("Data ready tag=0x%x len=%d\n", r->req.tag, len);
r->len = -1;
if (len == 0) {
scsi_command_complete(r, 0);
} else {
if (r->req.cmd.buf[0] == READ_CAPACITY_10 &&
(ldl_be_p(&r->buf[0]) != 0xffffffffU || s->max_lba == 0)) {
s->blocksize = ldl_be_p(&r->buf[4]);
s->max_lba = ldl_be_p(&r->buf[0]) & 0xffffffffULL;
} else if (r->req.cmd.buf[0] == SERVICE_ACTION_IN_16 &&
(r->req.cmd.buf[1] & 31) == SAI_READ_CAPACITY_16) {
s->blocksize = ldl_be_p(&r->buf[8]);
s->max_lba = ldq_be_p(&r->buf[0]);
}
bdrv_set_guest_block_size(s->conf.bs, s->blocksize);
scsi_req_data(&r->req, len);
scsi_req_unref(&r->req);
}
}
| 1threat |
order in stl queue container : <p>I'm trying to make a queue of a class that uses a template, but when I try to use the functions front or back I get an error saying that the operator "<<" doesn't match the function. But if I use the function size, for example, it works fine. So, I was wondering that maybe it is because of the order in objects in the queue? I already tried to overload the << operator but didn't work. Thanks for any help.
Here's my code:</p>
<pre><code>//STL queue container
queue<stackType<int>> stack5;
stack5.push(5);
stack5.push(8);
stack5.push(6);
cout << "The front element of stack5 is: " << stack5.front() << endl;
</code></pre>
| 0debug |
How can a activate debugage USB in my phone : I found a problem with debugage USB in my phone LG V10, that option not accecible to activate ; i am serching for a solution [enter image description here][1]
[1]: https://i.stack.imgur.com/3GnBn.png | 0debug |
How to properly set line height for Android? : <p>I am a UX architect working with a team of Android developers that are mostly junior. We are having issues properly setting line height in Android. </p>
<p>We are using the Material Design spec as our guide for our app. In particular, you can see line height specs here:</p>
<p><a href="https://material.google.com/style/typography.html#typography-line-height" rel="noreferrer">https://material.google.com/style/typography.html#typography-line-height</a></p>
<p>Let's use Body 2 as our example. The spec says the type is 13sp or 14sp, and the leading (line height - same thing) should be 24dp. </p>
<p>Here's the problem: these devs are telling me there is no such way to set line height like that in the code. Instead, they are telling me to measure the distance between the two lines of text and give them that measure - let's say it's 4dp. They want this for each style of text we are using. </p>
<p>We are using a Sketch > Zepelin flow for spec. </p>
<p>It seems odd to me to be able to create a font style (which could easily be class/style in the code) that is 13sp with 24dp leading, and not be able to set the leading, but instead have to add a 3rd measure to the mix. There is no place in Sketch or Zepelin for such a measure "between lines."</p>
<p>Is this really the way it is done, or is there a proper way to set line height? </p>
| 0debug |
static inline int tcg_temp_new_internal(TCGType type, int temp_local)
{
TCGContext *s = &tcg_ctx;
TCGTemp *ts;
int idx, k;
k = type + (temp_local ? TCG_TYPE_COUNT : 0);
idx = find_first_bit(s->free_temps[k].l, TCG_MAX_TEMPS);
if (idx < TCG_MAX_TEMPS) {
clear_bit(idx, s->free_temps[k].l);
ts = &s->temps[idx];
ts->temp_allocated = 1;
assert(ts->base_type == type);
assert(ts->temp_local == temp_local);
} else {
idx = s->nb_temps;
#if TCG_TARGET_REG_BITS == 32
if (type == TCG_TYPE_I64) {
tcg_temp_alloc(s, s->nb_temps + 2);
ts = &s->temps[s->nb_temps];
ts->base_type = type;
ts->type = TCG_TYPE_I32;
ts->temp_allocated = 1;
ts->temp_local = temp_local;
ts->name = NULL;
ts++;
ts->base_type = TCG_TYPE_I32;
ts->type = TCG_TYPE_I32;
ts->temp_allocated = 1;
ts->temp_local = temp_local;
ts->name = NULL;
s->nb_temps += 2;
} else
#endif
{
tcg_temp_alloc(s, s->nb_temps + 1);
ts = &s->temps[s->nb_temps];
ts->base_type = type;
ts->type = type;
ts->temp_allocated = 1;
ts->temp_local = temp_local;
ts->name = NULL;
s->nb_temps++;
}
}
#if defined(CONFIG_DEBUG_TCG)
s->temps_in_use++;
#endif
return idx;
}
| 1threat |
Ruby on rails: unexpected end-of-input, expecting keyword_end : <p>i have a problem like the subject in the controller. I've got error of expecting end of function. But as you can see I've got every end of the function. I'm a beginner in RoR.</p>
<pre><code>class UsersController < ApplicationController
before_filter :authenticate_user!
def show
@user = User.find(params[:id])
@user_catalogs = @user.catalogs
@hash = Gmaps4rails.build_markers(@user.locations) do |location, marker|
marker.lat location.latitude
marker.lng location.longitude
marker.infowindow location.address
end
def index
@users = User.where.not("id = ?",current_user.id).order("created_at DESC")
@conversations = Conversation.involving(current_user).order("created_at DESC")
end
end
</code></pre>
| 0debug |
Data from PHP form is not posting to mySQL : <p>I am a novice with coding, so I am unsure why I am not getting data to store in mySQL after submitting a form. I started with a code generator, but it just ins't working. Thanks for any help. Here is my code:</p>
<p>Form:</p>
<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><html>
<body>
<form id="FormName" action="added.php" method="post" name="FormName">
<table width="448" border="0" cellspacing="2" cellpadding="0">
<tr><td width = "150"><div align="right"><label for="name">Name of Farm </label></div></td>
<td><input id="name" name="name" type="text" size="25" value="" maxlength="255"></td></tr><tr><td width = "150"><div align="right"><label for="owners">Name of Owners</label></div></td>
<td><input id="owners" name="owners" type="text" size="25" value="" maxlength="255"></td></tr><tr><td width = "150"><div align="right"><label for="location">Location (city,state)</label></div></td>
<td><input id="location" name="location" type="text" size="25" value="" maxlength="255"></td></tr><tr><td width = "150"><div align="right"><label for="phone">Phone</label></div></td>
<td><input id="phone" name="phone" type="text" size="25" value="" maxlength="10"></td></tr><tr><td width = "150"><div align="right"><label for="email">Email</label></div></td>
<td><input id="email" name="email" type="text" size="25" value="" maxlength="255"></td></tr><tr><td width = "150"><div align="right"><label for="website">Website</label></div></td>
<td><input id="website" name="website" type="text" size="25" value="" maxlength="255"></td></tr><tr><td width = "150"><div align="right"><label for="description">Description</label></div></td>
<td><textarea id="description" name="description" rows="4" cols="40"></textarea></td></tr><tr><td width = "150"><div align="right"><label for="dateadded">Today's Date</label></div></td>
<td><input id="dateadded" name="dateadded" type="text" size="25" value="" maxlength="255"></td></tr><tr><td width = "150"><div align="right"><label for="logo">Logo</label></div></td>
<td><input id="logo" name="logo" type="text" size="25" value="" maxlength="255"></td></tr><tr><td width = "150"><div align="right"><label for="state">State</label></div></td>
<td><input id="state" name="state" type="text" size="25" value="" maxlength="2"></td></tr><tr><td width="150"></td><td>
<input type="submit" name="submitButtonName" value="Add"></td>
</tr></table></form>
</body>
</html>
PHP is in 2 files - one with db connection instructions and the other to post the data in the mySQL.
**Code to Connect to mySQL:**
<?php
$hostname='localhost'; //// specify host, i.e. 'localhost'
$user='llamabre_visitor'; //// specify username
$pass='llama'; //// specify password
$dbase='llamabre_farms1'; //// specify database name
$connection = mysql_connect("$hostname" , "$user" , "$pass")
or die ("Can't connect to MySQL");
$db = mysql_select_db($dbase , $connection) or die ("Can't select database.");
?>
<a href="index.php">Back to List</a>
**Code for posting to mySQL:**
<?php
include("connect.php");
$name = trim($_POST['name']);
$owners = trim($_POST['owners']);
$location = trim($_POST['location']);
$phone = trim($_POST['phone']);
$email = trim($_POST['email']);
$website = trim($_POST['website']);
$description = trim($_POST['description']);
$dateadded = trim($_POST['dateadded']);
$logo = trim($_POST['logo']);
$state = trim($_POST['state']);
$query = "INSERT INTO farmsdir (id, name, owners, location, phone, email, website, description, dateadded, logo, state)
VALUES ('', '$name', '$owners', '$location', '$phone', '$email', '$website', '$description', '$dateadded', '$logo', '$state')";
$results = mysql_query($query);
if ($results)
{
echo "Details added.";
}
mysql_close();
?></code></pre>
</div>
</div>
</p>
| 0debug |
void vnc_zlib_zfree(void *x, void *addr)
{
qemu_free(addr);
}
| 1threat |
what are the Best practice to store or monitor UI logs? : <p>what are the best practices to store the ui logs/error statements of all the clients in the server side,
so that we can analyse this later</p>
| 0debug |
how to add two id's for jquery function : <p><a href="http://jsfiddle.net/o1hdh8rw/7/" rel="nofollow noreferrer">JSfiddle.</a></p>
<p>Here I am restricting zero at first position and I restricted that for a single field using it's id. Now I want to restrict the same for two fields. How can I achieve that functionality in a single function.</p>
<pre><code>$('input#abc#xyz').keypress(function(e){
if (this.value.length == 0 && e.which == 48 ){
return false;
}
});
</code></pre>
| 0debug |
static inline int mirror_clip_sectors(MirrorBlockJob *s,
int64_t sector_num,
int nb_sectors)
{
return MIN(nb_sectors,
s->bdev_length / BDRV_SECTOR_SIZE - sector_num);
}
| 1threat |
Creating publication-quality geometric figures in Python : <p>I am a mathematician. Recently, I became the editor of the puzzles and problems column for a well-known magazine. Occasionally, I need to create a figure to accompany a problem or solution. These figures mostly relate to 2D (occasionally, 3D) euclidean geometry (lines, polygons, circles, plus the occasional ellipse or other conic section). The goal is obtaining figures of very high quality (press-ready), with Computer Modern ("TeX") textual labels. My hope is finding (or perhaps helping write!) a relatively high-level Python library that "knows" euclidean geometry in the sense that natural operations (e.g., drawing a perpendicular line to a given one passing through a given point, bisecting a given angle, or reflecting a figure A on a line L to obtain a new figure A') are already defined in the library. Of course, the ability to create figures after their elements are defined is a crucial goal (e.g., as Encapsulated Postscript).</p>
<p>I know multiple sub-optimal solutions to this problem (some partial), but I don't know of any that is both simple and flexible. Let me explain:</p>
<ul>
<li><a href="http://asymptote.sourceforge.net/" rel="noreferrer">Asymptote</a> (similar to/based on <a href="https://www.tug.org/metapost.html" rel="noreferrer">Metapost</a>) allows creating extremely high-quality figures of great complexity, but knows almost nothing about geometric constructions (it is a rather low-level language) and thus any nontrivial construction requires quite a long script.</li>
<li><a href="http://www.texample.net/tikz/" rel="noreferrer">TikZ</a> with package <a href="https://www.ctan.org/pkg/tkz-euclide" rel="noreferrer">tkz-euclide</a> is high-level, flexible and also generates quality figures, but its syntax is so heavy that I just cry for Python's simplicity in comparison. (Some programs actually export to TikZ---see below.)</li>
<li>Dynamic Geometry programs, of which I'm most familiar with <a href="http://www.geogebra.org/" rel="noreferrer">Geogebra</a>, often have figure-exporting features (EPS, TikZ, etc.), but are meant to be used interactively. Sometimes, what one needs is a figure based on hard specs (e.g., exact side lengths)---defining objects in a script is ultimately more flexible (if correspondingly less convenient).</li>
<li>Two programs, <a href="http://www.eukleides.org/" rel="noreferrer">Eukleides</a> and <a href="http://poincare.matf.bg.ac.rs/~janicic//gclc/" rel="noreferrer">GCLC</a>, are closest to what I'm looking for: They generate figures (EPS format; GCLC also exports to TikZ). Eukleides has the prettiest, simplest syntax of all the options (see the <a href="http://www.eukleides.org/samples.html" rel="noreferrer">examples</a>), but it happens to be written in C (with source available, though I'm not sure about the license), rather limited/non-customizable, and no longer maintained. GCLC is still maintained but it is closed-source, its syntax is significantly worse than Eukleides's, and has certain other unnatural quirks. Besides, it is not available for Mac OS (my laptop is a Mac).</li>
</ul>
<p>Python has:</p>
<ul>
<li><a href="http://matplotlib.org/" rel="noreferrer">Matplotlib</a>, which produces extremely high-quality figures (particularly of functions or numerical data), but does not seem to know about geometric constructions, and</li>
<li><a href="http://www.sympy.org" rel="noreferrer">Sympy</a> has a geometry module which <em>does</em> know about geometric objects and constructions, all accessible in delightful Python syntax, but seems to have no figure-exporting (or even displaying?) capabilities.</li>
</ul>
<p>Finally, a question: Is there a library, something like "Figures for Sympy/geometry", that uses Python syntax to describe geometric objects and constructions, allowing to generate high-quality figures (primarily for printing, say EPS)?</p>
<p>If a library with such functionality does not exist, I would consider helping to write one (perhaps an extension to Sympy?). I will appreciate pointers.</p>
| 0debug |
Putting IP in web browser works, but putting IP in Google Domians doesn’t work? : I have my website (www.znepb.me) pointing to 98.29.128.167, but when I go to www.znepb.me, nothing comes up, but if I go to 98.29.128.167, it works perfectly. Any help is appreciated! | 0debug |
static CharDriverState *qemu_chr_open_udp_fd(int fd)
{
CharDriverState *chr = NULL;
NetCharDriver *s = NULL;
chr = qemu_chr_alloc();
s = g_malloc0(sizeof(NetCharDriver));
s->fd = fd;
s->chan = io_channel_from_socket(s->fd);
s->bufcnt = 0;
s->bufptr = 0;
chr->opaque = s;
chr->chr_write = udp_chr_write;
chr->chr_update_read_handler = udp_chr_update_read_handler;
chr->chr_close = udp_chr_close;
chr->explicit_be_open = true;
return chr;
}
| 1threat |
Is it possible to append spaces and a certain amount of spaces to a string? : <p>Here is my current code. The question is exactly in the title. (I'm looking to be able to align my triangle correctly) </p>
<pre><code>def Triangle(height):
if height % 2 == 0:
print "Please enter a height that is odd"
else:
stringTriangle = "x"
for x in range(height):
print stringTriangle
for x in range(1):
stringTriangle+="xx"
</code></pre>
| 0debug |
Change the number and variety of data fields without altering methods? : <p>I'm including my Java assignment below. I'm a bit puzzled by the instructions. I am supposed to use a new data field. The class is supposed to only have one data field. I am not, however, supposed to alter the methods. I don't really have any idea how to do this and make it work without altering the methods.</p>
<blockquote>
<p>Modify the Time2 class (below) to implement the time as the number of seconds since midnight. The class should have one data field (an int with the number of seconds since midnight) instead of three. This change should not affect the arguments, behavior, or output of the public methods.</p>
</blockquote>
<pre><code>public class Time2 {
private int hour; // 0 - 23
private int minute; // 0 - 59
private int second; // 0 - 59
public Time2() {this(0, 0, 0);}
public Time2(int hour) {this(hour, 0, 0);}
public Time2(int hour, int minute) {this(hour, minute, 0);}
// Time2 constructor: hour, minute and second supplied
public Time2(int hour, int minute, int second) {
if(hour<0||hour>=24)
throw new IllegalArgumentException("hour must be 0-23");
if (minute < 0 || minute >= 60)
throw new IllegalArgumentException("minute must be 0-59");
if (second < 0 || second >= 60)
throw new IllegalArgumentException("second must be 0-59");
this.hour = hour;
this.minute = minute;
this.second = second;
}
public Time2(Time2 time) {this(time.getHour(), time.getMinute(), time.getSecond());}
// Set Methods
// set a new time value using universal time;
// validate the data
public void setTime(int hour, int minute, int second) {
if (hour<0||hour>=24)
throw new IllegalArgumentException("hour must be 0-23");
if (minute < 0 || minute >= 60)
throw new IllegalArgumentException("minute must be 0-59");
if (second < 0 || second >= 60)
throw new IllegalArgumentException("second must be 0-59");
this.hour = hour;
this.minute = minute;
this.second = second;
}
public void setHour(int hour) {
if (hour < 0 || hour >= 24)
throw new IllegalArgumentException("hour must be 0-23");
this.hour = hour;
}
public void setMinute(int minute) {
if (minute < 0 && minute >= 60)
throw new IllegalArgumentException("minute must be 0-59");
this.minute = minute;
}
public void setSecond(int second) {
if (second <= 0 || second > 60)
throw new IllegalArgumentException("second must be 0-59");
this.second = second;
}
public int getHour() {return hour;}
public int getMinute() {return minute;}
public int getSecond() {return second;}
// convert to String in universal-time format (HH:MM:SS)
public String toUniversalString() {
return String.format( "%02d:%02d:%02d", getHour(), getMinute(), getSecond());
}
// convert to String in standard-time format (H:MM:SS AM or PM)
public String toString() {
return String.format("%d:%02d:%02d %s",
((getHour() == 0 || getHour() == 12) ? 12 : getHour() % 12), getMinute(), getSecond(), (getHour() < 12 ? "AM" : "PM"));
}
}
</code></pre>
| 0debug |
import heapq
def larg_nnum(list1,n):
largest=heapq.nlargest(n,list1)
return largest | 0debug |
REGEX for finding exactly two non consecutive characters in a line using GREP/AWK : This is what I have.
grep "\(r\)\1" file
How do I adept this to make it match too possibly non consecutive r's | 0debug |
UIBezierPath doesn't work in TopRight corner and BottomRight corner : <p>I want to round my right corners, but only works for Left corners</p>
<pre><code>let path = UIBezierPath(roundedRect: view.bounds, byRoundingCorners: [UIRectCorner.TopLeft, UIRectCorner.TopRight], cornerRadii: CGSizeMake(20.0, 20.0))
let maskLayer = CAShapeLayer()
maskLayer.path = path.CGPath
view.layer.mask = maskLayer
view.layer.masksToBounds = true
</code></pre>
| 0debug |
how to show certain row data from query horizontally in sql : i have this query
select inv.refe, co.color, inv.size, sum(acu.total), bo.wareh from inv_article inv
inner join inv_colors co on inv.color = co.color
inner join inv_store acu on inv.item = acu.item
inner join inv_bods bo on bo.wareh = acu.wareh
where refers = 'julios'
and acu.year = '2018'
group by inv.refe, co.color, inv.size, bo.wareh
having SUM(total) != '0'
which gives me the following result
> JULIOS BLUE 35 1,00 DENVER
> JULIOS BLUE 35 1,00 PA
> JULIOS BLUE 36 1,00 FLORIDA
> JULIOS BLUE 36 2,00 FLORIDA
> JULIOS BLUE 37 2,00 HOUSTON
> JULIOS BLUE 38 2,00 FLORIDA
> JULIOS GREEN 35 1,00 DENVER
> JULIOS GREEN 35 1,00 PA
> JULIOS GREEN 36 1,00 FLORIDA
> JULIOS GREEN 36 2,00 FLORIDA
> JULIOS GREEN 37 2,00 HOUSTON
> JULIOS GREEN 38 2,00 FLORIDA
I WANT THE RESUL TO SHOW THE SIZE RESULT HORIZONTALLY EXAMPLE
refe color 35 36 37 38 39 40 wareh
and the total goes on the bottom of each size
| 0debug |
Can't understand this zero index? : Could someone tell, what happens when using this zero index?
document.getElementsByTagName('head')[0].appendChild(script); | 0debug |
How does source code manage white space and concatenation : <p>In the following code:</p>
<pre><code> $email_body =
"message from $name \n"
"email address $visitor_email \n"
"\n $message";
</code></pre>
<p>the fourth line generates a parsing error dues to an unexpected <code>"</code>, but the quotes seem to be correctly paired. So why is (the final?) one in the last line "unexpected"?</p>
<p>I expected the result for $email_body to be:</p>
<pre><code> message from $name
email address $visitor_email
$message
</code></pre>
<p>I've looked throught the syntax page on php.net/manual, and read the questions here on single and double quotes. I can't find any exceptions for a line feed at the beginning of a string but that seems to be what it is. Can anyone clarify?</p>
| 0debug |
Convert decimal number to binary in C : <p>For an assignment I need to convert a 16-bit decimal number to a binary number. So for example the number 9 should print 0000000000001001. My professor started us with this code:</p>
<pre><code>void printBinary(short n)
{
}
int main(int argc, char **argv)
{
short n;
printf("Enter number: ");
scanf("%hd", &n);
printBinary(n);
}
</code></pre>
<p>I am very confused as to where to go from here. I really would appreciate anyone helping me understand what to do, as I am very new to coding. Thanks in advance.</p>
| 0debug |
static void virtio_net_device_realize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIONet *n = VIRTIO_NET(dev);
NetClientState *nc;
int i;
virtio_init(vdev, "virtio-net", VIRTIO_ID_NET, n->config_size);
n->max_queues = MAX(n->nic_conf.peers.queues, 1);
n->vqs = g_malloc0(sizeof(VirtIONetQueue) * n->max_queues);
n->vqs[0].rx_vq = virtio_add_queue(vdev, 256, virtio_net_handle_rx);
n->curr_queues = 1;
n->vqs[0].n = n;
n->tx_timeout = n->net_conf.txtimer;
if (n->net_conf.tx && strcmp(n->net_conf.tx, "timer")
&& strcmp(n->net_conf.tx, "bh")) {
error_report("virtio-net: "
"Unknown option tx=%s, valid options: \"timer\" \"bh\"",
n->net_conf.tx);
error_report("Defaulting to \"bh\"");
if (n->net_conf.tx && !strcmp(n->net_conf.tx, "timer")) {
n->vqs[0].tx_vq = virtio_add_queue(vdev, 256,
virtio_net_handle_tx_timer);
n->vqs[0].tx_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, virtio_net_tx_timer,
&n->vqs[0]);
} else {
n->vqs[0].tx_vq = virtio_add_queue(vdev, 256,
virtio_net_handle_tx_bh);
n->vqs[0].tx_bh = qemu_bh_new(virtio_net_tx_bh, &n->vqs[0]);
n->ctrl_vq = virtio_add_queue(vdev, 64, virtio_net_handle_ctrl);
qemu_macaddr_default_if_unset(&n->nic_conf.macaddr);
memcpy(&n->mac[0], &n->nic_conf.macaddr, sizeof(n->mac));
n->status = VIRTIO_NET_S_LINK_UP;
n->announce_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL,
virtio_net_announce_timer, n);
if (n->netclient_type) {
n->nic = qemu_new_nic(&net_virtio_info, &n->nic_conf,
n->netclient_type, n->netclient_name, n);
} else {
n->nic = qemu_new_nic(&net_virtio_info, &n->nic_conf,
object_get_typename(OBJECT(dev)), dev->id, n);
peer_test_vnet_hdr(n);
if (peer_has_vnet_hdr(n)) {
for (i = 0; i < n->max_queues; i++) {
qemu_using_vnet_hdr(qemu_get_subqueue(n->nic, i)->peer, true);
n->host_hdr_len = sizeof(struct virtio_net_hdr);
} else {
n->host_hdr_len = 0;
qemu_format_nic_info_str(qemu_get_queue(n->nic), n->nic_conf.macaddr.a);
n->vqs[0].tx_waiting = 0;
n->tx_burst = n->net_conf.txburst;
virtio_net_set_mrg_rx_bufs(n, 0);
n->promisc = 1;
n->mac_table.macs = g_malloc0(MAC_TABLE_ENTRIES * ETH_ALEN);
n->vlans = g_malloc0(MAX_VLAN >> 3);
nc = qemu_get_queue(n->nic);
nc->rxfilter_notify_enabled = 1;
n->qdev = dev;
register_savevm(dev, "virtio-net", -1, VIRTIO_NET_VM_VERSION,
virtio_net_save, virtio_net_load, n);
| 1threat |
static int vp8_lossy_decode_frame(AVCodecContext *avctx, AVFrame *p,
int *got_frame, uint8_t *data_start,
unsigned int data_size)
{
WebPContext *s = avctx->priv_data;
AVPacket pkt;
int ret;
if (!s->initialized) {
ff_vp8_decode_init(avctx);
s->initialized = 1;
if (s->has_alpha)
avctx->pix_fmt = AV_PIX_FMT_YUVA420P;
}
s->lossless = 0;
if (data_size > INT_MAX) {
av_log(avctx, AV_LOG_ERROR, "unsupported chunk size\n");
return AVERROR_PATCHWELCOME;
}
av_init_packet(&pkt);
pkt.data = data_start;
pkt.size = data_size;
ret = ff_vp8_decode_frame(avctx, p, got_frame, &pkt);
if (s->has_alpha) {
ret = vp8_lossy_decode_alpha(avctx, p, s->alpha_data,
s->alpha_data_size);
}
} | 1threat |
Can't read json_encode : <p>I'm having an issue. I have a json_encode array in php. With ajax, I get back in my javascript script. </p>
<p><strong>php</strong></p>
<pre><code><?php
$code = 'xyz';
$email = 'xyz@gmail.com';
$back = array();
array_push($back, array("code" => $code,"email" => $email));
echo json_encode($back);
?>
</code></pre>
<p><strong>ajax callback function</strong></p>
<pre><code>function(data){
alert(data);
alert(data[0].code);
}
</code></pre>
<p>When I try to alert data, I get <code>[{"code":"xyz","email":"xyz@gmail.com"}]</code></p>
<p>Now when I try to alert the code (or the email) it says <code>undefined</code>. </p>
<p>Can you help me alert data[0].code properly ? </p>
| 0debug |
static int find_pte32(CPUPPCState *env, struct mmu_ctx_hash32 *ctx,
target_ulong sr, target_ulong eaddr, int rwx)
{
hwaddr pteg_off, pte_offset;
ppc_hash_pte32_t pte;
hwaddr hash;
uint32_t vsid, pgidx, ptem;
int ret;
ret = -1;
vsid = sr & SR32_VSID;
ctx->key = (((sr & SR32_KP) && (msr_pr != 0)) ||
((sr & SR32_KS) && (msr_pr == 0))) ? 1 : 0;
pgidx = (eaddr & ~SEGMENT_MASK_256M) >> TARGET_PAGE_BITS;
hash = vsid ^ pgidx;
ptem = (vsid << 7) | (pgidx >> 10);
LOG_MMU("htab_base " TARGET_FMT_plx " htab_mask " TARGET_FMT_plx
" hash " TARGET_FMT_plx "\n",
env->htab_base, env->htab_mask, hash);
LOG_MMU("0 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=%" PRIx32 " ptem=%" PRIx32
" hash=" TARGET_FMT_plx "\n",
env->htab_base, env->htab_mask, vsid, ptem, hash);
pteg_off = get_pteg_offset32(env, hash);
pte_offset = ppc_hash32_pteg_search(env, pteg_off, 0, ptem, &pte);
if (pte_offset == -1) {
LOG_MMU("1 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=%" PRIx32 " api=%" PRIx32
" hash=" TARGET_FMT_plx "\n", env->htab_base,
env->htab_mask, vsid, ptem, ~hash);
pteg_off = get_pteg_offset32(env, ~hash);
pte_offset = ppc_hash32_pteg_search(env, pteg_off, 1, ptem, &pte);
}
if (pte_offset != -1) {
ret = pte_check_hash32(ctx, pte.pte0, pte.pte1, rwx);
LOG_MMU("found PTE at addr %08" HWADDR_PRIx " prot=%01x ret=%d\n",
ctx->raddr, ctx->prot, ret);
if (ppc_hash32_pte_update_flags(ctx, &pte.pte1, ret, rwx) == 1) {
ppc_hash32_store_hpte1(env, pte_offset, pte.pte1);
}
}
return ret;
}
| 1threat |
How to get timezone offset as ±hh:mm? : <p>I can get the offset seconds from GMT with this: <code>TimeZone.current.secondsFromGMT()</code>.</p>
<p>However, how do I get the format as <code>±hh:mm</code>?</p>
| 0debug |
How to save generated exe in Run-Time Complation : I am trying to save to Desktop generated code by CSharpProvider to Desktop . How can i do that ?` CodeDomProvider codeProvider = CodeDomProvider.CreateProvider("CSharp");
string Output = "Out.exe";
Button ButtonObject = (Button)sender;
textBox2.Text = "";
System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters();
//Make sure we generate an EXE, not a DLL
parameters.GenerateExecutable = true;
parameters.OutputAssembly = Output;
CompilerResults results = codeProvider.CompileAssemblyFromSource(parameters, textBox1.Text);
if (results.Errors.Count > 0)
{
textBox2.ForeColor = Color.Red;
foreach (CompilerError CompErr in results.Errors)
{
textBox2.Text = textBox2.Text +
"Line number " + CompErr.Line +
", Error Number: " + CompErr.ErrorNumber +
", '" + CompErr.ErrorText + ";" +
Environment.NewLine + Environment.NewLine;
}
}
else
{
//Successful Compile
textBox2.ForeColor = Color.Blue;
textBox2.Text = "Success!";
//If we clicked run then launch our EXE
if (ButtonObject.Text == "Run") Process.Start(Output);
}` | 0debug |
static void gen_brcond(DisasContext *dc, TCGCond cond,
TCGv_i32 t0, TCGv_i32 t1, uint32_t offset)
{
int label = gen_new_label();
tcg_gen_brcond_i32(cond, t0, t1, label);
gen_jumpi(dc, dc->next_pc, 0);
gen_set_label(label);
gen_jumpi(dc, dc->pc + offset, 1);
}
| 1threat |
Zero Division Error in boolean statement Python : <pre><code>print(True or 5 / 0 > 3)
</code></pre>
<p>This is my code but it returns <code>True</code></p>
<p>Is there a reason why it doesn't return a Zero Division Error?</p>
| 0debug |
static void asfrtp_close_context(PayloadContext *asf)
{
ffio_free_dyn_buf(&asf->pktbuf);
av_freep(&asf->buf);
av_free(asf);
}
| 1threat |
Why CSS рover is not working? : My site test06.menchasha.ru. I am trying to apply hover effect: when hover the link Promotional Activities, div in the right should appear.
[Example][1]
[1]: https://i.stack.imgur.com/48DZG.png
I use the following code:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.child1 {
display: none;
}
a .title1:hover + .child1 {
display: inline-block;
}
<!-- end snippet -->
But this hover effect is not working. What should I correct?
Thank you in advance! | 0debug |
Swift 4: Parse to generic type using URLSession data task needs to implement Encodable : <p>I have two classes, the first one <code>WebsiteDescription</code> and the second one: <code>Course</code>.</p>
<p>Both have inheritance from <code>Decodable</code> and the first one is implementing the protocol <code>Encoder</code> without no definition.</p>
<p>But, my code has a problem:</p>
<blockquote>
<p>Type 'WebsiteDescription' does not conform to protocol 'Encodable'</p>
</blockquote>
<p>This error appears in the line:</p>
<p><code>self.requestdata(endpoint: jsonUrlString, type: WebsiteDescription.self) { result, error in
}</code></p>
<p>The complete code is:</p>
<pre><code>import UIKit
public class WebsiteDescription:Decodable {
init(){
}
let name: String?
let description: String?
//let courses: [Course]?
func encode(to encoder: Encoder) throws {
do {
} catch {
print(error)
}
}
}
class Course: Decodable {
let id: Int?
let name: String?
let link: String?
let imageUrl: String?
}
class RequestController : UIViewController{
override func viewDidLoad() {
super.viewDidLoad()
let jsonUrlString = "http://api.letsbuildthatapp.com/jsondecodable/website_description"
self.requestdata(endpoint: jsonUrlString, type: WebsiteDescription.self) { result, error in
}
}
func requestdata<T:Codable>(endpoint :String, type: T.Type, completionHandler: @escaping (T?, Error?) -> ()) {
let jsonUrlString = "http://api.letsbuildthatapp.com/jsondecodable/website_description"
guard let url = URL(string: jsonUrlString) else {return }
URLSession.shared.dataTask(with: url){ (data, response, err) in
guard let data = data else{ completionHandler(nil, nil) }
do {
let result = self.parse(data: data, type: type)
completionHandler(result, nil)
} catch let jsonErr{
completionHandler(nil, jsonErr)
}
}.resume()
}
private func parse<T:Codable>(data: Data, type: T.Type) -> T? {
do{
let json = try JSONDecoder().decode(type, from: data)
print(json)
return json
}catch {
return nil
}
return nil
}
}
</code></pre>
<p>Well, I'm trying to use <code>URLSession</code> in my method to cast all my request in a single middleware.</p>
<p>How I can resolve the <code>Encodable</code> issue?</p>
| 0debug |
static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
int buf_size, int *coded_samples, int *approx_nb_samples)
{
ADPCMDecodeContext *s = avctx->priv_data;
int nb_samples = 0;
int ch = avctx->channels;
int has_coded_samples = 0;
int header_size;
*coded_samples = 0;
*approx_nb_samples = 0;
if(ch <= 0)
return 0;
switch (avctx->codec->id) {
case AV_CODEC_ID_ADPCM_EA_XAS:
if (buf_size < 76 * ch)
return 0;
nb_samples = 128;
break;
case AV_CODEC_ID_ADPCM_IMA_QT:
if (buf_size < 34 * ch)
return 0;
nb_samples = 64;
break;
case AV_CODEC_ID_ADPCM_CT:
case AV_CODEC_ID_ADPCM_IMA_APC:
case AV_CODEC_ID_ADPCM_IMA_EA_SEAD:
case AV_CODEC_ID_ADPCM_IMA_OKI:
case AV_CODEC_ID_ADPCM_IMA_WS:
case AV_CODEC_ID_ADPCM_YAMAHA:
nb_samples = buf_size * 2 / ch;
break;
}
if (nb_samples)
return nb_samples;
header_size = 0;
switch (avctx->codec->id) {
case AV_CODEC_ID_ADPCM_4XM:
case AV_CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch; break;
case AV_CODEC_ID_ADPCM_IMA_AMV: header_size = 8; break;
case AV_CODEC_ID_ADPCM_IMA_SMJPEG: header_size = 4 * ch; break;
}
if (header_size > 0)
return (buf_size - header_size) * 2 / ch;
switch (avctx->codec->id) {
case AV_CODEC_ID_ADPCM_EA:
has_coded_samples = 1;
*coded_samples = bytestream2_get_le32(gb);
*coded_samples -= *coded_samples % 28;
nb_samples = (buf_size - 12) / 30 * 28;
break;
case AV_CODEC_ID_ADPCM_IMA_EA_EACS:
has_coded_samples = 1;
*coded_samples = bytestream2_get_le32(gb);
nb_samples = (buf_size - (4 + 8 * ch)) * 2 / ch;
break;
case AV_CODEC_ID_ADPCM_EA_MAXIS_XA:
nb_samples = (buf_size - ch) / ch * 2;
break;
case AV_CODEC_ID_ADPCM_EA_R1:
case AV_CODEC_ID_ADPCM_EA_R2:
case AV_CODEC_ID_ADPCM_EA_R3:
has_coded_samples = 1;
switch (avctx->codec->id) {
case AV_CODEC_ID_ADPCM_EA_R1:
header_size = 4 + 9 * ch;
*coded_samples = bytestream2_get_le32(gb);
break;
case AV_CODEC_ID_ADPCM_EA_R2:
header_size = 4 + 5 * ch;
*coded_samples = bytestream2_get_le32(gb);
break;
case AV_CODEC_ID_ADPCM_EA_R3:
header_size = 4 + 5 * ch;
*coded_samples = bytestream2_get_be32(gb);
break;
}
*coded_samples -= *coded_samples % 28;
nb_samples = (buf_size - header_size) * 2 / ch;
nb_samples -= nb_samples % 28;
*approx_nb_samples = 1;
break;
case AV_CODEC_ID_ADPCM_IMA_DK3:
if (avctx->block_align > 0)
buf_size = FFMIN(buf_size, avctx->block_align);
nb_samples = ((buf_size - 16) * 2 / 3 * 4) / ch;
break;
case AV_CODEC_ID_ADPCM_IMA_DK4:
if (avctx->block_align > 0)
buf_size = FFMIN(buf_size, avctx->block_align);
nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch;
break;
case AV_CODEC_ID_ADPCM_IMA_RAD:
if (avctx->block_align > 0)
buf_size = FFMIN(buf_size, avctx->block_align);
nb_samples = (buf_size - 4 * ch) * 2 / ch;
break;
case AV_CODEC_ID_ADPCM_IMA_WAV:
{
int bsize = ff_adpcm_ima_block_sizes[avctx->bits_per_coded_sample - 2];
int bsamples = ff_adpcm_ima_block_samples[avctx->bits_per_coded_sample - 2];
if (avctx->block_align > 0)
buf_size = FFMIN(buf_size, avctx->block_align);
nb_samples = 1 + (buf_size - 4 * ch) / (bsize * ch) * bsamples;
break;
}
case AV_CODEC_ID_ADPCM_MS:
if (avctx->block_align > 0)
buf_size = FFMIN(buf_size, avctx->block_align);
nb_samples = 2 + (buf_size - 7 * ch) * 2 / ch;
break;
case AV_CODEC_ID_ADPCM_SBPRO_2:
case AV_CODEC_ID_ADPCM_SBPRO_3:
case AV_CODEC_ID_ADPCM_SBPRO_4:
{
int samples_per_byte;
switch (avctx->codec->id) {
case AV_CODEC_ID_ADPCM_SBPRO_2: samples_per_byte = 4; break;
case AV_CODEC_ID_ADPCM_SBPRO_3: samples_per_byte = 3; break;
case AV_CODEC_ID_ADPCM_SBPRO_4: samples_per_byte = 2; break;
}
if (!s->status[0].step_index) {
nb_samples++;
buf_size -= ch;
}
nb_samples += buf_size * samples_per_byte / ch;
break;
}
case AV_CODEC_ID_ADPCM_SWF:
{
int buf_bits = buf_size * 8 - 2;
int nbits = (bytestream2_get_byte(gb) >> 6) + 2;
int block_hdr_size = 22 * ch;
int block_size = block_hdr_size + nbits * ch * 4095;
int nblocks = buf_bits / block_size;
int bits_left = buf_bits - nblocks * block_size;
nb_samples = nblocks * 4096;
if (bits_left >= block_hdr_size)
nb_samples += 1 + (bits_left - block_hdr_size) / (nbits * ch);
break;
}
case AV_CODEC_ID_ADPCM_THP:
if (avctx->extradata) {
nb_samples = buf_size / (8 * ch) * 14;
break;
}
has_coded_samples = 1;
bytestream2_skip(gb, 4);
*coded_samples = bytestream2_get_be32(gb);
*coded_samples -= *coded_samples % 14;
nb_samples = (buf_size - (8 + 36 * ch)) / (8 * ch) * 14;
break;
case AV_CODEC_ID_ADPCM_AFC:
nb_samples = buf_size / (9 * ch) * 16;
break;
case AV_CODEC_ID_ADPCM_XA:
nb_samples = (buf_size / 128) * 224 / ch;
break;
case AV_CODEC_ID_ADPCM_DTK:
nb_samples = buf_size / (16 * ch) * 28;
break;
}
if (has_coded_samples && (*coded_samples <= 0 || *coded_samples > nb_samples))
return AVERROR_INVALIDDATA;
return nb_samples;
}
| 1threat |
Devise NoMethodError 'for' ParameterSanitizer : <p>I'm going nuts with an error I'm getting every time I try to sing in/sing up on my web.</p>
<p>Heroku logs:</p>
<pre><code>Started GET "/users/sign_in" for 201.235.89.150 at 2016-07-06 01:35:03 +0000
Completed 500 Internal Server Error in 3ms (ActiveRecord: 0.0ms)
NoMethodError (undefined method `for' for #<Devise::ParameterSanitizer:0x007f5968e0a920>):
app/controllers/application_controller.rb:11:in `configure_permitted_parameters'
</code></pre>
<p>application_controller.rb</p>
<pre><code>class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password, :provider, :uid) }
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :password, :current_password) }
end
end
</code></pre>
<p>The thing is it is working fine locally. It´s just on Heroku. And also it was working just fine a couple of days ago.</p>
| 0debug |
Good way to losslessly compress a massive string : <p>I have this giant string, I was wondering if it can be compressed and if so what are some good ways to do so.</p>
<p>"01011311100111111112110131131011111110111011113111101101001110110110100110001001111003011011101111311102110011030111001311110113110111110111111111111111311103010001113110013100100101110000010111111111001000111111100001100030111111131113113101101001100111111100110100131001102101101110030300300011011111001111100010110011201111111011110011101011000011100013110101111003000131111012011131000000113111111311111001100111011111000101111101313111010000001131103011210111101001110010100113111311000111001100011110001000001111110001111111001010001011111100111000131000"</p>
<p>This is a sample and there are thousands more lines. Any suggestions?</p>
| 0debug |
static void vc1_decode_b_blocks(VC1Context *v)
{
MpegEncContext *s = &v->s;
switch(v->c_ac_table_index){
case 0:
v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
break;
case 1:
v->codingset = CS_HIGH_MOT_INTRA;
break;
case 2:
v->codingset = CS_MID_RATE_INTRA;
break;
}
switch(v->c_ac_table_index){
case 0:
v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
break;
case 1:
v->codingset2 = CS_HIGH_MOT_INTER;
break;
case 2:
v->codingset2 = CS_MID_RATE_INTER;
break;
}
s->first_slice_line = 1;
for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) {
for(s->mb_x = 0; s->mb_x < s->mb_width; s->mb_x++) {
ff_init_block_index(s);
ff_update_block_index(s);
s->dsp.clear_blocks(s->block[0]);
vc1_decode_b_mb(v);
if(get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) {
ff_er_add_slice(s, 0, 0, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n", get_bits_count(&s->gb), v->bits,s->mb_x,s->mb_y);
return;
}
if(v->s.loop_filter) vc1_loop_filter_iblk(s, s->current_picture.qscale_table[s->mb_x + s->mb_y *s->mb_stride]);
}
ff_draw_horiz_band(s, s->mb_y * 16, 16);
s->first_slice_line = 0;
}
ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END));
}
| 1threat |
whereNear query doesn't seem to work properly in Parse : <p>I'm working on an Android app related to Geolocations. I'm using Parse as backend.
I need to display results based on user's current location. </p>
<p>I'm using this query:</p>
<pre><code>ParseQuery<ParseObject> query = ParseQuery.getQuery("Restaurants");
ParseGeoPoint sLatlong = new ParseGeoPoint(currentLat, currentLong);
query.whereNear("rest_location", sLatlong);
</code></pre>
<p>But the results are not sorted distance wise. </p>
<p>Can someone help me out. </p>
| 0debug |
void connection_destroy(void *opaque)
{
Connection *conn = opaque;
g_queue_foreach(&conn->primary_list, packet_destroy, NULL);
g_queue_free(&conn->primary_list);
g_queue_foreach(&conn->secondary_list, packet_destroy, NULL);
g_queue_free(&conn->secondary_list);
g_slice_free(Connection, conn);
}
| 1threat |
static uint64_t pxa2xx_i2s_read(void *opaque, hwaddr addr,
unsigned size)
{
PXA2xxI2SState *s = (PXA2xxI2SState *) opaque;
switch (addr) {
case SACR0:
return s->control[0];
case SACR1:
return s->control[1];
case SASR0:
return s->status;
case SAIMR:
return s->mask;
case SAICR:
return 0;
case SADIV:
return s->clk;
case SADR:
if (s->rx_len > 0) {
s->rx_len --;
pxa2xx_i2s_update(s);
return s->codec_in(s->opaque);
}
return 0;
default:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr);
break;
}
return 0;
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.