problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
CSS3 :nth-child(odd) Selector not selecting columns not rows : I have a simple table using tr:nth-child(odd) to alternate background for rows in a table.
HTML
<tr class="sao-zebra">
<th class="sao-feature">Some Text</th>
<td class="sao-even-basic">Copy</td>
<td class="sao-even-gold">Copy</td>
</tr>
<tr class="sao-zebra">
<th class="sao-feature">More Text</th>
<td class="sao-odd-basic"><span class="sao-checkmark">✓</span></td>
<td class="sao-odd-gold"><span class="sao-checkmark">✓</span></td>
</tr>
CSS
tr.sao-zebra :nth-child(odd) {
background: #23282D;
}
as is stands, the table has 3 columns. The nth-child pseudo selector is causing every other column to be black, not every other row. What have I done wrong? | 0debug |
Sending JSON Data with Xcode : I'm building a chat app and I understand how to receive the data back but I'm having trouble sending the data. Im trying to take two UITextField values which are the username and the message and send the data.
Variables
@IBOutlet weak var username: UITextField!
@IBOutlet weak var textBox: UITextField!
Request To Receive
@IBAction func sendMessage(_ sender: UIButton) {
let parameters = ["user": username.text, "message": textBox.text] as! [String: String]
//create the url with NSURL
let url = NSURL(string: "http://website.com/getChatLogJSON.php")
//create the session object
let session = URLSession.shared
//now create the NSMutableRequest object using the url object
let request = NSMutableURLRequest(url: url! as URL)
request.httpMethod = "POST" //set http method as POST
do {
request.httpBody = try JSONSerialization.data(withJSONObject: parameters, options: .prettyPrinted) // pass dictionary to nsdata object and set it as request body
} catch let error {
print(error.localizedDescription)
}
//HTTP Headers
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")
//create dataTask using the session object to send data to the server
let task = session.dataTask(with: request as URLRequest, completionHandler: { data, response, error in
guard error == nil else {
return
}
guard let data = data else {
return
}
do {
//create json object from data
if let json = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String: AnyObject] {
print(json)
// handle json...
}
} catch let error {
print(error.localizedDescription)
}
})
task.resume()
} | 0debug |
how to sort my sql table datas in category wise : im trying to create a music site
i need to sort my table datas in category wise
Like English , Chines , Hindi etc but i dont know this
Help Me Please
sorry for my bad english
my table
CREATE TABLE `players` (
`id` int(11) NOT NULL auto_increment,
`namemovie` varchar(50) NOT NULL,
`releaseyear` varchar(50) NOT NULL,
`musiccategory` varchar(50) NOT NULL,
`musiclink` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
| 0debug |
Subtract values in single column using where condition : Table Name : report
column : amount, type
values of 'type' = credit, debit
I want to calculate balance via sum (amount) where type=credit - sum (amount) where type=debit
Please check the sqlfiddle : http://sqlfiddle.com/#!9/cd8b8c
thanks a lot !!! | 0debug |
Kotlin Android Extensions giving Layout Null Pointer : <p>There is a fairly simple scenario that is giving me quite a bit of trouble. I'm making a very simple Activity with an embedded fragment. This fragment is simply a Gridview that displays some images. The issue comes when referring to the Gridview using Kotlin extensions to refer directly to an XML id. <strong>What is the issue here?
Does kotlinx not work on static fragments?</strong></p>
<p><em>Error:</em></p>
<pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.android_me/com.example.android.android_me.ui.MainActivity}: java.lang.IllegalStateException: gridview_all_parts must not be null
Caused by: java.lang.IllegalStateException: gridview_all_parts must not be null at com.example.android.android_me.ui.MasterListFragment.onActivityCreated(MasterListFragment.kt:22)
</code></pre>
<p><em>Fragment with offensive line of code</em></p>
<pre><code>import kotlinx.android.synthetic.main.fragment_master_list.*
class MasterListFragment: Fragment() {
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val layoutView = inflater?.inflate(R.layout.fragment_master_list, container, false)
return layoutView
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
//If this is removed, code runs
gridview_all_parts.adapter = MasterListAdapter(activity, AndroidImageAssets.getAll())
super.onActivityCreated(savedInstanceState)
}
}
</code></pre>
<p><em>Fragment Layout:</em></p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview_all_parts"
android:layout_width="match_parent" android:layout_height="match_parent"/>
</code></pre>
<p><em>Parent Activity Layout</em></p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<!--have tried both class:= and android:name:=-->
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
class="com.example.android.android_me.ui.MasterListFragment"
android:id="@+id/fragment_masterlist"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</code></pre>
<p><em>Parent Activity</em></p>
<pre><code>class MainActivity: AppCompatActivity(){
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}
</code></pre>
| 0debug |
Tkinter error TclError: invalid command name ".71847552" : I am making an excel comparing program and exporting it to a CSV file. Here is my code:
import openpyxl, csv
from tkinter import *
from tkinter.filedialog import askopenfilename
from openpyxl.utils import column_index_from_string
output = open('differences.csv', 'w', newline='')
output_writer = csv.writer(output)
wb1, wb2 = '', ''
sheet1, sheet2 = '', ''
column_1, column_2 = '', ''
root = Tk()
root.configure(background='light green')
root.geometry("500x500")
root.wm_title("BananaCell")
e1 = Text(root, width=15, height=1)
e1.pack()
e1.place(x=70, y=150)
e2 = Text(root, width=15, height=1)
e2.pack()
e2.place(x=300, y=150)
column1_entry = Text(root, width=5, height=1)
column1_entry.pack()
column1_entry.place(x=135, y=250)
column2_entry = Text(root, width=5, height=1)
column2_entry.pack()
column2_entry.place(x=385, y=250)
def destroy():
root.destroy()
def ask_for_filename_1():
global wb1
wb1 = askopenfilename(title="Select Workbook 1")
print(str(wb1))
return wb1
def ask_for_filename_2():
global wb2
wb2 = askopenfilename(title="Select Workbook 1")
print(str(wb2))
return wb2
def ask_for_sheet1():
global sheet1
sheet1 = e1.get("1.0", "end-1c")
print(sheet1)
return sheet1
def ask_for_sheet2():
global sheet2
sheet2 = e2.get("1.0", "end-1c")
print(sheet2)
return sheet2
def get_col_1():
global column_1
column_1 = column1_entry.get("1.0", "end-1c")
print(column_1)
return column_1
def get_col_2():
global column_2
column_2 = column2_entry.get("1.0", "end-1c")
print(column_2)
return column_2
filename_button1 = Button(root, text="Workbook 1", width=12, height=2, command=ask_for_filename_1)
filename_button1.pack()
filename_button1.place(x=100, y=100)
filename_button2 = Button(root, text="Workbook 2", width=12, height=2, command=ask_for_filename_2)
filename_button2.pack()
filename_button2.place(x=300, y=100)
col_button1 = Button(root, text="Enter", width=5, height=1, command=get_col_1)
col_button1.pack()
col_button1.place(x=185, y=248)
col_button2 = Button(root, text="Enter", width=5, height=1, command=get_col_2)
col_button2.pack()
col_button2.place(x=435, y=248)
sheet_button1 = Button(root, text="Enter", width=6, height=0, command=ask_for_sheet1)
sheet_button1.pack()
sheet_button1.place(x=15, y=147)
sheet_button2 = Button(root, text="Enter", width=6, height=0, command=ask_for_sheet2)
sheet_button2.pack()
sheet_button2.place(x=430, y=147)
label1 = Label(root, text="Sheet 1 column letter: ", bg="light green")
label1.pack()
label1.place(x=10, y=250)
label2 = Label(root, text="Sheet 2 column letter: ", bg = "light green")
label2.pack()
label2.place(x=260, y=250)
def write_csv(col1, col2, worksheet1, worksheet2):
for (col, col_1) in zip(worksheet1.iter_cols(min_col = column_index_from_string(col1), max_col=column_index_from_string(col1)), worksheet2.iter_cols(min_col = column_index_from_string(col2), max_col=column_index_from_string(col2))):
for (cell, cell_1) in zip(col, col_1):
if cell.value != cell_1.value and cell.row == cell_1.row:
output_writer.writerow(['Sheet 1 value: ' + ' ' + str(cell.value) + ' ' + 'is not equal to ' + ' ' + 'Sheet 2 value: ' + ' ' + str(cell_1.value) + ' ' + 'on row ' + ' ' + str(cell.row)])
dButton = Button(root, text="Exit", width=8, height=1, command=destroy)
dButton.pack()
dButton.place(x=100, y=60)
mainloop()
workbook1 = openpyxl.load_workbook(str(wb1))
workbook2 = openpyxl.load_workbook(str(wb2))
global sheet1
sheet1 = e1.get("1.0", "end-1c")
global sheet2
sheet2 = e2.get("1.0", "end-1c")
worksheet1 = workbook1.get_sheet_by_name(str(sheet1))
worksheet2 = workbook2.get_sheet_by_name(str(sheet2))
col1 = column1_entry.get("1.0", "end-1c")
col2 = column2_entry.get("1.0", "end-1c")
write_csv(col1, col2, worksheet1, worksheet2)
However, when I run the follwing code, I enter the criteria required and end up with the following error: `_tkinter.TclError: invalid command name ".71847552"`.
Does anyone know how to fix this issue? Any help would be massively appreciated
| 0debug |
Pattern to use Serilog (pass ILogger vs using static Serilog.Log) : <p><strong>Background</strong></p>
<p>In a new project where <em>Serilog</em> was chosen as the logger I automatically started passing around <code>ILogger</code> interface. The code accesses <code>Log.Logger</code> once and from then the classes that desire logging accept <code>ILogger</code> via constructor injection. </p>
<p>I was challenged on this practice and the advice was to use the static methods on the <code>Log</code> class, e.g. <code>Serilog.Log.Debug(...)</code>. The argument is that there is a <code>set;</code> on <code>Log.Logger</code> so mocking is easy. </p>
<p>Looking at the api I can see that one of the benefits of passing <code>ILogger</code> are the <code>ForContext</code> methods.</p>
<p>I spent some time on the webs and in the <em>Serilog</em>'s documentation but I could not find information about a canonical way to access the log throughout the application code. </p>
<p><strong>Question</strong></p>
<p>Is there a canonical, i.e. better-in-most-cases, way to access/pass around the <em>Serilog</em> logger and if there is, is it passing <code>ILogger</code> or using the static api on the <code>Serilog.Log</code> class?</p>
| 0debug |
Material spinner cant support v4 device. How can i fix it? : Im using material spinner library 'com.github.ganfra:material-spinner:1.1.0'. This spinner working fine all device . But not working version 4. How can i fix this issues?I attached screenshot
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/yVYCV.png | 0debug |
Python substitution of words : <p>Let's say that I have a text with me and I assigned it a variable. </p>
<p>text = "Don't you want to play"</p>
<p>I want to add a question at the end of the sentence, in order to do that, I need some code which helps me recognize and analyse the first word of the sentence and place a question mark at the end if the sentence starts off with a don't. </p>
<p>The text which is getting back to me has to say: </p>
<p>"Don't you want to play?"</p>
<p>What libraries or what natural language processing software could I use to achieve this?</p>
| 0debug |
Getting error while using const ,I am little confused in using const : <p>I'm wondering what is the difference between let and const in ECMAScript 6. Both of them are block scoped</p>
| 0debug |
tow like condition in 1 sql query : i have a datagridview and i want to set it user to serch data using textbox
i am using vb.net and ms accsess
here is my sql code .when i run it there is an error show "no value given for one or more parameeter
("select *from itemtbl where (item_id like '%" & TextBox1.Text & "%') or (item_desc like '%" & TextBox1.Text & "%') ", objcon1.mydataconnection) | 0debug |
Android Studio not stopping for asking to update Gradle : <p>Since the latest version, Android Studio is annoying me that</p>
<blockquote>
<p>It is strongly recommended that you update Gradle to version 2.14.1 or later.</p>
</blockquote>
<p><a href="https://i.stack.imgur.com/d6tTk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/d6tTk.png" alt="enter image description here"></a></p>
<p>Sadly I can´t update it currently, because it breaks my project completely and I need to do research to get it working, so I´m pressing </p>
<blockquote>
<p>"Don´t remind me again for this project"</p>
</blockquote>
<p>But it ignores it and it pops up over and over again.</p>
<p>Is there any trick to get rid of it?</p>
| 0debug |
How to create and validate forms in Javascript / JQuery? : <p>I'm currently developing a checkout form for an e-commerce site, as any other checkout there are a lot of validations on its fields, things like: </p>
<ul>
<li>If the user selects the radio buton 'I'm Company' show the VAT field.</li>
<li>If the user has no billing address show the inputs to create a new shipping address. </li>
<li>If the user has billing addresses list them as radio buttons.</li>
</ul>
<p>And a lot more, currently I'm using thinks like <code>addClass('hide')</code> or <code>removeClass('hide')</code>, in other cases I use <code>toggle()</code>, it works but somehow I feel that this is not a solid approach.</p>
<p>Is there any 'Best Practices' to create forms and validate them?</p>
<p>Best Regards.</p>
| 0debug |
How to get the record number returned for a MySQL insert command in Perl : <p>I am inserting into a MySQL table from Perl. But sometimes I would like to get the record number for that insert to use later.</p>
<p>Is there a way to get that return from MySQL?</p>
<p>p.s. This table has zero indexes. </p>
<p>Thanks</p>
| 0debug |
sql convert datetime to day name : i want convert form datetime formate to day name but i have problem failed convert.
"Conversion failed when converting date and/or time from character string."
`SELECT DATENAME(dw, date) as date , name, date FROM kkpsurabaya` | 0debug |
AVFixedDSPContext * avpriv_alloc_fixed_dsp(int bit_exact)
{
AVFixedDSPContext * fdsp = av_malloc(sizeof(AVFixedDSPContext));
fdsp->vector_fmul_window_scaled = vector_fmul_window_fixed_scaled_c;
fdsp->vector_fmul_window = vector_fmul_window_fixed_c;
return fdsp;
} | 1threat |
Parsing a string to a usable formate and compare it to current date & time (C#) : I'm trying to parse a string that looks like this (20190903T114500,000) to a formate and compare it to the current time and date. It's supposed to give an allert, when the date and time are only 5 minutes appart.
Yet I'm struggeling with every part of that task. The formate makes no sense, I cant change it because of that "T" in the middle... Im kind of lost tbh.. It would be so nice if someone could help me, I'm just started learning to code... | 0debug |
C# "content acceptance : Hi you know I can't make my character move in unity, because c# doesn't accet word "velocity". Help me solve this problem please.
public class MarioController : MonoBehaviour
{
public float maxSpeed=10f;
bool facingRight=true;
void Start ()
{}
void FixedUpdate ()
{
float move = Input.GetAxis ("Horizontal");
rigidbody2D.velocity = new Vector2 (move * maxSpeed, rigidbody2D.velocity.y);
if (move > 0 && !facingRight)
Flip ();
else if (move < 0 && facingRight)
Flip ();
}
void Flip ()
{
facingRight = !facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
}
| 0debug |
static void omap_update_display(void *opaque)
{
struct omap_lcd_panel_s *omap_lcd = (struct omap_lcd_panel_s *) opaque;
DisplaySurface *surface = qemu_console_surface(omap_lcd->con);
draw_line_func draw_line;
int size, height, first, last;
int width, linesize, step, bpp, frame_offset;
hwaddr frame_base;
if (!omap_lcd || omap_lcd->plm == 1 || !omap_lcd->enable ||
!surface_bits_per_pixel(surface)) {
return;
}
frame_offset = 0;
if (omap_lcd->plm != 2) {
cpu_physical_memory_read(omap_lcd->dma->phys_framebuffer[
omap_lcd->dma->current_frame],
(void *)omap_lcd->palette, 0x200);
switch (omap_lcd->palette[0] >> 12 & 7) {
case 3 ... 7:
frame_offset += 0x200;
break;
default:
frame_offset += 0x20;
}
}
switch ((omap_lcd->palette[0] >> 12) & 7) {
case 1:
draw_line = draw_line_table2[surface_bits_per_pixel(surface)];
bpp = 2;
break;
case 2:
draw_line = draw_line_table4[surface_bits_per_pixel(surface)];
bpp = 4;
break;
case 3:
draw_line = draw_line_table8[surface_bits_per_pixel(surface)];
bpp = 8;
break;
case 4 ... 7:
if (!omap_lcd->tft)
draw_line = draw_line_table12[surface_bits_per_pixel(surface)];
else
draw_line = draw_line_table16[surface_bits_per_pixel(surface)];
bpp = 16;
break;
default:
return;
}
width = omap_lcd->width;
if (width != surface_width(surface) ||
omap_lcd->height != surface_height(surface)) {
qemu_console_resize(omap_lcd->con,
omap_lcd->width, omap_lcd->height);
surface = qemu_console_surface(omap_lcd->con);
omap_lcd->invalidate = 1;
}
if (omap_lcd->dma->current_frame == 0)
size = omap_lcd->dma->src_f1_bottom - omap_lcd->dma->src_f1_top;
else
size = omap_lcd->dma->src_f2_bottom - omap_lcd->dma->src_f2_top;
if (frame_offset + ((width * omap_lcd->height * bpp) >> 3) > size + 2) {
omap_lcd->sync_error = 1;
omap_lcd_interrupts(omap_lcd);
omap_lcd->enable = 0;
return;
}
frame_base = omap_lcd->dma->phys_framebuffer[
omap_lcd->dma->current_frame] + frame_offset;
omap_lcd->dma->condition |= 1 << omap_lcd->dma->current_frame;
if (omap_lcd->dma->interrupts & 1)
qemu_irq_raise(omap_lcd->dma->irq);
if (omap_lcd->dma->dual)
omap_lcd->dma->current_frame ^= 1;
if (!surface_bits_per_pixel(surface)) {
return;
}
first = 0;
height = omap_lcd->height;
if (omap_lcd->subpanel & (1 << 31)) {
if (omap_lcd->subpanel & (1 << 29))
first = (omap_lcd->subpanel >> 16) & 0x3ff;
else
height = (omap_lcd->subpanel >> 16) & 0x3ff;
}
step = width * bpp >> 3;
linesize = surface_stride(surface);
framebuffer_update_display(surface, omap_lcd->sysmem,
frame_base, width, height,
step, linesize, 0,
omap_lcd->invalidate,
draw_line, omap_lcd->palette,
&first, &last);
if (first >= 0) {
dpy_gfx_update(omap_lcd->con, 0, first, width, last - first + 1);
}
omap_lcd->invalidate = 0;
}
| 1threat |
document.getElementById('input').innerHTML = user_input; | 1threat |
Unit testing with private service injected using jasmine angular2 : <p>I have a problem trying to unit test an angular service. I want to verify that this service is properly calling another service that is injected into it.</p>
<p>Lets say I have this ServiceToTest that injects ServiceInjected:</p>
<p>ServiceToTest .service.ts</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>@Injectable()
export class ServiceToTest {
constructor(private _si: ServiceInjected) {}
public init() {
this._si.configure();
}
}</code></pre>
</div>
</div>
</p>
<p>ServiceInjected.service.ts
<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>@Injectable()
export class ServiceInjected {
constructor() {}
public configure() {
/*Some actions*/
}
}</code></pre>
</div>
</div>
</p>
<p>With these services, now I write my unit test: </p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>const serviceInjectedStub = {
configure(): void {}
}
describe('ServiceToTest service Test', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [ServiceToTest ,
{ provide: ServiceInjected, useValue: serviceInjectedStub }]
});
});
it('should be initialize the service injected', inject([ServiceToTest],
(tService: ServiceToTest) => {
spyOn(serviceInjectedStub, 'configure');
tService.init();
expect(serviceInjectedStub.configure).toHaveBeenCalled();
}));</code></pre>
</div>
</div>
</p>
<p>I expected my test to be positive, however I receive the following error:</p>
<p>Expected spy configure to have been called.</p>
<p>On the other hand, it works OK if I set the injected service public in this way:</p>
<pre><code>private _si: ServiceInjected by public si: ServiceInjected
</code></pre>
| 0debug |
static void correlate_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand *b, DWTELEM *src, int stride, int inverse, int use_median, int start_y, int end_y){
const int w= b->width;
int x,y;
DWTELEM * line;
DWTELEM * prev;
if (start_y != 0)
line = slice_buffer_get_line(sb, ((start_y - 1) * b->stride_line) + b->buf_y_offset) + b->buf_x_offset;
for(y=start_y; y<end_y; y++){
prev = line;
line = slice_buffer_get_line(sb, (y * b->stride_line) + b->buf_y_offset) + b->buf_x_offset;
for(x=0; x<w; x++){
if(x){
if(use_median){
if(y && x+1<w) line[x] += mid_pred(line[x - 1], prev[x], prev[x + 1]);
else line[x] += line[x - 1];
}else{
if(y) line[x] += mid_pred(line[x - 1], prev[x], line[x - 1] + prev[x] - prev[x - 1]);
else line[x] += line[x - 1];
}
}else{
if(y) line[x] += prev[x];
}
}
}
}
| 1threat |
static void vga_putcharxy(DisplayState *ds, int x, int y, int ch,
TextAttributes *t_attrib)
{
uint8_t *d;
const uint8_t *font_ptr;
unsigned int font_data, linesize, xorcol, bpp;
int i;
unsigned int fgcol, bgcol;
#ifdef DEBUG_CONSOLE
printf("x: %2i y: %2i", x, y);
console_print_text_attributes(t_attrib, ch);
#endif
if (t_attrib->invers) {
bgcol = color_table[t_attrib->bold][t_attrib->fgcol];
fgcol = color_table[t_attrib->bold][t_attrib->bgcol];
} else {
fgcol = color_table[t_attrib->bold][t_attrib->fgcol];
bgcol = color_table[t_attrib->bold][t_attrib->bgcol];
}
bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3;
d = ds_get_data(ds) +
ds_get_linesize(ds) * y * FONT_HEIGHT + bpp * x * FONT_WIDTH;
linesize = ds_get_linesize(ds);
font_ptr = vgafont16 + FONT_HEIGHT * ch;
xorcol = bgcol ^ fgcol;
switch(ds_get_bits_per_pixel(ds)) {
case 8:
for(i = 0; i < FONT_HEIGHT; i++) {
font_data = *font_ptr++;
if (t_attrib->uline
&& ((i == FONT_HEIGHT - 2) || (i == FONT_HEIGHT - 3))) {
font_data = 0xFFFF;
}
((uint32_t *)d)[0] = (dmask16[(font_data >> 4)] & xorcol) ^ bgcol;
((uint32_t *)d)[1] = (dmask16[(font_data >> 0) & 0xf] & xorcol) ^ bgcol;
d += linesize;
}
break;
case 16:
case 15:
for(i = 0; i < FONT_HEIGHT; i++) {
font_data = *font_ptr++;
if (t_attrib->uline
&& ((i == FONT_HEIGHT - 2) || (i == FONT_HEIGHT - 3))) {
font_data = 0xFFFF;
}
((uint32_t *)d)[0] = (dmask4[(font_data >> 6)] & xorcol) ^ bgcol;
((uint32_t *)d)[1] = (dmask4[(font_data >> 4) & 3] & xorcol) ^ bgcol;
((uint32_t *)d)[2] = (dmask4[(font_data >> 2) & 3] & xorcol) ^ bgcol;
((uint32_t *)d)[3] = (dmask4[(font_data >> 0) & 3] & xorcol) ^ bgcol;
d += linesize;
}
break;
case 32:
for(i = 0; i < FONT_HEIGHT; i++) {
font_data = *font_ptr++;
if (t_attrib->uline && ((i == FONT_HEIGHT - 2) || (i == FONT_HEIGHT - 3))) {
font_data = 0xFFFF;
}
((uint32_t *)d)[0] = (-((font_data >> 7)) & xorcol) ^ bgcol;
((uint32_t *)d)[1] = (-((font_data >> 6) & 1) & xorcol) ^ bgcol;
((uint32_t *)d)[2] = (-((font_data >> 5) & 1) & xorcol) ^ bgcol;
((uint32_t *)d)[3] = (-((font_data >> 4) & 1) & xorcol) ^ bgcol;
((uint32_t *)d)[4] = (-((font_data >> 3) & 1) & xorcol) ^ bgcol;
((uint32_t *)d)[5] = (-((font_data >> 2) & 1) & xorcol) ^ bgcol;
((uint32_t *)d)[6] = (-((font_data >> 1) & 1) & xorcol) ^ bgcol;
((uint32_t *)d)[7] = (-((font_data >> 0) & 1) & xorcol) ^ bgcol;
d += linesize;
}
break;
}
}
| 1threat |
Slice signatures are inconsistent with android studio default run : <p>I've configured gradle for signing with:</p>
<pre><code>android {
...
signingConfigs{
debug {
storeFile file("...");
storePassword '...'
keyAlias '...'
keyPassword '...'
}
}
}
</code></pre>
<p>Now when I run the Gradle task installDebug the app is signed and installed correctly and I can run the app as expected. But when I run the app module (android studio default run, which is much preferred for debugging). I get the message:</p>
<pre><code>Failed to finalize session : INSTALL_FAILED_INVALID_APK:
/data/app/vmdl2083307194.tmp/1_slice__ signatures are inconsistent
</code></pre>
<p>This happens even when No apk is yet installed.</p>
<p>I think it has to do with android studio splitting the apk improperly. So if nobody knows how to make it sign correctly a way to keep android studio from splitting the apk will probably also work.</p>
| 0debug |
Code for C# that allows you to Sum all Quantity from SQL Database with only name Condition without using datagridview : <p>Please Help. What is the code for C# Windows Form that allows you to Sum all Quantity from SQL Database with only name Condition without using Datagridview. Thanks in advance</p>
<p>This be like: Checking if how many stocks are added automatically without using tables</p>
<p>Name = wheels
Result = Total Quantity</p>
| 0debug |
JSON Web Token (JWT) as a url for email activation : <p>How secure it is to make JWT as the activation url in email?</p>
<p>For example:
Click link to activate your account
<a href="http://127.0.0.1:8000/account/activate/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0b3B0YWwuY29tIiwiZXhwIjoxNDI2NDIwODAwLCJodHRwOi8vdG9wdGFsLmNvbS9qd3RfY2xhaW1zL2lzX2FkbWluIjp0cnVlLCJjb21wYW55IjoiVG9wdGFsIiwiYXdlc29tZSI6dHJ1ZX0.yRQYnWzskCZUxPwaQupWkiUzKELZ49eM7oWxAQK_ZXw" rel="noreferrer">http://127.0.0.1:8000/account/activate/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0b3B0YWwuY29tIiwiZXhwIjoxNDI2NDIwODAwLCJodHRwOi8vdG9wdGFsLmNvbS9qd3RfY2xhaW1zL2lzX2FkbWluIjp0cnVlLCJjb21wYW55IjoiVG9wdGFsIiwiYXdlc29tZSI6dHJ1ZX0.yRQYnWzskCZUxPwaQupWkiUzKELZ49eM7oWxAQK_ZXw</a></p>
| 0debug |
Why, when I print a derefrenced pointer in main that points to a variable declared in a function, does it not print junk memory. (GOLANG) : package main
2
3 import "fmt"
4
5
6 func point(x int) *int {
7
8 y := x
9 return &y
10
11 }
12
13
14 func main() {
15
16 x := 10
17
18 pointer := point(x)
19
20 fmt.Println(*pointer)
21
22
23
24
25 }
Shouldn't the memory for Y be junk after the function has been called?
It prints 10 just fine.
~ | 0debug |
Color gamut in Xcode 8 : <p>Today I have installed Xcode 8(beta) and exploring Storyboards. Here we can now set background and tintColor for different traits. That's good news.</p>
<p>But here with trait collection(for example any height X any width) there is another selection of <code>gamuts</code></p>
<p>Here is the screenshot<a href="https://i.stack.imgur.com/LN8Um.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LN8Um.png" alt="enter image description here"></a></p>
<p>As I have searched for <code>gamut</code>, I found that it is related with color.
I have tried with different combination of <code>gamuts</code> but I am unable to see any difference.</p>
<p>The <a href="https://developer.apple.com/library/prerelease/content/samplecode/ColorGamutShowcase/Listings/README_md.html#//apple_ref/doc/uid/TP40017308-README_md-DontLinkElementID_8" rel="noreferrer">documentation</a> is also not helpful. </p>
<p>The question is how the developers get the benefit of this feature?</p>
| 0debug |
copy a file and change the name : i was asked to make a file copier that will change the name of the file (add "_Copy") but will keep the type of file
for example:
c:\...mike.jpg(or mp3 or any type of file)
to:
c:\...mike_Copy.jpg
here is my code :
private void btnChseFile_Click(object sender, EventArgs e)
{
prgrssBar.Minimum = 0;
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "Which file do you want to copy ?";
DialogResult fc = ofd.ShowDialog();
tbSource.Text = ofd.FileName;
tbDestination.Text = tbSource.Text + "_Copy";
} | 0debug |
static void free_packet_list(AVPacketList *pktl)
{
AVPacketList *cur;
while (pktl) {
cur = pktl;
pktl = cur->next;
av_free_packet(&cur->pkt);
av_free(cur);
}
}
| 1threat |
I have jason object But I am unabled to access 'name' element in this? :
This is the jason data
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
{"0":{"restaurant":"Bayleaf","order":"HIHUN10","delivery at":"04:43 PM 2016-06-22","type":"Home Delivery","name":"dEEPAK rAI","address":"12356,Lucknow,226010","phone":"9120276440","total":"Rs 831.60","pay by":"Cash On Delivery","picked by":"By Administrator","date":"06\/22\/2016","status":"Waiting","action":"pending"},"1":{"restaurant":"Jungliee","order":"HIHUN9","delivery at":"03:40 PM 2016-06-21","type":"Home Delivery","name":"dEEPAK rAI","address":"12356,Lucknow,226010","phone":"9120276440","total":"Rs 465.00","pay by":"Cash On Delivery","picked by":"Dummy","date":"06\/21\/2016","status":{"Accepted":1,"Processing":2,"Delivered":3,"Completed":4,"Failed":5},"action":"view"},"2":{"restaurant":"Naushijaan","order":"HIHUN8","delivery at":"11:10 AM 2016-06-18","type":"Home Delivery","name":"dEEPAK rAI","address":"12356,Lucknow,226010","phone":"9120276440","total":"Rs 545.00","pay by":"Cash On Delivery","picked by":"By Administrator","date":"06\/18\/2016","status":{"Processing":2,"Delivered":3,"Completed":4,"Failed":5},"action":"view"},"3":{"restaurant":"Aahaar","order":"HIHUN7","delivery at":"11:32 AM 2016-06-12","type":"Home Delivery","name":"sk mishra","address":"520viram khand,Lucknow,226010","phone":"9198979962","total":"Rs 450.00","pay by":"Cash On Delivery","picked by":"Dummy","date":"06\/12\/2016","status":{"Completed":4,"Failed":5},"action":"view"},"4":{"restaurant":"Bayleaf","order":"HIHUN6","delivery at":"08:29 PM 2016-06-11","type":"Home Delivery","name":"Dharmraj","address":"D-242Office G 19 Sector 63,Lucknow,201003","phone":"7428069025","total":"Rs 606.60","pay by":"Cash On Delivery","picked by":"By Administrator","date":"06\/11\/2016","status":{"Completed":4,"Failed":5},"action":"view"},"5":{"restaurant":"Bayleaf","order":"HIHUN5","delivery at":"08:17 PM 2016-06-11","type":"Home Delivery","name":"Dharmraj","address":"D-242Office G 19 Sector 63,Lucknow,201003","phone":"7428069025","total":"Rs 606.60","pay by":"Cash On Delivery","picked by":"By Administrator","date":"06\/11\/2016","status":{"Completed":4,"Failed":5},"action":"view"}}
<!-- end snippet -->
| 0debug |
static void tcg_out_ri64(TCGContext *s, int const_arg, TCGArg arg)
{
if (const_arg) {
assert(const_arg == 1);
tcg_out8(s, TCG_CONST);
tcg_out64(s, arg);
} else {
tcg_out_r(s, arg);
}
}
| 1threat |
React’s new context api with enzyme : <p>I have been using enzyme and love it a lot. It works with react 16 until I wanted to test my new project that uses react’s new context api. </p>
<p>If I render only my basic component using shallow and console log the debug of the component I can see its content but when I use the new context api with provider and consumer, I get <code><undefined /></code> as a render out. Enzyme does not render the component but react does.</p>
<p>Can someone please provide some guidance. </p>
<p>Thank you.</p>
| 0debug |
Java - Subtracting doubles gives answer * 1000 : <p>I am trying to find the difference of 2 doubles with many decimal points: </p>
<pre><code>double highest = 0.01518804243008679;
double lowest = 0.01464486209421528;
System.out.println("Difference: " + (highest - lowest));
</code></pre>
<p>And I get an answer which is correct, but is just just multiplied by 10 000: </p>
<pre><code>Difference: 5.431803358715102E-4
</code></pre>
<p>When the desired output is: </p>
<pre><code>Difference: 0.0005431803358
</code></pre>
| 0debug |
static void flush_dpb(AVCodecContext *avctx){
H264Context *h= avctx->priv_data;
int i;
for(i=0; i<16; i++)
h->delayed_pic[i]= NULL;
h->delayed_output_pic= NULL;
idr(h);
} | 1threat |
PHP - Get the current array with string : <pre><code>$form = array(
array(
'form' => 'Change Schedule',
'data' => array(
array(
'element'=>'input',
'name'=>'form-start',
'class'=>'form-control',
'type'=>'text',
'column'=>'col-md-12',
'label'=>'Schedule'
)
),
),
array(
'form' => 'Maintenance',
'data' => array(
array(
'element'=>'input',
'name'=>'form-room-place',
'class'=>'form-control',
'type'=>'text',
'column'=>'col-md-12',
'label'=>'Room # / Place'
)
),
),
);
</code></pre>
<p>This is the <code>array</code> I made, I wanted to get the array with <code>form</code> = <code>Maintenance</code> only. Is this possible with <code>php</code> to get the array via <code>string arrays</code> I want to pass?</p>
<p>My attempt:
<code>$form(('form'=>'Change Dormitory'));</code></p>
| 0debug |
int ff_vorbiscomment_write(uint8_t **p, AVDictionary **m,
const char *vendor_string)
{
bytestream_put_le32(p, strlen(vendor_string));
bytestream_put_buffer(p, vendor_string, strlen(vendor_string));
if (*m) {
int count = av_dict_count(*m);
AVDictionaryEntry *tag = NULL;
bytestream_put_le32(p, count);
while ((tag = av_dict_get(*m, "", tag, AV_DICT_IGNORE_SUFFIX))) {
unsigned int len1 = strlen(tag->key);
unsigned int len2 = strlen(tag->value);
bytestream_put_le32(p, len1+1+len2);
bytestream_put_buffer(p, tag->key, len1);
bytestream_put_byte(p, '=');
bytestream_put_buffer(p, tag->value, len2);
}
} else
bytestream_put_le32(p, 0);
return 0;
}
| 1threat |
connection.query('SELECT * FROM users WHERE username = ' + input_string) | 1threat |
static bool tcg_out_opc_jmp(TCGContext *s, MIPSInsn opc, void *target)
{
uintptr_t dest = (uintptr_t)target;
uintptr_t from = (uintptr_t)s->code_ptr + 4;
int32_t inst;
if ((from ^ dest) & -(1 << 28)) {
return false;
}
assert((dest & 3) == 0);
inst = opc;
inst |= (dest >> 2) & 0x3ffffff;
tcg_out32(s, inst);
return true;
}
| 1threat |
static int nbd_send_rep(int csock, uint32_t type, uint32_t opt)
{
uint64_t magic;
uint32_t len;
magic = cpu_to_be64(NBD_REP_MAGIC);
if (write_sync(csock, &magic, sizeof(magic)) != sizeof(magic)) {
LOG("write failed (rep magic)");
return -EINVAL;
}
opt = cpu_to_be32(opt);
if (write_sync(csock, &opt, sizeof(opt)) != sizeof(opt)) {
LOG("write failed (rep opt)");
return -EINVAL;
}
type = cpu_to_be32(type);
if (write_sync(csock, &type, sizeof(type)) != sizeof(type)) {
LOG("write failed (rep type)");
return -EINVAL;
}
len = cpu_to_be32(0);
if (write_sync(csock, &len, sizeof(len)) != sizeof(len)) {
LOG("write failed (rep data length)");
return -EINVAL;
}
return 0;
}
| 1threat |
static inline void mix_3f_to_mono(AC3DecodeContext *ctx)
{
int i;
float (*output)[256] = ctx->audio_block.block_output;
for (i = 0; i < 256; i++)
output[1][i] += (output[2][i] + output[3][i]);
memset(output[2], 0, sizeof(output[2]));
memset(output[3], 0, sizeof(output[3]));
}
| 1threat |
React Native: Can't see console.logs when I run application from XCode : <p>I'm struggling to get my code working with <code>react-native run-ios</code>. The native code is pulling some old cached version of the javascript bundle, and I can't seem to clear that to save my life.</p>
<p>When I run the application from XCode however, the application runs just fine. Awesome!</p>
<p>The only problem is that when I run my application through XCode, I can't seem to access the javascript logs. I've tried <code>react-native log-ios</code> but that doesn't seem to show my logs. I've tried "Enabling debugging in Chrome" from the simulator menu, but this option isn't available to me when I run the app from XCode.</p>
<p>Does anybody have any thoughts on what might be going on here?</p>
| 0debug |
static void virtio_pci_device_plugged(DeviceState *d)
{
VirtIOPCIProxy *proxy = VIRTIO_PCI(d);
VirtioBusState *bus = &proxy->bus;
uint8_t *config;
uint32_t size;
config = proxy->pci_dev.config;
if (proxy->class_code) {
pci_config_set_class(config, proxy->class_code);
}
pci_set_word(config + PCI_SUBSYSTEM_VENDOR_ID,
pci_get_word(config + PCI_VENDOR_ID));
pci_set_word(config + PCI_SUBSYSTEM_ID, virtio_bus_get_vdev_id(bus));
config[PCI_INTERRUPT_PIN] = 1;
if (proxy->nvectors &&
msix_init_exclusive_bar(&proxy->pci_dev, proxy->nvectors, 1)) {
error_report("unable to init msix vectors to %" PRIu32,
proxy->nvectors);
proxy->nvectors = 0;
}
proxy->pci_dev.config_write = virtio_write_config;
size = VIRTIO_PCI_REGION_SIZE(&proxy->pci_dev)
+ virtio_bus_get_vdev_config_len(bus);
if (size & (size - 1)) {
size = 1 << qemu_fls(size);
}
memory_region_init_io(&proxy->bar, OBJECT(proxy), &virtio_pci_config_ops,
proxy, "virtio-pci", size);
pci_register_bar(&proxy->pci_dev, 0, PCI_BASE_ADDRESS_SPACE_IO,
&proxy->bar);
if (!kvm_has_many_ioeventfds()) {
proxy->flags &= ~VIRTIO_PCI_FLAG_USE_IOEVENTFD;
}
proxy->host_features |= 0x1 << VIRTIO_F_NOTIFY_ON_EMPTY;
proxy->host_features |= 0x1 << VIRTIO_F_BAD_FEATURE;
proxy->host_features = virtio_bus_get_vdev_features(bus,
proxy->host_features);
}
| 1threat |
Vue.js display one data at a time from an array : <p>My requirement is something like this</p>
<ol>
<li>I have an array with few names.</li>
<li>I want to take first name from this array and display it inside the
div. After that I want to display the second name then third...</li>
<li>I want this to happen as an infinite loop and names should be changed after a one minute of time.</li>
</ol>
<p>How do I achieve this <strong>using Vue.js</strong></p>
<pre><code><template>
<div class="">
</div>
</template>
<script>
export default {
name: 'app',
data () {
return {
names:["Jona","Jane","Kalana"]
}
}
}
</script>
</code></pre>
| 0debug |
How to extract the Photo/Video component of a MVIMG? : <p>The Google Pixel 2 and probably other phones since have the capability to cover "Motion Photos". These are saved as MVIMG and comparatively big.</p>
<p>I’m looking for a way to remove/extract the video.</p>
<p>So far I found a promising exif tag</p>
<pre><code>$ exiftool -xmp:all MVIMG_123.jpg
XMP Toolkit : Adobe XMP Core 5.1.0-jc003
Micro Video : 1
Micro Video Version : 1
Micro Video Offset : 4032524
</code></pre>
<p>I thought the video might be present at the specified offset, but this doesn’t work:</p>
<pre><code>$ dd if=MVIMG_123.jpg of=video.mp4 bs=4032524 skip=1
$ file video.mp4
video.mp4: data
</code></pre>
<p>Are there any resources that document the embedding? Are there even any tools to remove/extract the video?</p>
| 0debug |
How to make a phone call in Xamarin.Forms by clicking on a label? : <p>Hello I have an app i'm working on in Xamarin.Forms that gets contact info from a web service and then displays that info in labels however I want to make the label that lists the phone number to make a call when clicked. How do I go about doing this?</p>
<p>Heres in my XAML:</p>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ReadyMo.ContactInfo">
<ContentPage.Content>
<Frame Padding="0,0,0,8" BackgroundColor="#d2d5d7">
<Frame.Content>
<Frame Padding="15,15,15,15" OutlineColor="Gray" BackgroundColor="White">
<Frame.Content>
<ScrollView Orientation="Vertical" VerticalOptions="FillAndExpand">
<StackLayout Padding="20,0,0,0" Orientation="Horizontal" HorizontalOptions="CenterAndExpand">
<StackLayout Orientation="Vertical" VerticalOptions="FillAndExpand">
<Label Text="Emergency Coordinators" HorizontalOptions="Center" FontFamily="OpenSans-Light"
FontSize="20"
TextColor="#69add1">
</Label>
<Label x:Name="CountyName" HorizontalOptions="Center" FontFamily="OpenSans-Light"
FontSize="16"
TextColor="#69add1">
</Label>
<Label x:Name="FirstName" HorizontalOptions="Center">
</Label>
<Label x:Name ="LastName" HorizontalOptions="Center">
</Label>
<Label x:Name="County" HorizontalOptions="Center">
</Label>
<Label x:Name ="Adress" HorizontalOptions="Center">
</Label>
<Label x:Name ="City" HorizontalOptions="Center">
</Label>
//This is the label that displays the phone number!
<Label x:Name="Number" HorizontalOptions="Center">
</Label>
</StackLayout>
</StackLayout>
</ScrollView>
</Frame.Content>
</Frame>
</Frame.Content>
</Frame>
</ContentPage.Content>
</ContentPage>
</code></pre>
<p>heres my code behind:</p>
<pre><code>using Newtonsoft.Json;
using ReadyMo.Data;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace ReadyMo
{
public partial class ContactInfo : ContentPage
{
private County item;
public ContactInfo()
{
InitializeComponent();
var contactpagetext = ContactManager.GetContactString(item.id);
}
public ContactInfo(County item)
{
InitializeComponent();
this.item = item;
//var contactpagetext = ContactManager.GetContactString(item.id).Result;
//Emergency Coordinators Code
ContactInfoModel TheContactInfo = ContactManager.CurrentContactInfo;
CountyName.Text = TheContactInfo.name;
FirstName.Text = TheContactInfo.First_Name;
LastName.Text = TheContactInfo.Last_Name;
Adress.Text = TheContactInfo.Address1;
City.Text = TheContactInfo.Address2;
Number.Text = TheContactInfo.BusinessPhone;
}
}
}
</code></pre>
<p>Thanks in advance!</p>
| 0debug |
static int x86_cpu_filter_features(X86CPU *cpu)
{
CPUX86State *env = &cpu->env;
FeatureWord w;
int rv = 0;
for (w = 0; w < FEATURE_WORDS; w++) {
uint32_t host_feat =
x86_cpu_get_supported_feature_word(w, false);
uint32_t requested_features = env->features[w];
env->features[w] &= host_feat;
cpu->filtered_features[w] = requested_features & ~env->features[w];
if (cpu->filtered_features[w]) {
rv = 1;
}
}
return rv;
}
| 1threat |
void cpu_dump_statistics (CPUState *env, FILE*f,
int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
int flags)
{
#if defined(DO_PPC_STATISTICS)
opc_handler_t **t1, **t2, **t3, *handler;
int op1, op2, op3;
t1 = env->opcodes;
for (op1 = 0; op1 < 64; op1++) {
handler = t1[op1];
if (is_indirect_opcode(handler)) {
t2 = ind_table(handler);
for (op2 = 0; op2 < 32; op2++) {
handler = t2[op2];
if (is_indirect_opcode(handler)) {
t3 = ind_table(handler);
for (op3 = 0; op3 < 32; op3++) {
handler = t3[op3];
if (handler->count == 0)
continue;
cpu_fprintf(f, "%02x %02x %02x (%02x %04d) %16s: "
"%016" PRIx64 " %" PRId64 "\n",
op1, op2, op3, op1, (op3 << 5) | op2,
handler->oname,
handler->count, handler->count);
}
} else {
if (handler->count == 0)
continue;
cpu_fprintf(f, "%02x %02x (%02x %04d) %16s: "
"%016" PRIx64 " %" PRId64 "\n",
op1, op2, op1, op2, handler->oname,
handler->count, handler->count);
}
}
} else {
if (handler->count == 0)
continue;
cpu_fprintf(f, "%02x (%02x ) %16s: %016" PRIx64
" %" PRId64 "\n",
op1, op1, handler->oname,
handler->count, handler->count);
}
}
#endif
}
| 1threat |
void net_slirp_redir(const char *redir_str)
{
int is_udp;
char buf[256], *r;
const char *p;
struct in_addr guest_addr;
int host_port, guest_port;
if (!slirp_inited) {
slirp_inited = 1;
slirp_init(0, NULL);
}
p = redir_str;
if (get_str_sep(buf, sizeof(buf), &p, ':') < 0)
goto fail;
if (!strcmp(buf, "tcp")) {
is_udp = 0;
} else if (!strcmp(buf, "udp")) {
is_udp = 1;
} else {
goto fail;
}
if (get_str_sep(buf, sizeof(buf), &p, ':') < 0)
goto fail;
host_port = strtol(buf, &r, 0);
if (r == buf)
goto fail;
if (get_str_sep(buf, sizeof(buf), &p, ':') < 0)
goto fail;
if (buf[0] == '\0') {
pstrcpy(buf, sizeof(buf), "10.0.2.15");
}
if (!inet_aton(buf, &guest_addr))
goto fail;
guest_port = strtol(p, &r, 0);
if (r == p)
goto fail;
if (slirp_redir(is_udp, host_port, guest_addr, guest_port) < 0) {
fprintf(stderr, "qemu: could not set up redirection\n");
exit(1);
}
return;
fail:
fprintf(stderr, "qemu: syntax: -redir [tcp|udp]:host-port:[guest-host]:guest-port\n");
exit(1);
}
| 1threat |
static inline void vhost_dev_log_resize(struct vhost_dev* dev, uint64_t size)
{
vhost_log_chunk_t *log;
uint64_t log_base;
int r;
if (size) {
log = g_malloc0(size * sizeof *log);
} else {
log = NULL;
}
log_base = (uint64_t)(unsigned long)log;
r = ioctl(dev->control, VHOST_SET_LOG_BASE, &log_base);
assert(r >= 0);
vhost_client_sync_dirty_bitmap(&dev->client, 0,
(target_phys_addr_t)~0x0ull);
if (dev->log) {
g_free(dev->log);
}
dev->log = log;
dev->log_size = size;
}
| 1threat |
IdentityUserLogin<string>' requires a primary key to be defined error while adding migration : <p>I am using 2 different Dbcontexts. i want to use 2 different databases users and mycontext. While doing that i am getting a error The entity type 'Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserLogin' requires a primary key to be defined. I think there is something wrong with IdentityUser please suggest me where can i change my code so that i can add migration.</p>
<p>My Dbcontext class:</p>
<pre><code> class MyContext : DbContext
{
public DbSet<Post> Posts { get; set; }
public DbSet<Tag> Tags { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<PostTag>()
.HasKey(t => new { t.PostId, t.TagId });
modelBuilder.Entity<PostTag>()
.HasOne(pt => pt.Post)
.WithMany(p => p.PostTags)
.HasForeignKey(pt => pt.PostId);
modelBuilder.Entity<PostTag>()
.HasOne(pt => pt.Tag)
.WithMany(t => t.PostTags)
.HasForeignKey(pt => pt.TagId);
}
}
public class Post
{
public int PostId { get; set; }
public string Title { get; set; }
public AppUser User {get; set;}
public string Content { get; set; }
public List<PostTag> PostTags { get; set; }
}
public class Tag
{
public string TagId { get; set; }
public List<PostTag> PostTags { get; set; }
}
public class PostTag
{
public int PostId { get; set; }
public Post Post { get; set; }
public string TagId { get; set; }
public Tag Tag { get; set; }
}
</code></pre>
<p>and AppUser class:</p>
<pre><code>public class AppUser : IdentityUser
{
//some other propeties
}
</code></pre>
<p>when I try to Add migration the following error occurs.</p>
<pre><code>The entity type 'Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserLogin<string>' requires a primary key to be defined.
</code></pre>
<p>give me solution to resolve the issue..</p>
| 0debug |
ssize_t qemu_paio_return(struct qemu_paiocb *aiocb)
{
ssize_t ret;
pthread_mutex_lock(&lock);
ret = aiocb->ret;
pthread_mutex_unlock(&lock);
return ret;
}
| 1threat |
Why can't I parse "0-2-6-1" to ints after splitting by '-' : <p>Reading from an Excel Worksheet that was copy and pasted with a list of string speperated numbers, why will c# not convert a char/string 0 to a zero or a char/string 1 to an int 1 after splitting the string into an array by '-'? </p>
<p>It seems like there is a character problem, the difference between a 1 and a 1 with no line at the bottom?</p>
<p>Thanks</p>
| 0debug |
HTML/CSS layout design help? How can I center this slideshow? : I need some help regarding the layout of my website. Basically, **I'm trying to center the Js slideshow & "Slideshow header" that you can see in image left.** Below you can see what my website looks like on the left and on the right is how I want to center my slideshow.
[Website][1]
I tried adding "text-align: center;" to my css but nothing changes. I'm clueless
Some help would be appreciated!
**PS: Sorry for using screenshots instead of block codes.**Getting errors while adding my snippets**
[HTML][2]
[CSS CODE][1]
[1]: https://i.stack.imgur.com/LJWyE.png
[2]: https://i.stack.imgur.com/nCSnF.png | 0debug |
int bdrv_all_create_snapshot(QEMUSnapshotInfo *sn,
BlockDriverState *vm_state_bs,
uint64_t vm_state_size,
BlockDriverState **first_bad_bs)
{
int err = 0;
BlockDriverState *bs;
BdrvNextIterator it;
for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
AioContext *ctx = bdrv_get_aio_context(bs);
aio_context_acquire(ctx);
if (bs == vm_state_bs) {
sn->vm_state_size = vm_state_size;
err = bdrv_snapshot_create(bs, sn);
} else if (bdrv_can_snapshot(bs)) {
sn->vm_state_size = 0;
err = bdrv_snapshot_create(bs, sn);
}
aio_context_release(ctx);
if (err < 0) {
goto fail;
}
}
fail:
*first_bad_bs = bs;
return err;
} | 1threat |
What are the benefits of C# 7 local functions over lambdas? : <p>The other day in one of my utilities, ReSharper hinted me about the piece of code below stating that lambda defining the delegate <code>ThreadStart</code> can be turned into a local function:</p>
<pre><code>public void Start(ThreadPriority threadPriority = ThreadPriority.Lowest)
{
if (!Enabled)
{
_threadCancellationRequested = false;
ThreadStart threadStart = () => NotificationTimer (ref _interval, ref _ignoreDurationThreshold, ref _threadCancellationRequested);
Thread = new Thread(threadStart) {Priority = ThreadPriority.Lowest};
Thread.Start();
}
}
</code></pre>
<p>And hence transformed into:</p>
<pre><code>public void Start(ThreadPriority threadPriority = ThreadPriority.Lowest)
{
if (!Enabled)
{
_threadCancellationRequested = false;
void ThreadStart() => NotificationTimer(ref _interval, ref _ignoreDurationThreshold, ref _threadCancellationRequested);
Thread = new Thread(ThreadStart) {Priority = ThreadPriority.Lowest};
Thread.Start();
}
}
</code></pre>
<p>What are the benefits of the latter over the former, is it only about performance?</p>
<p>I've already checked the resources below but in my example the benefits are not that obvious:</p>
<ul>
<li><a href="https://asizikov.github.io/2016/04/15/thoughts-on-local-functions/" rel="noreferrer">https://asizikov.github.io/2016/04/15/thoughts-on-local-functions/</a></li>
<li><a href="https://www.infoworld.com/article/3182416/application-development/c-7-in-depth-exploring-local-functions.html" rel="noreferrer">https://www.infoworld.com/article/3182416/application-development/c-7-in-depth-exploring-local-functions.html</a></li>
</ul>
| 0debug |
How to configure Lombok with maven-compiler-plugin? : <p>I have a root module and submodule in maven in the project. I am trying to use Lombok.
I have added </p>
<pre><code><dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.12</version>
<scope>provided</scope>
</dependency>
</code></pre>
<p>to root pom.xml.
In submodule I have a class with Lombok annotations.
When I am trying to build the project I get a lot of </p>
<blockquote>
<p>cannot find symbol</p>
</blockquote>
<p>where I am trying to call getters and setters. </p>
<p>I have tried to use <strong>lombok-maven-plugin</strong> with same version (1.16.12) in root pom and in the sub pom as well with delombok and moving my annotated class to src/main/lombok, I have looked through almost all questions in SO, try all the variants, but not succeed.</p>
<p>I am using Maven 3, Java 8, maven-compiler-plugin with 3.6.1 version.</p>
<p>How should I configure the project to be able to use lombok? Or maybe I am doing smth wrong.</p>
| 0debug |
Unable to predict test dataset : I have a training data set with the below variables
> str(PairsTrain)
'data.frame': 1495698 obs. of 4 variables:
$ itemID_1 : int 1 4 8 12 15 19 20 20 22 26 ...
$ itemID_2 : int 4112648 1223296 2161930 5637025 113701
$ isDuplicate : int 1 0 1 0 0 0 0 0 1 0 ...
$ generationMethod: int 1 1 1 1 1 1 1 1 1 1 ...
I have learned from this dataset using the logistic regression glm() function
`mod1 <- glm(isDuplicate ~., data = PairsTrain, family = binomial)`
Below is the structure of m y test dataset
> str(Test)
'data.frame': 1044196 obs. of 3 variables:
$ id : int 0 1 2 3 4 5 6 7 8 9 ...
$ itemID_1: int 5 5 6 11 23 23 30 31 36 47 ...
$ itemID_2: int 4670875 787210 1705280 3020777 5316130 3394969 2922567
I am trying to make predictions on my test data set like below
> `PredTest <- predict(mod1, newdata = Test, type = "response")`
Error in eval(expr, envir, enclos) : object 'generationMethod' not found
I get the above error, I am thinking that the reason for the error I am getting is the number of features in my test dataset which doesn't match the training dataset. I am not sure if I am correct and I am stuck here and don't know how to deal this situation. Any help is much appreciated.
//Sam | 0debug |
user registration form without entity framework using MVC : [HttpPost]
public ActionResult Create(UserModel userModel)
{
using (SqlConnection sqlCon= new SqlConnection(connectionString))
{
sqlCon.Open();
String query = "INSERT INTO User VALUES(@UserName,@UserPassword,@UserAddress)";
SqlCommand sqlCmd = new SqlCommand(query,sqlCon);
sqlCmd.Parameters.AddWithValue("@UserName",userModel.username);
sqlCmd.Parameters.AddWithValue("@UserPassword", userModel.userpassword);
sqlCmd.Parameters.AddWithValue("@UserAddress", userModel.useraddress);
sqlCmd.ExecuteNonQuery();
}
return RedirectToAction("Index");
}
I'm learning C#.So I tried to code CURD operations.In this code there is is a Open() method..I want to know Why it used and explain line bye line what is code flow.. | 0debug |
can i scan objects like fruits, vegetables, non vegetables and flowers with camera in android? : <blockquote>
<p>I want to make an android app to check the freshness of fruits,vegetables, non vegetables and flowers. I want to scan all these with camera and provide details to user after scanning. Can anyone please give me suggestion about it. I will be really thankful.</p>
</blockquote>
| 0debug |
void cpu_outw(pio_addr_t addr, uint16_t val)
{
LOG_IOPORT("outw: %04"FMT_pioaddr" %04"PRIx16"\n", addr, val);
trace_cpu_out(addr, val);
ioport_write(1, addr, val);
}
| 1threat |
static void get_seg(SegmentCache *lhs, const struct kvm_segment *rhs)
{
lhs->selector = rhs->selector;
lhs->base = rhs->base;
lhs->limit = rhs->limit;
lhs->flags =
(rhs->type << DESC_TYPE_SHIFT)
| (rhs->present * DESC_P_MASK)
| (rhs->dpl << DESC_DPL_SHIFT)
| (rhs->db << DESC_B_SHIFT)
| (rhs->s * DESC_S_MASK)
| (rhs->l << DESC_L_SHIFT)
| (rhs->g * DESC_G_MASK)
| (rhs->avl * DESC_AVL_MASK);
}
| 1threat |
Xquery with dynamic Index : i am trying to use Xquery in Sql Server, but i need that the index be dynamic:
This is my query:
<code>
SELECT cast(yourXML as XML).value('(/integracao/item/NumPedido)[1]','VARCHAR(MAX)') NumPedido
FROM #xml
</code>
what i have tried:
<code>
SELECT cast(yourXML as XML).value('(/integracao/item/NumPedido)[sql:variable("@index")]','VARCHAR(MAX)') NumPedido
FROM #xml
</code>
But it returns me the error:
XQuery [#xml.yourXML.value()]: 'value()' requires a singleton (or empty sequence), found operand of type 'xdt:untypedAtomic *'
Somebody can help me please?
| 0debug |
Avoid `logger=logging.getLogger(__name__)` without loosing : I am lazy and want to avoid this line in every python file which uses logging:
logger = logging.getLogger(__name__)
In january I asked how this could be done, and found an answer: http://stackoverflow.com/questions/34726515/avoid-logger-logging-getlogger-name
Unfortunately the answer there has the drawback, that you loose the ability to filter.
I really want to avoid this useless and redundant line.
Example:
import logging
def my_method(foo):
logging.info()
Unfortunately I think it is impossible do `logger = logging.getLogger(__name__)` implicitly if `logging.info()` gets called for the first time in this file.
Is there anybody out there who knows how to do impossible stuff?
| 0debug |
static bool check_section_footer(QEMUFile *f, SaveStateEntry *se)
{
uint8_t read_mark;
uint32_t read_section_id;
if (skip_section_footers) {
return true;
}
read_mark = qemu_get_byte(f);
if (read_mark != QEMU_VM_SECTION_FOOTER) {
error_report("Missing section footer for %s", se->idstr);
return false;
}
read_section_id = qemu_get_be32(f);
if (read_section_id != se->section_id) {
error_report("Mismatched section id in footer for %s -"
" read 0x%x expected 0x%x",
se->idstr, read_section_id, se->section_id);
return false;
}
return true;
}
| 1threat |
JQUERY - using has class to show/hide rows results in lag and performance hit : I have a quite large html table that I am showing/hiding rows based on their class. The code works as desired, but there is around a 10 second lag/freeze of the client. Any help or pointers on fixing this performance issue would be appreciated. Please note amount of departments in my example could be dynamic, hence some of the reasoning of the crazy table structure.
Here is my [JSFIDDLE][1]
$(function() {
$("#deptOpt").on('change', function() {
var dept = $(this).prop('selectedIndex');
$("#scLDP > tbody > tr").each(function() {
var x = $(this);
switch (dept) {
case 0:
$("#scLDP > tbody > tr").show();
break;
default:
$("#scLDP > tbody > tr").hide();
$("#scLDP > tbody > .onHand.dept" + dept).prev().prev().show();
$("#scLDP > tbody > .onHand.dept" + dept).prev().show();
$("#scLDP > tbody > .onHand.dept" + dept).show();
$("#scLDP > tbody > .onHandQ.dept" + dept).show();
$("#scLDP > tbody > .poss.dept" + dept).show();
$("#scLDP > tbody > .posq.dept" + dept).show();
$("#scLDP > tbody > .wos.dept" + dept).show();
$("#scLDP > tbody > .stP.dept" + dept).show();
$("#scLDP > tbody > .twmd.dept" + dept).show();
$("#scLDP > tbody > .grandT").show();
$("#scLDP > tbody > .onHandGrand").show();
$("#scLDP > tbody > .onHandQGrand").show();
$("#scLDP > tbody > .possGrand").show();
$("#scLDP > tbody > .posqGrand").show();
$("#scLDP > tbody > .wosGrand").show();
$("#scLDP > tbody > .stpGrand").show();
$("#scLDP > tbody > .twmdGrand").show();
break;
}
})
})
})
[1]: https://jsfiddle.net/khemikal/qxdwrq7x/8/ | 0debug |
Filter through an array of objects : <p>Having an array of objects with this structure<a href="https://i.stack.imgur.com/hJRWZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hJRWZ.png" alt="enter image description here"></a>
My question is how should a filter it to return, for example, only the objects with meterName = "Bay-3". That hexadecimal header at each object tangles me.</p>
| 0debug |
static void virtio_blk_migration_state_changed(Notifier *notifier, void *data)
{
VirtIOBlock *s = container_of(notifier, VirtIOBlock,
migration_state_notifier);
MigrationState *mig = data;
Error *err = NULL;
if (migration_in_setup(mig)) {
if (!s->dataplane) {
return;
}
virtio_blk_data_plane_destroy(s->dataplane);
s->dataplane = NULL;
} else if (migration_has_finished(mig) ||
migration_has_failed(mig)) {
if (s->dataplane) {
return;
}
bdrv_drain_all();
virtio_blk_data_plane_create(VIRTIO_DEVICE(s), &s->conf,
&s->dataplane, &err);
if (err != NULL) {
error_report("%s", error_get_pretty(err));
error_free(err);
}
}
}
| 1threat |
static int decode_frame_png(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
PNGDecContext *const s = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AVFrame *p;
int64_t sig;
int ret;
ff_thread_release_buffer(avctx, &s->last_picture);
FFSWAP(ThreadFrame, s->picture, s->last_picture);
p = s->picture.f;
bytestream2_init(&s->gb, buf, buf_size);
sig = bytestream2_get_be64(&s->gb);
if (sig != PNGSIG &&
sig != MNGSIG) {
av_log(avctx, AV_LOG_ERROR, "Invalid PNG signature 0x%08"PRIX64".\n", sig);
return AVERROR_INVALIDDATA;
}
s->y = s->has_trns = 0;
s->hdr_state = 0;
s->pic_state = 0;
s->zstream.zalloc = ff_png_zalloc;
s->zstream.zfree = ff_png_zfree;
s->zstream.opaque = NULL;
ret = inflateInit(&s->zstream);
if (ret != Z_OK) {
av_log(avctx, AV_LOG_ERROR, "inflateInit returned error %d\n", ret);
return AVERROR_EXTERNAL;
}
if ((ret = decode_frame_common(avctx, s, p, avpkt)) < 0)
goto the_end;
if (avctx->skip_frame == AVDISCARD_ALL) {
*got_frame = 0;
ret = bytestream2_tell(&s->gb);
goto the_end;
}
if ((ret = av_frame_ref(data, s->picture.f)) < 0)
return ret;
*got_frame = 1;
ret = bytestream2_tell(&s->gb);
the_end:
inflateEnd(&s->zstream);
s->crow_buf = NULL;
return ret;
}
| 1threat |
Efficiently mapping one-to-many many-to-many database to struct in Golang : <h1>Question</h1>
<p>When dealing with a one-to-many or many-to-many SQL relationship in Golang, what is the best (efficient, recommended, "Go-like") way of mapping the rows to a struct?</p>
<p>Taking the example setup below I have tried to detail some approaches with Pros and Cons of each but was wondering what the community recommends.</p>
<h1>Requirements</h1>
<ul>
<li>Works with PostgreSQL (can be generic but not include MySQL/Oracle specific features)</li>
<li>Efficiency - No brute forcing every combination</li>
<li>No ORM - Ideally using only <code>database/sql</code> and <code>jmoiron/sqlx</code></li>
</ul>
<h1>Example</h1>
<p><em>For sake of clarity I have removed error handling</em></p>
<p><strong>Models</strong></p>
<pre class="lang-golang prettyprint-override"><code>type Tag struct {
ID int
Name string
}
type Item struct {
ID int
Tags []Tag
}
</code></pre>
<p><strong>Database</strong></p>
<pre class="lang-sql prettyprint-override"><code>CREATE TABLE item (
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY
);
CREATE TABLE tag (
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
name VARCHAR(160),
item_id INT REFERENCES item(id)
);
</code></pre>
<p><strong>Approach 1 - Select all Items, then select tags per item</strong></p>
<pre class="lang-golang prettyprint-override"><code>var items []Item
sqlxdb.Select(&items, "SELECT * FROM item")
for i, item := range items {
var tags []Tag
sqlxdb.Select(&tags, "SELECT * FROM tag WHERE item_id = $1", item.ID)
items[i].Tags = tags
}
</code></pre>
<p><em>Pros</em></p>
<ul>
<li>Simple</li>
<li>Easy to understand</li>
</ul>
<p><em>Cons</em></p>
<ul>
<li>Inefficient with the number of database queries increasing proportional with number of items</li>
</ul>
<p><strong>Approach 2 - Construct SQL join and loop through rows manually</strong></p>
<pre class="lang-golang prettyprint-override"><code>var itemTags = make(map[int][]Tag)
var items = []Item{}
rows, _ := sqlxdb.Queryx("SELECT i.id, t.id, t.name FROM item AS i JOIN tag AS t ON t.item_id = i.id")
for rows.Next() {
var (
itemID int
tagID int
tagName string
)
rows.Scan(&itemID, &tagID, &tagName)
if tags, ok := itemTags[itemID]; ok {
itemTags[itemID] = append(tags, Tag{ID: tagID, Name: tagName,})
} else {
itemTags[itemID] = []Tag{Tag{ID: tagID, Name: tagName,}}
}
}
for itemID, tags := range itemTags {
items = append(Item{
ID: itemID,
Tags: tags,
})
}
</code></pre>
<p><em>Pros</em></p>
<ul>
<li>A single database call and cursor that can be looped through without eating too much memory</li>
</ul>
<p><em>Cons</em></p>
<ul>
<li>Complicated and harder to develop with multiple joins and many attributes on the struct</li>
<li>Not too performant; more memory usage and processing time vs. more network calls</li>
</ul>
<p><strong>Failed approach 3 - sqlx struct scanning</strong></p>
<p>Despite failing I want to include this approach as I find it to be my current aim of efficiency paired with development simplicity. My hope was by explicitly setting the <code>db</code> tag on each struct field <code>sqlx</code> could do some advanced struct scanning </p>
<pre class="lang-golang prettyprint-override"><code>var items []Item
sqlxdb.Select(&items, "SELECT i.id AS item_id, t.id AS tag_id, t.name AS tag_name FROM item AS i JOIN tag AS t ON t.item_id = i.id")
</code></pre>
<p>Unfortunately this errors out as <code>missing destination name tag_id in *[]Item</code> leading me to believe the <code>StructScan</code> is not advanced enough to recursively loop through rows (no criticism - it is a complicated scenario)</p>
<p><strong>Possible approach 4 - PostgreSQL array aggregators and <code>GROUP BY</code></strong></p>
<p>While I am sure this will <em>not</em> work I have included this untested option to see if it could be improved upon so it <em>may</em> work.</p>
<pre class="lang-golang prettyprint-override"><code>var items = []Item{}
sqlxdb.Select(&items, "SELECT i.id as item_id, array_agg(t.*) as tags FROM item AS i JOIN tag AS t ON t.item_id = i.id GROUP BY i.id")
</code></pre>
<p>When I have some time I will try and run some experiments here. </p>
| 0debug |
Easy way to sort DOM? : <p>I'm really new to JS and i'm trying to sort this code from the higher user_mmr to lowest.</p>
<pre><code> <table>
<tr class="user"><td class="user_name">Kyun#294</td><td class="user_mmr">4837</td>
<tr class="user">
<td class="user_name">MiR#350</td>
<td class="user_mmr">4143</td>
</code></pre>
<p>There's any way to do something like that?</p>
| 0debug |
def geometric_sum(n):
if n < 0:
return 0
else:
return 1 / (pow(2, n)) + geometric_sum(n - 1) | 0debug |
static uint32_t nabm_readl (void *opaque, uint32_t addr)
{
PCIAC97LinkState *d = opaque;
AC97LinkState *s = &d->ac97;
AC97BusMasterRegs *r = NULL;
uint32_t index = addr - s->base[1];
uint32_t val = ~0U;
switch (index) {
case PI_BDBAR:
case PO_BDBAR:
case MC_BDBAR:
r = &s->bm_regs[GET_BM (index)];
val = r->bdbar;
dolog ("BMADDR[%d] -> %#x\n", GET_BM (index), val);
break;
case PI_CIV:
case PO_CIV:
case MC_CIV:
r = &s->bm_regs[GET_BM (index)];
val = r->civ | (r->lvi << 8) | (r->sr << 16);
dolog ("CIV LVI SR[%d] -> %#x, %#x, %#x\n", GET_BM (index),
r->civ, r->lvi, r->sr);
break;
case PI_PICB:
case PO_PICB:
case MC_PICB:
r = &s->bm_regs[GET_BM (index)];
val = r->picb | (r->piv << 16) | (r->cr << 24);
dolog ("PICB PIV CR[%d] -> %#x %#x %#x %#x\n", GET_BM (index),
val, r->picb, r->piv, r->cr);
break;
case GLOB_CNT:
val = s->glob_cnt;
dolog ("glob_cnt -> %#x\n", val);
break;
case GLOB_STA:
val = s->glob_sta | GS_S0CR;
dolog ("glob_sta -> %#x\n", val);
break;
default:
dolog ("U nabm readl %#x -> %#x\n", addr, val);
break;
}
return val;
}
| 1threat |
how to insert tab in a sequential word in python : nowadays I met a problem that I have a very large txt file which looks like following:
- A T T A G C A
- A AT A G C A
- T TT AG G A
- G T T A G C A
every character was spilt by \t,but some characters are connected,I want to add \t to these sequence. What I need is like following:
- A T T A G C A
- A A T A G C A
- T T T A G C A
- G T T A G C A
What can i do in python?and I need to fully use my memory to speed up the procession. | 0debug |
static int unpack_block_qpis(Vp3DecodeContext *s, GetBitContext *gb)
{
int qpi, i, j, bit, run_length, blocks_decoded, num_blocks_at_qpi;
int num_blocks = s->total_num_coded_frags;
for (qpi = 0; qpi < s->nqps-1 && num_blocks > 0; qpi++) {
i = blocks_decoded = num_blocks_at_qpi = 0;
bit = get_bits1(gb);
do {
run_length = get_vlc2(gb, s->superblock_run_length_vlc.table, 6, 2) + 1;
if (run_length == 34)
run_length += get_bits(gb, 12);
blocks_decoded += run_length;
if (!bit)
num_blocks_at_qpi += run_length;
for (j = 0; j < run_length; i++) {
if (i >= s->total_num_coded_frags)
return -1;
if (s->all_fragments[s->coded_fragment_list[0][i]].qpi == qpi) {
s->all_fragments[s->coded_fragment_list[0][i]].qpi += bit;
j++;
}
}
if (run_length == MAXIMUM_LONG_BIT_RUN)
bit = get_bits1(gb);
else
bit ^= 1;
} while (blocks_decoded < num_blocks);
num_blocks -= num_blocks_at_qpi;
}
return 0;
}
| 1threat |
static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
Jpeg2000DecoderContext *s = avctx->priv_data;
ThreadFrame frame = { .f = data };
AVFrame *picture = data;
int tileno, ret;
s->avctx = avctx;
s->buf = s->buf_start = avpkt->data;
s->buf_end = s->buf_start + avpkt->size;
s->curtileno = 0;
s->reduction_factor = s->lowres;
if (s->buf_end - s->buf < 2)
return AVERROR_INVALIDDATA;
if ((AV_RB32(s->buf) == 12) &&
(AV_RB32(s->buf + 4) == JP2_SIG_TYPE) &&
(AV_RB32(s->buf + 8) == JP2_SIG_VALUE)) {
if (!jp2_find_codestream(s)) {
av_log(avctx, AV_LOG_ERROR,
"Could not find Jpeg2000 codestream atom.\n");
return AVERROR_INVALIDDATA;
}
}
if (bytestream_get_be16(&s->buf) != JPEG2000_SOC) {
av_log(avctx, AV_LOG_ERROR, "SOC marker not present\n");
return AVERROR_INVALIDDATA;
}
if (ret = jpeg2000_read_main_headers(s))
goto end;
if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "ff_thread_get_buffer() failed.\n");
goto end;
}
picture->pict_type = AV_PICTURE_TYPE_I;
picture->key_frame = 1;
if (ret = jpeg2000_read_bitstream_packets(s))
goto end;
for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++)
if (ret = jpeg2000_decode_tile(s, s->tile + tileno, picture))
goto end;
*got_frame = 1;
end:
jpeg2000_dec_cleanup(s);
return ret ? ret : s->buf - s->buf_start;
}
| 1threat |
e1000_set_link_status(NetClientState *nc)
{
E1000State *s = qemu_get_nic_opaque(nc);
uint32_t old_status = s->mac_reg[STATUS];
if (nc->link_down) {
e1000_link_down(s);
} else {
if (s->compat_flags & E1000_FLAG_AUTONEG &&
s->phy_reg[PHY_CTRL] & MII_CR_AUTO_NEG_EN &&
s->phy_reg[PHY_CTRL] & MII_CR_RESTART_AUTO_NEG &&
!(s->phy_reg[PHY_STATUS] & MII_SR_AUTONEG_COMPLETE)) {
timer_mod(s->autoneg_timer,
qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 500);
} else {
e1000_link_up(s);
}
}
if (s->mac_reg[STATUS] != old_status)
set_ics(s, 0, E1000_ICR_LSC);
}
| 1threat |
static void gem_transmit(GemState *s)
{
unsigned desc[2];
target_phys_addr_t packet_desc_addr;
uint8_t tx_packet[2048];
uint8_t *p;
unsigned total_bytes;
if (!(s->regs[GEM_NWCTRL] & GEM_NWCTRL_TXENA)) {
return;
}
DB_PRINT("\n");
p = tx_packet;
total_bytes = 0;
packet_desc_addr = s->tx_desc_addr;
cpu_physical_memory_read(packet_desc_addr,
(uint8_t *)&desc[0], sizeof(desc));
while (tx_desc_get_used(desc) == 0) {
if (!(s->regs[GEM_NWCTRL] & GEM_NWCTRL_TXENA)) {
return;
}
print_gem_tx_desc(desc);
if ((tx_desc_get_buffer(desc) == 0) ||
(tx_desc_get_length(desc) == 0)) {
DB_PRINT("Invalid TX descriptor @ 0x%x\n", packet_desc_addr);
break;
}
cpu_physical_memory_read(tx_desc_get_buffer(desc), p,
tx_desc_get_length(desc));
p += tx_desc_get_length(desc);
total_bytes += tx_desc_get_length(desc);
if (tx_desc_get_last(desc)) {
cpu_physical_memory_read(s->tx_desc_addr,
(uint8_t *)&desc[0], sizeof(desc));
tx_desc_set_used(desc);
cpu_physical_memory_write(s->tx_desc_addr,
(uint8_t *)&desc[0], sizeof(desc));
if (tx_desc_get_wrap(desc)) {
s->tx_desc_addr = s->regs[GEM_TXQBASE];
} else {
s->tx_desc_addr = packet_desc_addr + 8;
}
DB_PRINT("TX descriptor next: 0x%08x\n", s->tx_desc_addr);
s->regs[GEM_TXSTATUS] |= GEM_TXSTATUS_TXCMPL;
gem_update_int_status(s);
if (s->regs[GEM_DMACFG] & GEM_DMACFG_TXCSUM_OFFL) {
net_checksum_calculate(tx_packet, total_bytes);
}
gem_transmit_updatestats(s, tx_packet, total_bytes);
if (s->phy_loop) {
gem_receive(&s->nic->nc, tx_packet, total_bytes);
} else {
qemu_send_packet(&s->nic->nc, tx_packet, total_bytes);
}
p = tx_packet;
total_bytes = 0;
}
if (tx_desc_get_wrap(desc)) {
packet_desc_addr = s->regs[GEM_TXQBASE];
} else {
packet_desc_addr += 8;
}
cpu_physical_memory_read(packet_desc_addr,
(uint8_t *)&desc[0], sizeof(desc));
}
if (tx_desc_get_used(desc)) {
s->regs[GEM_TXSTATUS] |= GEM_TXSTATUS_USED;
gem_update_int_status(s);
}
}
| 1threat |
AWS Glue executor memory limit : <p>I found that AWS Glue set up executor's instance with memory limit to 5 Gb <code>--conf spark.executor.memory=5g</code> and some times, on a big datasets it fails with <code>java.lang.OutOfMemoryError</code>. The same is for driver instance <code>--spark.driver.memory=5g</code>.
Is there any option to increase this value?</p>
| 0debug |
static void vfio_msix_enable(VFIOPCIDevice *vdev)
{
vfio_disable_interrupts(vdev);
vdev->msi_vectors = g_malloc0(vdev->msix->entries * sizeof(VFIOMSIVector));
vdev->interrupt = VFIO_INT_MSIX;
vfio_msix_vector_do_use(&vdev->pdev, 0, NULL, NULL);
vfio_msix_vector_release(&vdev->pdev, 0);
if (msix_set_vector_notifiers(&vdev->pdev, vfio_msix_vector_use,
vfio_msix_vector_release, NULL)) {
error_report("vfio: msix_set_vector_notifiers failed");
}
trace_vfio_msix_enable(vdev->vbasedev.name);
}
| 1threat |
Git - how to automatically resolve "deleted by us" conflict when cherry-picking : <p>I run the following command:</p>
<pre><code>git cherry-pick SHA --strategy-option theirs
</code></pre>
<p>and get a conflict like this waiting for manual resolution:</p>
<pre><code>deleted by us: SOME_FILE
</code></pre>
<p>Is there a way to make git automatically resolve such conflicts by adding files <em>deleted by us</em>?</p>
| 0debug |
Comapre object properties in 2 lists : I found in some other questions how to compare two lists of objects and get the difference in the way that objects in lists are different.
But I am not sure If the same/similar thing is possible in case that I have same objects in two list, but possibly different property value of particular object in two lists ?
Is there shortcut to check that ?
| 0debug |
struct SwrContext *swr_alloc_set_opts(struct SwrContext *s,
int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate,
int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate,
int log_offset, void *log_ctx){
if(!s) s= swr_alloc();
if(!s) return NULL;
s->log_level_offset= log_offset;
s->log_ctx= log_ctx;
av_opt_set_int(s, "ocl", out_ch_layout, 0);
av_opt_set_int(s, "osf", out_sample_fmt, 0);
av_opt_set_int(s, "osr", out_sample_rate, 0);
av_opt_set_int(s, "icl", in_ch_layout, 0);
av_opt_set_int(s, "isf", in_sample_fmt, 0);
av_opt_set_int(s, "isr", in_sample_rate, 0);
av_opt_set_int(s, "tsf", AV_SAMPLE_FMT_NONE, 0);
av_opt_set_int(s, "ich", av_get_channel_layout_nb_channels(s-> in_ch_layout), 0);
av_opt_set_int(s, "och", av_get_channel_layout_nb_channels(s->out_ch_layout), 0);
av_opt_set_int(s, "uch", 0, 0);
return s;
}
| 1threat |
Checking file existence in Julia : <p>Is there a simple way in Julia to check whether a file in the current working directory exists (something like <code>test = os.path.isfile("foo.txt")</code> in Python or <code>inquire(file = "foo.txt", exist = test)</code> in Fortran)?</p>
| 0debug |
what's the difference between yield from and yield in python 3.3.2+ : <p>After python 3.3.2+ python support a new syntax for create generator function </p>
<pre><code>yield from <expression>
</code></pre>
<p>I have made a quick try for this by </p>
<pre><code>>>> def g():
... yield from [1,2,3,4]
...
>>> for i in g():
... print(i)
...
1
2
3
4
>>>
</code></pre>
<p>It seems simple to use but the <a href="https://www.python.org/dev/peps/pep-0380/" rel="noreferrer">PEP</a> document is complex. My question is that is there any other difference compare to the previous yield statement? Thanks.</p>
| 0debug |
How to add multiplie placeholders to HTML Program? : Okay I made a program
<div id="todo-app">
<label class="todo-label" for="new-todo">What do you want to do today?</label>
<input type="text" id="new-todo" class="todo-input"
placeholder="buy milk">
But in the placeholder section I want it to randomly display othe placeholders.
For example, if you reload: new placeholder texts will appear. One time itll say "buy milk" and another "purchase phone" | 0debug |
Convert a column of datetimes to epoch in Python : <p>I'm currently having an issue with Python. I have a Pandas DataFrame and one of the columns is a string with a date.
The format is :</p>
<blockquote>
<p>"%Y-%m-%d %H:%m:00.000". For example : "2011-04-24 01:30:00.000"</p>
</blockquote>
<p>I need to convert the entire column to integers. I tried to run this code, but it is extremely slow and I have a few million rows.</p>
<pre><code> for i in range(calls.shape[0]):
calls['dateint'][i] = int(time.mktime(time.strptime(calls.DATE[i], "%Y-%m-%d %H:%M:00.000")))
</code></pre>
<p>Do you guys know how to convert the whole column to epoch time ?</p>
<p>Thanks in advance !</p>
| 0debug |
static int tcp_write(URLContext *h, uint8_t *buf, int size)
{
TCPContext *s = h->priv_data;
int ret, size1, fd_max;
fd_set wfds;
struct timeval tv;
size1 = size;
while (size > 0) {
if (url_interrupt_cb())
return -EINTR;
fd_max = s->fd;
FD_ZERO(&wfds);
FD_SET(s->fd, &wfds);
tv.tv_sec = 0;
tv.tv_usec = 100 * 1000;
select(fd_max + 1, NULL, &wfds, NULL, &tv);
#ifdef __BEOS__
ret = send(s->fd, buf, size, 0);
#else
ret = write(s->fd, buf, size);
#endif
if (ret < 0) {
if (errno != EINTR && errno != EAGAIN) {
#ifdef __BEOS__
return errno;
#else
return -errno;
#endif
}
continue;
}
size -= ret;
buf += ret;
}
return size1 - size;
}
| 1threat |
How to get index of smallest value from list : <p>I want to get the index of smallest value from ArrayList of String type</p>
<pre><code>ArrayList<String> list = new ArrayList();
list.add("7.01");
list.add("12.01")
list.add("9.00");
list.add("8.1");
</code></pre>
<p>I am getting those above value from server. </p>
<ol>
<li>Either tell me what is the best way to add it.</li>
<li>Or how to get smallest value index by above ways.
Thanks</li>
</ol>
| 0debug |
@ngrx Effect does not run the second time : <p>I've just started learning about @ngrx/store and @ngrx.effects and have created my first effect in my Angular/Ionic app. It runs ok the first time but if I dispatch the event to the store again (i.e when clicking the button again), nothing happens (no network call is made, nothing in console logs). Is there something obvious I'm doing wrong? Here's the effect:</p>
<pre><code>@Effect() event_response$ = this.action$
.ofType(SEND_EVENT_RESPONSE_ACTION)
.map(toPayload)
.switchMap((payload) => this.myService.eventResponse(payload.eventId,payload.response))
.map(data => new SentEventResponseAction(data))
.catch((error) => Observable.of(new ErrorOccurredAction(error)));
</code></pre>
<p>Thanks</p>
| 0debug |
void qmp_migrate_set_cache_size(int64_t value, Error **errp)
{
MigrationState *s = migrate_get_current();
int64_t new_size;
if (value != (size_t)value) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
"exceeding address space");
return;
}
if (value > ram_bytes_total()) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
"exceeds guest ram size ");
return;
}
new_size = xbzrle_cache_resize(value);
if (new_size < 0) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
"is smaller than page size");
return;
}
s->xbzrle_cache_size = new_size;
}
| 1threat |
static PageDesc *page_find_alloc(tb_page_addr_t index, int alloc)
{
PageDesc *pd;
void **lp;
int i;
#if defined(CONFIG_USER_ONLY)
# define ALLOC(P, SIZE) \
do { \
P = mmap(NULL, SIZE, PROT_READ | PROT_WRITE, \
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \
} while (0)
#else
# define ALLOC(P, SIZE) \
do { P = g_malloc0(SIZE); } while (0)
#endif
lp = l1_map + ((index >> V_L1_SHIFT) & (V_L1_SIZE - 1));
for (i = V_L1_SHIFT / V_L2_BITS - 1; i > 0; i--) {
void **p = *lp;
if (p == NULL) {
if (!alloc) {
return NULL;
}
ALLOC(p, sizeof(void *) * V_L2_SIZE);
*lp = p;
}
lp = p + ((index >> (i * V_L2_BITS)) & (V_L2_SIZE - 1));
}
pd = *lp;
if (pd == NULL) {
if (!alloc) {
return NULL;
}
ALLOC(pd, sizeof(PageDesc) * V_L2_SIZE);
*lp = pd;
}
#undef ALLOC
return pd + (index & (V_L2_SIZE - 1));
}
| 1threat |
Null pointer exception during ParseJSON : <p>When i am trying to parse the json, its throwing a null pointer exception. Also nothing is showing when i am trying to display the values.</p>
<p>code:</p>
<pre><code>public class ParseJSON {
//public static String[] ids;
public static String[] names;
public static String[] message;
public static final String JSON_ARRAY = "users";
// public static final String KEY_ID = "id";
public static final String KEY_NAME = "username";
public static final String KEY_EMAIL = "message";
private JSONArray users = null;
private String json;
public ParseJSON(String json){
this.json = json;
}
protected void parseJSON(){
JSONObject jsonObject=null;
try {
jsonObject = new JSONObject(json);
users = jsonObject.getJSONArray(JSON_ARRAY);
//final String TAG = events.class.getSimpleName();
//Log.d(TAG, "username value: \n" + KEY_NAME);
for(int i=0;i<users.length();i++){
JSONObject jo = users.getJSONObject(i);
// ids[i] = jo.getString(KEY_ID);
names[i] = jo.getString(KEY_NAME);
message[i] = jo.getString(KEY_EMAIL);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
</code></pre>
<p>but when i am trying to display the the parse values, i am displaying it in a separate page, there if i can try to display values using LOG.d, it is showing values.</p>
<p>list_view.java</p>
<pre><code> private void sendRequest(){
StringRequest stringRequest = new StringRequest(JSON_URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
showJSON(response);
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(list_view.this,error.getMessage(),Toast.LENGTH_LONG).show();
}
});
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
}
private void showJSON(String json){
final String TAG = events.class.getSimpleName();
Log.d(TAG, "showJSON: \n" + json);
ParseJSON pj = new ParseJSON(json);
pj.parseJSON();
CustomList cl = new CustomList(this,ParseJSON.names,ParseJSON.message);
listView.setAdapter(cl);
}
@Override
public void onClick(View v) {
sendRequest();
}
}
</code></pre>
<p>Here is the error;</p>
<pre><code>04-24 21:49:39.449 15992-15992/? D/events: showJSON:
{"users":[{"username":"varun","message":"hello word, my first message "},{"username":"varun","message":"hello word, my first message "},{"username":"rahul","message":"hello world"},{"username":"rahul","message":"world: its cool"},{"username":"rahul","message":"awesom"},{"username":"rahul","message":"ranom"},{"username":"rahul","message":"randimagain"},{"username":"rahi","message":"is it me again"},{"username":"rahull","message":"hi rahul"},{"username":"rahul","message":"world, am bacj"},{"username":"rahul","message":"hello parents"},{"username":"","message":""},{"username":"","message":""},{"username":"","message":""},{"username":"","message":""},{"username":"","message":""},{"username":"varun","message":"google world"},{"username":"rahul","message":"ollaaa"},{"username":"rahul","message":"ollaaa"},{"username":"rahul","message":"where are others"},{"username":"rahul","message":"where are others"},{"username":"varun","message":"oil spil"},{"username":"varun","message":"phone"},{"username":"vatun","message":"tttt"},{"username":"varun","message":"poiuytrew"},{"username":"rahui","message":"yregh"},{"username":"varun","message":"huiokgddfv"},{"username":"rahi","message":"poiutghklnbfd"},{"username":"rahui","message":"qwerty"},{"username":"varub","message":"hi eat pineapple"},{"username":"varun","message":"hi prabh"},{"username":"rahul","message":"hi world"},{"username":"ggjdjjf","message":"yhvdhhj"},{"username":"tgggg","message":"hhhh"},{"username":"rahul","message":"lqvrl"},{"username":"hhhh","message":"ghh"},{"username":"tff","message":"gg"},{"username":"hfdhn","message":"hnnnme"},{"username":"popo","message":"plpl"},{"username":"rahulpop","message":"op music"},{"username":"rtrt","message":"tyty"},{"username":"hlpo","message":"opop"},{"username":"hlpoghhj","message":"opop"},{"username":"tt","message":"hhh"},{"username":"ttere","message":"hhh"},{"username":"gytgjyg","message":"lajdhd"},{"username":"topo","message":"ptpt"},{"username":"jgj","message":"rtr"},{"username":"ry","message":"yr"},{"username":"ry","message":"yr"},{"username":"y","message":"q"},{"username":"u","message":"t"},{"username":"tt","message":"pp"},{"username":"q","message":"z"},{"username":"w","message":"v"},{"username":"e","message":"e."},{"username":"ui","message":"ui"},{"username":"yi","message":"yi"},{"username":"gg","message":"g"},{"username":"e","message":"e"},{"username":"h","message":"hh"},{"username":"j","message":"j"},{"username":"j","message":"k"},{"username":"v","message":"v"}]}
04-24 21:49:39.459 15992-15992/? D/AndroidRuntime: Shutting down VM
04-24 21:49:39.459 15992-15992/? W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x40c1ea68)
04-24 21:49:39.529 15992-15992/? E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NullPointerException
at com.weavearound.schools.weavearound.ParseJSON.parseJSON(ParseJSON.java:43)
at com.weavearound.schools.weavearound.list_view.showJSON(list_view.java:76)
at com.weavearound.schools.weavearound.list_view.access$000(list_view.java:22)
at com.weavearound.schools.weavearound.list_view$1.onResponse(list_view.java:51)
at com.weavearound.schools.weavearound.list_view$1.onResponse(list_view.java:45)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:67)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4517)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
at dalvik.system.NativeStart.main(Native Method)
04-24 21:49:39.559 403-420/? E/android.os.Debug: !@Dumpstate > dumpstate -k -t -n -z -d -o /data/log/dumpstate_app_error
</code></pre>
| 0debug |
Upgrade Angular version (now: 2.4.3 or 4.0.0-beta.3) following the best practice? : <p>Now that <a href="http://angularjs.blogspot.com.eg/2016/12/ok-let-me-explain-its-going-to-be.html" rel="noreferrer">Angular is following a Semantic Versioning</a>, and <a href="http://angularjs.blogspot.com.eg/2016/12/angular-240-now-available.html" rel="noreferrer">Angular2.4.3 were released</a>, I'm a little confused here on what is the best practice when I upgrade to the next Angular version in existing project.</p>
<p>I've a project with Angular-cli, with <code>@angular/core: 2.2.0</code>. Here is my <code>package.json</code>:</p>
<pre><code>"dependencies": {
"@angular/common": "~2.2.0",
"@angular/compiler": "~2.2.0",
"@angular/core": "~2.2.0",
"@angular/forms": "~2.2.0",
"@angular/http": "~2.2.0",
"@angular/platform-browser": "~2.2.0",
"@angular/platform-browser-dynamic": "~2.2.0",
"@angular/router": "~3.2.0",
"@types/jasmine": "^2.5.40",
"angular2-click-outside": "^0.1.0",
"angular2-modal": "^2.0.2",
"bootstrap": "4.0.0-alpha.4",
"bootstrap-loader": "^2.0.0-beta.15",
"core-js": "^2.4.1",
"karma-remap-istanbul": "^0.2.2",
"material-design-icons": "^3.0.1",
"ng2-bootstrap": "^1.1.16",
"ng2-charts": "^1.4.4",
"postcss-loader": "^1.1.1",
"rxjs": "5.0.0-rc.4",
"screenfull": "^3.0.2",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23"
},
"devDependencies": {
"@types/jasmine": "^2.2.30",
"@types/node": "^6.0.42",
"angular-cli": "1.0.0-beta.19-3",
"codelyzer": "1.0.0-beta.3",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.7.0",
"karma": "1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"node-sass": "^3.13.0",
"protractor": "4.0.11",
"replace": "0.3.0",
"ts-node": "1.7.0",
"tslint": "3.15.1",
"typescript": "~2.0.3",
"webdriver-manager": "10.2.8"
}
</code></pre>
<p><strong>Question:</strong> How do I upgrade to the next Angular version(now: 2.4.3 or 4.0.0-beta.3) following the best practice? Using <code>npm</code> or <code>yarn</code>.</p>
| 0debug |
Why install symfony version 4? : <p>I want to install version 4 symfony ,
but when I use the compose composer-project symfony / website-skeleton demo,
it is version 5 downloaded by default ?</p>
| 0debug |
static void pxa2xx_pcmcia_realize(DeviceState *dev, Error **errp)
{
PXA2xxPCMCIAState *s = PXA2XX_PCMCIA(dev);
pcmcia_socket_register(&s->slot);
}
| 1threat |
java8: method reference from another method reference : <p>I want to use a method reference based off another method reference. It's kind of hard to explain, so I'll give you an example:</p>
<p><strong>Person.java</strong></p>
<pre><code>public class Person{
Person sibling;
int age;
public Person(int age){
this.age = age;
}
public void setSibling(Person p){
this.sibling = p;
}
public Person getSibling(){
return sibling;
}
public int getAge(){
return age;
}
}
</code></pre>
<p>Given a list of <code>Person</code>s, I want to use method references to get a list of their sibling's ages. I know this can be done like this:</p>
<pre><code>roster.stream().map(p -> p.getSibling().getAge()).collect(Collectors.toList());
</code></pre>
<p>But I'm wondering if it's possible to do it more like this:</p>
<pre><code>roster.stream().map(Person::getSibling::getAge).collect(Collectors.toList());
</code></pre>
<p>It's not terribly useful in this example, I just want to know what's possible.</p>
| 0debug |
Trying to learn better lamba coding : While the following code works fine I was wondering if there a cleaner way to accomplish this with lambda expressions?
var counter = 1;
foreach (var item in model)
{
item.ID = counter++;
} | 0debug |
Delay a jquery function without timer : <p>I have seen many stack or google answer, where to delay a function there is a suggestion for timer. But is there a way to delay a function with out using timer. Or other way is there a event where once a event for eg onclick or on blur is done check for the event end and call a function in a lazy manner without using timer. </p>
| 0debug |
def closest_num(N):
return (N - 1) | 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.