problem
stringlengths
26
131k
labels
class label
2 classes
How to hide Blue line covering views in xib/Storyboard in Xcode 7.2 : <p><a href="https://i.stack.imgur.com/bI0ls.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bI0ls.png" alt="enter image description here"></a> I am using xcode 7.2, in xib when i insert any view, label,txtField etc., all are showing this covering blue line. now it is very hard to insert/manage new view or anything in xib due to this line. Does anybody know how to hide these?</p>
0debug
static int iscsi_readcapacity_sync(IscsiLun *iscsilun) { struct scsi_task *task = NULL; struct scsi_readcapacity10 *rc10 = NULL; struct scsi_readcapacity16 *rc16 = NULL; int ret = 0; int retries = ISCSI_CMD_RETRIES; do { if (task != NULL) { scsi_free_scsi_task(task); task = NULL; } switch (iscsilun->type) { case TYPE_DISK: task = iscsi_readcapacity16_sync(iscsilun->iscsi, iscsilun->lun); if (task != NULL && task->status == SCSI_STATUS_GOOD) { rc16 = scsi_datain_unmarshall(task); if (rc16 == NULL) { error_report("iSCSI: Failed to unmarshall readcapacity16 data."); ret = -EINVAL; } else { iscsilun->block_size = rc16->block_length; iscsilun->num_blocks = rc16->returned_lba + 1; iscsilun->lbpme = rc16->lbpme; iscsilun->lbprz = rc16->lbprz; } } break; case TYPE_ROM: task = iscsi_readcapacity10_sync(iscsilun->iscsi, iscsilun->lun, 0, 0); if (task != NULL && task->status == SCSI_STATUS_GOOD) { rc10 = scsi_datain_unmarshall(task); if (rc10 == NULL) { error_report("iSCSI: Failed to unmarshall readcapacity10 data."); ret = -EINVAL; } else { iscsilun->block_size = rc10->block_size; if (rc10->lba == 0) { iscsilun->num_blocks = 0; } else { iscsilun->num_blocks = rc10->lba + 1; } } } break; default: return 0; } } while (task != NULL && task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_UNIT_ATTENTION && retries-- > 0); if (task == NULL || task->status != SCSI_STATUS_GOOD) { error_report("iSCSI: failed to send readcapacity10 command."); ret = -EINVAL; } if (task) { scsi_free_scsi_task(task); } return ret; }
1threat
static void bonito_cop_writel(void *opaque, hwaddr addr, uint64_t val, unsigned size) { PCIBonitoState *s = opaque; ((uint32_t *)(&s->boncop))[addr/sizeof(uint32_t)] = val & 0xffffffff;
1threat
Arrays.stream(array) vs Arrays.asList(array).stream() : <p>In <a href="https://stackoverflow.com/questions/27391028/arrays-aslist-vs-arrays-stream-to-use-foreach">this</a> question it has already been answered that both expressions are equal, but in this case they produce different results. For a given <code>int[] scores</code>, why does this work:</p> <pre><code>Arrays.stream(scores) .forEach(System.out::println); </code></pre> <p>...but this does not:</p> <pre><code>Arrays.asList(scores).stream() .forEach(System.out::println); </code></pre> <p>As far as I know <code>.stream()</code> can be called on any Collection, which Lists definitely are. The second code snippet just returns a stream containing the array as a whole instead of the elements.</p>
0debug
Discriminated Union - Allow Pattern Matching but Restrict Construction : <p>I have an F# Discriminated Union, where I want to apply some "constructor logic" to any values used in constructing the union cases. Let's say the union looks like this:</p> <pre><code>type ValidValue = | ValidInt of int | ValidString of string // other cases, etc. </code></pre> <p>Now, I want to apply some logic to the values that are actually passed-in to ensure that they are valid. In order to make sure I don't end up dealing with <code>ValidValue</code> instances that aren't really valid (haven't been constructed using the validation logic), I make the constructors private and expose a public function that enforces my logic to construct them.</p> <pre><code>type ValidValue = private | ValidInt of int | ValidString of string module ValidValue = let createInt value = if value &gt; 0 // Here's some validation logic then Ok &lt;| ValidInt value else Error "Integer values must be positive" let createString value = if value |&gt; String.length &gt; 0 // More validation logic then Ok &lt;| ValidString value else Error "String values must not be empty" </code></pre> <p>This works, allowing me to enforce the validation logic and make sure every instance of <code>ValidValue</code> really is valid. However, the problem is that no one outside of this module can pattern-match on <code>ValidValue</code> to inspect the result, limiting the usefulness of the Discriminated Union. </p> <p>I would like to allow outside users to still pattern-match and work with the <code>ValidValue</code> like any other DU, but that's not possible if it has a private constructor. The only solution I can think of would be to wrap each value inside the DU in a single-case union type with a private constructor, and leave the actual <code>ValidValue</code> constructors public. This would expose the cases to the outside, allowing them to be matched against, but still mostly-prevent the outside caller from constructing them, because the values required to instantiate each case would have private constructors:</p> <pre><code>type VInt = private VInt of int type VString = private VString of string type ValidValue = | ValidInt of VInt | ValidString of VString module ValidValue = let createInt value = if value &gt; 0 // Here's some validation logic then Ok &lt;| ValidInt (VInt value) else Error "Integer values must be positive" let createString value = if value |&gt; String.length &gt; 0 // More validation logic then Ok &lt;| ValidString (VString value) else Error "String values must not be empty" </code></pre> <p>Now the caller can match against the cases of <code>ValidValue</code>, but they can't read the actual integer and string values inside the union cases, because they're wrapped in types that have private constructors. This can be fixed with <code>value</code> functions for each type:</p> <pre><code>module VInt = let value (VInt i) = i module VString = let value (VString s) = s </code></pre> <p>Unfortunately, now the burden on the caller is increased:</p> <pre><code>// Example Caller let result = ValidValue.createInt 3 match result with | Ok validValue -&gt; match validValue with | ValidInt vi -&gt; let i = vi |&gt; VInt.value // Caller always needs this extra line printfn "Int: %d" i | ValidString vs -&gt; let s = vs |&gt; VString.value // Can't use the value directly printfn "String: %s" s | Error error -&gt; printfn "Invalid: %s" error </code></pre> <p>Is there a better way to enforce the execution of the constructor logic I wanted at the beginning, without increasing the burden somewhere else down the line?</p>
0debug
solving matrices using Cramer's rule in c : So i searched the in internet looking for programs with Cramer's Rule and there were some few, but apparently these examples were for fixed matrices only like 2x2 or 4x4. However I am looking for a way to solve a NxN Matrix. so I started and reached the point of asking the user for the size of the matrix and asked the user to input the values of the matrix but then i don't know how to move on from here. As in I guess my next step is to apply Cramer's rule and get the answers but i just don't know how.[This is the step I'm missing][1]. can anybody help me please? [1]: https://i.stack.imgur.com/Y5ans.png
0debug
Is there a way to change a specific word in an p or a tag attribute in HTML? : <p>This is kind of a beginners question. What I'm basically trying to do is loop different words in an HTML page's header. For instance, I would want a header that says "Paint your car the color of _____" where the empty space loops through the different words of "red", "blue", "green", "purple" etc... I've been looking everyone, but I can't seem to find anything. If someone can point me to the right direction of a link or something, that'd be much appreciated! Cheers</p>
0debug
How to Select and click button to login to web page using Python Selenium (Beginner in Selenium) : [![HTML code for button ][1]][1] [1]: https://i.stack.imgur.com/W1J6n.png How can I click on "Sign In" button to login to the web page as I am not getting any valid id to click on it
0debug
static int parse_outputs(const char **buf, AVFilterInOut **curr_inputs, AVFilterInOut **open_inputs, AVFilterInOut **open_outputs, AVClass *log_ctx) { int ret, pad = 0; while (**buf == '[') { char *name = parse_link_name(buf, log_ctx); AVFilterInOut *match; AVFilterInOut *input = *curr_inputs; *curr_inputs = (*curr_inputs)->next; if (!name) match = extract_inout(name, open_inputs); if (match) { if ((ret = link_filter(input->filter_ctx, input->pad_idx, match->filter_ctx, match->pad_idx, log_ctx)) < 0) return ret; av_free(match->name); av_free(name); av_free(match); av_free(input); } else { input->name = name; insert_inout(open_outputs, input); *buf += strspn(*buf, WHITESPACES); pad++; return pad;
1threat
Table Styling not working with IE and Edge : I simply applied the below css code which is working fine with Chrome but never works with Edge and IE11 <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-css --> .StandardTable table th { background: #0098B4 !important; color: #ffffff !important; text-align: center !important; } .StandardTable table tr { background: #ffffff !important; color: #000000 !important; } .StandardTable table tr:hover{ background-color:#1f2326 !important; color: #ffffff !important; } .StandardTable table, th, td { border: 1px solid #dcdcdc; } <!-- end snippet --> Any ideas? Thank you much :)
0debug
Is it possible to set a different specification per cache using caffeine in spring boot? : <p>I have a simple sprint boot application using spring boot <code>1.5.11.RELEASE</code> with <code>@EnableCaching</code> on the Application <code>Configuration</code> class.</p> <h2>pom.xml</h2> <pre><code> &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-cache&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.github.ben-manes.caffeine&lt;/groupId&gt; &lt;artifactId&gt;caffeine&lt;/artifactId&gt; &lt;/dependency&gt; </code></pre> <h2>application.properties</h2> <pre><code>spring.cache.type=caffeine spring.cache.cache-names=cache-a,cache-b spring.cache.caffeine.spec=maximumSize=100, expireAfterWrite=1d </code></pre> <h2>Question</h2> <p>My question is simple, how can one specify a different size/expiration per cache. E.g. perhaps it's acceptable for <code>cache-a</code> to be valid for <code>1 day</code>. But <code>cache-b</code> might be ok for <code>1 week</code>. The specification on a caffeine cache appears to be global to the <code>CacheManager</code> rather than <code>Cache</code>. Am I missing something? Perhaps there is a more suitable provider for my use case?</p>
0debug
create method channel after upgrading flutter- can not resolve method getFlutterView() : <p>i was using native android method in my flutter app using documentation which said use</p> <pre><code>MethodChannel(flutterView, CHANNEL).setMethodCallHandler... </code></pre> <p>but after upgrading flutter the <code>MethodChannel</code> function does not require <code>flutterView</code> and there is no <code>flutterView</code> anymore.</p> <pre><code>can not resolve method getFlutterView() </code></pre> <p>i think there should be a new tutorial for creating channel</p> <p>instead it needs some <code>BinaryMessenger</code> which i don't know what to give instead.</p> <p>this is the old code which is not working anymore:</p> <pre><code>import io.flutter.app.FlutterActivity; import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel.MethodCallHandler; import io.flutter.plugin.common.MethodChannel.Result; public class MainActivity extends FlutterActivity { private static final String CHANNEL = "samples.flutter.dev/battery"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); GeneratedPluginRegistrant.registerWith(this); new MethodChannel(getFlutterView(), CHANNEL).setMethodCallHandler( new MethodCallHandler() { @Override public void onMethodCall(MethodCall call, Result result) { // Note: this method is invoked on the main thread. // TODO } }); } </code></pre>
0debug
javascript/react dynamic height textarea (stop at a max) : <p>What I'm trying to achieve is a textarea that starts out as a single line but will grow up to 4 lines and at that point start to scroll if the user continues to type. I have a partial solution kinda working, it grows and then stops when it hits the max, but if you delete text it doesn't shrink like I want it to.</p> <p>This is what I have so far.</p> <pre><code>export class foo extends React.Component { constructor(props) { super(props); this.state = { textareaHeight: 38 }; } handleKeyUp(evt) { // Max: 75px Min: 38px let newHeight = Math.max(Math.min(evt.target.scrollHeight + 2, 75), 38); if (newHeight !== this.state.textareaHeight) { this.setState({ textareaHeight: newHeight }); } } render() { let textareaStyle = { height: this.state.textareaHeight }; return ( &lt;div&gt; &lt;textarea onKeyUp={this.handleKeyUp.bind(this)} style={textareaStyle}/&gt; &lt;/div&gt; ); } } </code></pre> <p>Obviously the problem is <code>scrollHeight</code> doesn't shrink back down when <code>height</code> is set to something larger. Any suggestion for how I might be able to fix this so it will also shrink back down if text is deleted? </p>
0debug
Visual C# problems : Im having some trouble with visual studio as it says it wont compile. I cant figure out what the problem is it says something like it can't convert from void to bool even though they're is no 'bool'. Here is my code: using System; namespace ConsoleApplication14 { class Program { static void Main(string[] args) { Console.WriteLine(myFunction(14)); } public static void myFunction(int x) { return x + 2; } } Please help me!!
0debug
jquery to remove dupicate elements from list by value : I am trying to remove li elements which have duplicate values. I have list as shown below: <ul> <li value="1" name="moon" id="moon1">Moon<li> <li value="2" name="moon" id="moon2">Moon<li> <li value="1" name="moon" id="moon3">Moon<li> <li value="3" name="moon" id="moon4">Moon<li> <li value="4" name="moon" id="sun1">Sun<li> <li value="5" name="moon" id="sun2">Sun<li> <li value="4" name="moon" id="sun3">Sun<li> <ul> I need something like this: <ul> <li value="1" name="moon" id="moon1">Moon<li> <li value="2" name="moon" id="moon2">Moon<li> <li value="3" name="moon" id="moon4">Moon<li> <li value="4" name="moon" id="sun1">Sun<li> <li value="5" name="moon" id="sun2">Sun<li> <ul> I am very basic to jquery, please help me out. Thanks in advance.
0debug
static int disas_coproc_insn(CPUARMState * env, DisasContext *s, uint32_t insn) { int cpnum, is64, crn, crm, opc1, opc2, isread, rt, rt2; const ARMCPRegInfo *ri; cpnum = (insn >> 8) & 0xf; if (arm_feature(env, ARM_FEATURE_XSCALE) && ((env->cp15.c15_cpar ^ 0x3fff) & (1 << cpnum))) return 1; switch (cpnum) { case 0: case 1: if (arm_feature(env, ARM_FEATURE_IWMMXT)) { return disas_iwmmxt_insn(env, s, insn); } else if (arm_feature(env, ARM_FEATURE_XSCALE)) { return disas_dsp_insn(env, s, insn); return 1; default: break; is64 = (insn & (1 << 25)) == 0; if (!is64 && ((insn & (1 << 4)) == 0)) { return 1; crm = insn & 0xf; if (is64) { crn = 0; opc1 = (insn >> 4) & 0xf; opc2 = 0; rt2 = (insn >> 16) & 0xf; } else { crn = (insn >> 16) & 0xf; opc1 = (insn >> 21) & 7; opc2 = (insn >> 5) & 7; rt2 = 0; isread = (insn >> 20) & 1; rt = (insn >> 12) & 0xf; ri = get_arm_cp_reginfo(s->cp_regs, ENCODE_CP_REG(cpnum, is64, crn, crm, opc1, opc2)); if (ri) { if (!cp_access_ok(s->current_pl, ri, isread)) { return 1; switch (ri->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) { case ARM_CP_NOP: return 0; case ARM_CP_WFI: if (isread) { return 1; s->is_jmp = DISAS_WFI; return 0; default: break; if (use_icount && (ri->type & ARM_CP_IO)) { gen_io_start(); if (isread) { if (is64) { TCGv_i64 tmp64; TCGv_i32 tmp; if (ri->type & ARM_CP_CONST) { tmp64 = tcg_const_i64(ri->resetvalue); } else if (ri->readfn) { tmp64 = tcg_temp_new_i64(); gen_helper_get_cp_reg64(tmp64, cpu_env, tmpptr); } else { tmp64 = tcg_temp_new_i64(); tcg_gen_ld_i64(tmp64, cpu_env, ri->fieldoffset); tmp = tcg_temp_new_i32(); tcg_gen_trunc_i64_i32(tmp, tmp64); store_reg(s, rt, tmp); tcg_gen_shri_i64(tmp64, tmp64, 32); tmp = tcg_temp_new_i32(); tcg_gen_trunc_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); store_reg(s, rt2, tmp); } else { TCGv_i32 tmp; if (ri->type & ARM_CP_CONST) { tmp = tcg_const_i32(ri->resetvalue); } else if (ri->readfn) { tmp = tcg_temp_new_i32(); gen_helper_get_cp_reg(tmp, cpu_env, tmpptr); } else { tmp = load_cpu_offset(ri->fieldoffset); if (rt == 15) { if (ri->type & ARM_CP_CONST) { return 0; if (is64) { TCGv_i32 tmplo, tmphi; TCGv_i64 tmp64 = tcg_temp_new_i64(); tmplo = load_reg(s, rt); tmphi = load_reg(s, rt2); tcg_gen_concat_i32_i64(tmp64, tmplo, tmphi); tcg_temp_free_i32(tmplo); tcg_temp_free_i32(tmphi); if (ri->writefn) { TCGv_ptr tmpptr = tcg_const_ptr(ri); gen_helper_set_cp_reg64(cpu_env, tmpptr, tmp64); } else { tcg_gen_st_i64(tmp64, cpu_env, ri->fieldoffset); tcg_temp_free_i64(tmp64); } else { if (ri->writefn) { TCGv_i32 tmp; tmp = load_reg(s, rt); gen_helper_set_cp_reg(cpu_env, tmpptr, tmp); tcg_temp_free_i32(tmp); } else { TCGv_i32 tmp = load_reg(s, rt); store_cpu_offset(tmp, ri->fieldoffset); if (use_icount && (ri->type & ARM_CP_IO)) { gen_io_end(); gen_lookup_tb(s); } else if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { /* We default to ending the TB on a coprocessor register write, * but allow this to be suppressed by the register definition * (usually only necessary to work around guest bugs). gen_lookup_tb(s); return 0; /* Unknown register; this might be a guest error or a QEMU * unimplemented feature. if (is64) { qemu_log_mask(LOG_UNIMP, "%s access to unsupported AArch32 " "64 bit system register cp:%d opc1: %d crm:%d\n", isread ? "read" : "write", cpnum, opc1, crm); } else { qemu_log_mask(LOG_UNIMP, "%s access to unsupported AArch32 " "system register cp:%d opc1:%d crn:%d crm:%d opc2:%d\n", isread ? "read" : "write", cpnum, opc1, crn, crm, opc2); return 1;
1threat
static inline void ide_abort_command(IDEState *s) { ide_transfer_stop(s); s->status = READY_STAT | ERR_STAT; s->error = ABRT_ERR; }
1threat
Create typescript interface as union of other interfaces : <p>I have a list of interfaces that extends one basic interface.</p> <p>I have also some functions that can accept any of these interfaces.</p> <p>I would like to create a new interface that describe that kind of parameter.</p> <p>So I have something like this:</p> <pre><code>interface BasicInterface {...}; interface A extends BasicInterface {...}; interface B extends BasicInterface {...}; </code></pre> <p>and I would like something like </p> <pre><code>interface C = A | B; </code></pre> <p>I know in my functions I can do </p> <pre><code>function X(param1: A | B) {}; </code></pre> <p>but since it is more than one function I would like to have just one interface for all of them</p>
0debug
Android studio - how can I add a textview to a linear layout with an onlick listener : how can I add a textview to a linear layout with a onlick button listener? At the moment, the button onclick listener will produce a textview but i don't like it because it looks messy and unorganised I tried doing this: varlinear.addView(varkebabTotal); but it caused an error. I have looked at other examples but they didn't explain how it will work with an onlick listener. Below I added the code for what happens when the button is clicked varKebab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String name = "Kebab Wrap"; if (menu.containsKey(name)) { kebabquantity = list.get(name); if (kebabquantity == null) { kebabquantity = 0; } kebabquantity++; list.put(name, kebabquantity); //kebab qty calc double kebabTotal = kebabquantity * menu.get(name); overallTotal = overallTotal + menu.get(name); varkebabTotal.setText(String.format("%s %s @ £%s = £%.2f", kebabquantity.toString(), name, menu.get(name), kebabTotal)); varTotalPrice.setText(String.format("Total = £%.2f", overallTotal)); varlinear.addView(varkebabTotal); // this line caused an error } } }); What I need is for the textview to be added onto a linear layout where it will look organised and nice. Whenever the button is clicked again, it should replace the old textview and update it again
0debug
How to change a variable within a request : I have a problem with coding in Swift. I'm using Xcode 9.1 and I want to check if file exist and then change the context of a variable. if I working with playgrounds, it wil work but coding in a viewport, nothing happens. I check if the file named "nameoffile.xml" exist, using the statuscode, and then the var color need to change into "blue". Below you will find my (not working) code. Many thanks in advance!!! let url = URL(string: "http://myurl/nameoffile.xml")! var color = "" func checkFile() { let req = NSMutableURLRequest(url: url) req.httpMethod = "HEAD" req.timeoutInterval = 1.0 var response: URLResponse? var task = URLSession.shared.dataTask(with: url) {(data, response, error) in if let httpStatus = response as? HTTPURLResponse { if httpStatus.statusCode == 200 { self.kleur = "blue" } } }
0debug
import csv into elasticsearch : <p>I'm doing "elastic search getting started" tutorial. Unfortunatelly this tutorial doesn't cover first step which is importing <code>csv</code> database into elasticsearch.</p> <p>I googled to find solution but it doesn't work unfortunatelly. Here is what I want to achieve and what I have:</p> <p>I have a file with data which I want to import (simplified)</p> <pre><code>id,title 10,Homer's Night Out 12,Krusty Gets Busted </code></pre> <p>I would like to import it using <code>logstash</code>. After research over the internet I end up with following config:</p> <pre><code>input { file { path =&gt; ["simpsons_episodes.csv"] start_position =&gt; "beginning" } } filter { csv { columns =&gt; [ "id", "title" ] } } output { stdout { codec =&gt; rubydebug } elasticsearch { action =&gt; "index" hosts =&gt; ["127.0.0.1:9200"] index =&gt; "simpsons" document_type =&gt; "episode" workers =&gt; 1 } } </code></pre> <p>I have a trouble with specifying document type so once data is imported and I navigate to <a href="http://localhost:9200/simpsons/episode/10" rel="noreferrer">http://localhost:9200/simpsons/episode/10</a> I expect to see result with episode 10.</p>
0debug
static int av_always_inline mlp_thd_probe(AVProbeData *p, uint32_t sync) { const uint8_t *buf, *last_buf = p->buf, *end = p->buf + p->buf_size; int frames = 0, valid = 0, size = 0; for (buf = p->buf; buf + 8 <= end; buf++) { if (AV_RB32(buf + 4) == sync) { frames++; if (last_buf + size == buf) { valid++; } last_buf = buf; size = (AV_RB16(buf) & 0xfff) * 2; } else if (buf - last_buf == size) { size += (AV_RB16(buf) & 0xfff) * 2; } } if (valid >= 100) return AVPROBE_SCORE_MAX; return 0; }
1threat
def join_tuples(test_list): res = [] for sub in test_list: if res and res[-1][0] == sub[0]: res[-1].extend(sub[1:]) else: res.append([ele for ele in sub]) res = list(map(tuple, res)) return (res)
0debug
I’m trying to set another color in in above mentioned attribute but it showing me error. Pls help me out : <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <TextView android:text="Happy Birthday! ABHISHEK :)" android:background="@android:color/blue" android:layout_width="300dp" android:layout_height="50dp" /> <!-- end snippet --> i’m trying to set another color in in above mentioned attribute but it showing me error. Please help me out
0debug
Angular 4 - Template inheritance : <p>I have the following child component and it's inheritance parent component:</p> <pre><code>@Component({ template: `&lt;p&gt;child&lt;/p&gt;` }) export class EditChildComponent extends EditViewComponent{ constructor(){ super(); } } @Component({ template: `&lt;p&gt;parent&lt;/p&gt;` }) export class EditViewComponent{ constructor(){ } } </code></pre> <p>Now is there any way to place the template of the EditViewComponent in the ChildComponents template like you would do with ng-content in nested components? How would I get the following result:</p> <pre><code>&lt;p&gt;parent&lt;/p&gt; &lt;p&gt;child&lt;/p&gt; </code></pre>
0debug
static int to_integer(char *p, int len) { int ret; char *q = av_malloc(sizeof(char) * len); if (!q) return -1; strncpy(q, p, len); ret = atoi(q); av_free(q); return ret; }
1threat
static av_cold int vsink_init(AVFilterContext *ctx, void *opaque) { BufferSinkContext *buf = ctx->priv; AVBufferSinkParams *params = opaque; if (params && params->pixel_fmts) { const int *pixel_fmts = params->pixel_fmts; buf->pixel_fmts = ff_copy_int_list(pixel_fmts); if (!buf->pixel_fmts) return AVERROR(ENOMEM); } return common_init(ctx); }
1threat
how to send action form to tow direction? : I have code send from to mail, and I don't broke this code. i don't know the page action receive the form info .. I wont code send to tow direction, in the same time like this . <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <from action ="firstdiraction.php" action="seconddirction.php" > <!-- end snippet -->
0debug
int kvm_sw_breakpoints_active(CPUState *env) { return !TAILQ_EMPTY(&env->kvm_state->kvm_sw_breakpoints); }
1threat
What is the error of my code? : <p>Can anyone tell what is wrong with my coding? There is undefined variable on every "$current...". Why does it has error while when i click on the search button, the result come out in the table?</p> <p><a href="http://i.stack.imgur.com/4fw26.jpg" rel="nofollow">Here is the error occur</a></p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;title&gt;Search Book&lt;/title&gt; &lt;link href="css/bootstrap.css" rel="stylesheet"&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="container" align="center"&gt; &lt;div class="row"&gt; &lt;div class="col-md-5"&gt; &lt;form method="get" action="" class="form-horizontal" name="search"&gt;&lt;br&gt; &lt;table border="0" bgcolor="#E0FFFF"&gt; &lt;td&gt;&lt;h3&gt;Search Book By ISBN:&lt;/h3&gt;&lt;/td&gt; &lt;div class="form-group"&gt; &lt;td&gt;&lt;input type="text" name="id" class="form-control" placeholder="eg: 978-0320037825"&gt;&lt;/td&gt; &lt;/div&gt; &lt;br/&gt; &lt;tr&gt;&lt;td&gt;&lt;center&gt;&lt;button type="submit" class="btn btn-success"&gt;Search&lt;/button&gt;&amp;nbsp;&lt;/center&gt;&lt;/td&gt; &lt;td&gt;&lt;a href="index.php"&gt;Back&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt; &lt;?php if (isset($_GET['id']) !='') { $id = $_GET['id']; $xml = simplexml_load_file("bookstore.xml"); $notThere = True; foreach ($xml-&gt;children() as $book) { if ($book-&gt;isbn == $id) { $currentisbn = $book-&gt;isbn; $currenttitle = $book-&gt;title; $currentfirstname = $book-&gt;firstname; $currentlastname = $book-&gt;lastname; $currentprice = $book-&gt;price; $currentyear = $book-&gt;year; $currentpublisher = $book-&gt;publisher; $notThere = False; } } if($notThere) { echo "ISBN Does Not Exist!"; } } ?&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;html&gt; &lt;form method="POST" action="" class="form-horizontal" name="delete"&gt; &lt;table width="600" bgcolor="#ffffff" border="1" cellpadding="8"&gt; &lt;tr colspan="2"&gt;&lt;h2&gt;Delete Book&lt;/h2&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width="150"&gt;ISBN&lt;/td&gt; &lt;td width="320"&gt;&lt;?php echo $currentisbn;?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="150"&gt;Title&lt;/td&gt; &lt;td width="320"&gt;&lt;?php echo $currenttitle;?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;First Name&lt;/td&gt; &lt;td&gt;&lt;?php echo $currentfirstname;?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Last Name&lt;/td&gt; &lt;td&gt;&lt;?php echo $currentlastname;?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="150"&gt;Price&lt;/td&gt; &lt;td width="320"&gt;&lt;?php echo $currentprice;?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="150"&gt;Year&lt;/td&gt; &lt;td width="320"&gt;&lt;?php echo $currentyear;?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="150"&gt;Publisher&lt;/td&gt; &lt;td width="320"&gt;&lt;?php echo $currentpublisher;?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;td colspan="2" align="center"&gt; &lt;input name="submit" type="submit" value="Delete"/&gt; &amp;nbsp; &lt;a class="btn btn-default" href="index.php" role="button"&gt;Home&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;?php if (isset($_GET['id'])!='' &amp;&amp; isset($_POST['submit'])!=''){ $id = $_GET['id']; $success=False; $dom = new DOMDocument(); $dom -&gt; load("bookstore.xml"); $xpath = new DOMXpath($dom); $node = $xpath-&gt;query("//*[isbn='$id']"); foreach ($node as $book) { $book-&gt;parentNode-&gt;removeChild($book); $success=True; } if($success) { echo "&lt;h1 style='text-align: center;'&gt;Successfully Deleted!&lt;/h1&gt;"; } $dom-&gt;save("bookstore.xml"); } ?&gt; &lt;script&gt; function goBack() { window.history.back(); } &lt;/script&gt; &lt;/html&gt; </code></pre>
0debug
Changing Property Name in Typescript Mapped Type : <p>I have a collection of Typescript objects that look like this:</p> <pre><code>SomeData { prop1: string; prop2: number; } </code></pre> <p>And I need to end up with some objects that look like this:</p> <pre><code>type SomeMoreData= { prop1Change: string; prop2Change: number; } </code></pre> <p>I know that if I just wanted to change the type, I could do this:</p> <pre><code>type SomeMoreData&lt;T&gt; = { [P in keyof T]: boolean; } </code></pre> <p>Which would give me:</p> <pre><code>SomeMoreData&lt;SomeData&gt; { prop1: boolean; prop2: boolean; } </code></pre> <p>Is there a way to manipulate the name produced by the <code>[P in keyof T]</code> bit? I've tried things like <code>[(P in keyof T) + "Change"]</code> with no success.</p>
0debug
static uint64_t omap_pwl_read(void *opaque, target_phys_addr_t addr, unsigned size) { struct omap_pwl_s *s = (struct omap_pwl_s *) opaque; int offset = addr & OMAP_MPUI_REG_MASK; if (size != 1) { return omap_badwidth_read8(opaque, addr); } switch (offset) { case 0x00: return s->level; case 0x04: return s->enable; } OMAP_BAD_REG(addr); return 0; }
1threat
MIME type issue in Angular : <p>I am getting the following error when I try to load my home page and the page is blank.</p> <pre><code>main-es2015.5ff489631e1a2300adb7.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec. runtime-es2015.2c9dcf60c8e0a8889c30.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec. vendor-es2015.02ac05cd7eee1cf62f5a.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec. </code></pre> <p>This was working before and it is working correctly in dev while serving using <code>ng serve</code>. The issue happens when the code is running from server. When I checked from the devtools, it is showing the <code>content-type</code> and <code>text/html</code> instead of <code>application/javascript</code>. How this can be fixed ? There is something needs to be set from the server ?</p>
0debug
static BlockBackend *img_open(const char *id, const char *filename, const char *fmt, int flags, bool require_io, bool quiet) { BlockBackend *blk; BlockDriverState *bs; char password[256]; Error *local_err = NULL; QDict *options = NULL; if (fmt) { options = qdict_new(); qdict_put(options, "driver", qstring_from_str(fmt)); } blk = blk_new_open(id, filename, NULL, options, flags, &local_err); if (!blk) { error_report("Could not open '%s': %s", filename, error_get_pretty(local_err)); error_free(local_err); goto fail; } bs = blk_bs(blk); if (bdrv_is_encrypted(bs) && require_io) { qprintf(quiet, "Disk image '%s' is encrypted.\n", filename); if (read_password(password, sizeof(password)) < 0) { error_report("No password given"); goto fail; } if (bdrv_set_key(bs, password) < 0) { error_report("invalid password"); goto fail; } } return blk; fail: blk_unref(blk); return NULL; }
1threat
Serial commmunication between stm32f103 and computer using usb to ttl pl2303 : please i would like to know is if is possible to send data from my stm32f103 board to my laptop using usb-ttl pl2303 ? i have tried but even after downloading the drivers the com port is not recognized by com terminal applications. I need this urgently for a project .Thanks
0debug
static void dump_data(const uint8_t *data, int len) {}
1threat
Is there a more elegant way to copy specific files using Docker COPY to the working directory? : <p>Attempting to create a container with microsoft/dotnet:2.1-aspnetcore-runtime. The .net core solution file has multiple projects nested underneath the solution, each with it's own .csproj file. I am attemping to create a more elegant COPY instruction for the sub-projects</p> <p>The sample available here <a href="https://github.com/dotnet/dotnet-docker/tree/master/samples/aspnetapp" rel="noreferrer">https://github.com/dotnet/dotnet-docker/tree/master/samples/aspnetapp</a> has a solution file with only one .csproj so creates the Dockerfile thusly:</p> <pre><code>COPY *.sln . COPY aspnetapp/*.csproj ./aspnetapp/ RUN dotnet restore </code></pre> <p>It works this way</p> <pre><code>COPY my_solution_folder/*.sln . COPY my_solution_folder/project/*.csproj my_solution_folder/ COPY my_solution_folder/subproject_one/*.csproj subproject_one/ COPY my_solution_folder/subproject_two/*.csproj subproject_two/ COPY my_solution_folder/subproject_three/*.csproj subproject_three/ </code></pre> <p>for a solution folder structure of:</p> <pre><code>my_solution_folder\my_solution.sln my_solution_folder\project\my_solution.csproj my_solution_folder\subproject_one\subproject_one.csproj my_solution_folder\subproject_two\subproject_two.csproj my_solution_folder\subproject_three\subproject_three.csproj </code></pre> <p>but this doesn't (was a random guess)</p> <pre><code>COPY my_solution_folder/*/*.csproj working_dir_folder/*/ </code></pre> <p>Is there a more elegant solution?</p>
0debug
static void get_tag(AVFormatContext *s, const char *key, int type, int len, int type2_size) { char *value; int64_t off = avio_tell(s->pb); if ((unsigned)len >= (UINT_MAX - 1) / 2) return; value = av_malloc(2 * len + 1); if (!value) goto finish; if (type == 0) { avio_get_str16le(s->pb, len, value, 2 * len + 1); } else if (type == -1) { avio_read(s->pb, value, len); value[len]=0; } else if (type == 1) { if (!strcmp(key, "WM/Picture")) { asf_read_picture(s, len); } else if (!strcmp(key, "ID3")) { get_id3_tag(s, len); } else { av_log(s, AV_LOG_VERBOSE, "Unsupported byte array in tag %s.\n", key); } goto finish; } else if (type > 1 && type <= 5) { uint64_t num = get_value(s->pb, type, type2_size); snprintf(value, len, "%"PRIu64, num); } else if (type == 6) { av_log(s, AV_LOG_DEBUG, "Unsupported GUID value in tag %s.\n", key); goto finish; } else { av_log(s, AV_LOG_DEBUG, "Unsupported value type %d in tag %s.\n", type, key); goto finish; } if (*value) av_dict_set(&s->metadata, key, value, 0); finish: av_freep(&value); avio_seek(s->pb, off + len, SEEK_SET); }
1threat
tôi bắt mắc phải một lỗi như sau : The view iot.views.post_new didn't return an HttpResponse object. It returned None instead : tôi bắt mắc phải một lỗi như sau : The view iot.views.post_new didn't return an HttpResponse object. It returned None instead. Hope everybody help please. This is my views.py file: def post_new(request): if request.method == "POST": form = PostForm(request.POST or None) if form.is_valid(): ct = form.save(commit=False) ct.author = request.user ct.upload_time = request.upload_time ct.save() return redirect('iot:detail', pk=ct.pk) else: form = PostForm() return render(request, 'iot/post.html', {"form":form})
0debug
implement rtree on postress : I want to implement Rtree with Postgres to fast query a two dimensional geographic data in double precision. I know Rtree was implemented in Postgres in old versions and was replaced by a more powerful module GIST. But I can't find any example of using GIST in postgres to create Rtree index. For example, I have a table Points, which has three fields: point_id, X and Y and I want to use Postgres to quickly query point that a<x<b and c<y<d. How can I do that. Thank you
0debug
Visible variables in c++ and how to make variable visible more : <p><br>I am still a beginner in c++, but I know something. I am studying the 1st term and I wanna make my own project, IMO it's the best way to learn to program. Anyway<br> I wanna load data from file to dynamic array (and I know how to do that) but I to that job be done by special function and to that array be visible for other function (alternativity global). I know that using global variables is not good idea so I am thinking if it's possible to make variable friend with NO classes (bc I didn't use and learn classes yet)<br> Thanks in advance!</p>
0debug
static int find_hw_breakpoint(target_ulong addr, int len, int type) { int n; for (n = 0; n < nb_hw_breakpoint; n++) if (hw_breakpoint[n].addr == addr && hw_breakpoint[n].type == type && (hw_breakpoint[n].len == len || len == -1)) return n; return -1; }
1threat
How to instantiate an unknown amount of objects in powershell : I have a question regarding the object creation in powershell version 5. To simplify my question I am providing the exact java code I want to functionally realize. I know, Java and powershell have nothing in common besides being object-oriented and I don't care for how this can be achieved syntactically but I hope it will help understand my intention. Scanner scan = new Scanner(System.in); System.out.println("How many argument lists do you want to provide?"); int i = Integer.parseInt(scan.next()); List<List<String>> list = new ArrayList<>(); for(int j = 0; j < i; j++) { list.add(new ArrayList<String>()); // this is the exact point if don't know how to substantiate in powershell list.get(j).add(scan.next()); // more arguments to be entered } The actual intention in powershell is to parse user provided arguments with Read-Host and build a list of list of Strings containing them. Each list shall contain arguments for one powershell command. I hope this is understandable and someone can provide a solution. I will gladly provide more explanation if I couldn't make myself clear yet.
0debug
static void qtest_irq_handler(void *opaque, int n, int level) { qemu_irq old_irq = *(qemu_irq *)opaque; qemu_set_irq(old_irq, level); if (irq_levels[n] != level) { CharDriverState *chr = qtest_chr; irq_levels[n] = level; qtest_send_prefix(chr); qtest_send(chr, "IRQ %s %d\n", level ? "raise" : "lower", n); } }
1threat
How can I determine whether a checkbox is checked in jQuery? : <p>I dynamically create a bunch of checkboxes like so:</p> <pre><code>@foreach (var rpt in reports) { @* convert id to lowercase and no spaces *@ var morphedRptName = @rpt.report.Replace(" ", string.Empty).ToLower(); &lt;input class="leftmargin8, ckbx" id="ckbx_@(morphedRptName)" type="checkbox" value="@rpt.report" /&gt;@rpt.report } </code></pre> <p>I've got this event handler where I want to determine their state - checked or unchecked:</p> <pre><code>$(".ckbx").change(function () { if ($(this).checked) { alert('checkbox is unchecked'); checkboxSelected = false; return; } alert('checkbox is checked'); . . . </code></pre> <p>However, the condition "if ($(this).checked)" is <em>always</em> false, both when I check a checkbox and when I subsequently uncheck/deselect it.</p> <p>So what do I need to do to determine when it is unchecked? I actually tried this first: "if (!$(this).checked)" but that just did the reverse - the condition was always true.</p>
0debug
void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s) { BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s->vdev))); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); VirtIOBlock *vblk = VIRTIO_BLK(s->vdev); int r; if (vblk->dataplane_started || s->starting) { return; } s->starting = true; s->vq = virtio_get_queue(s->vdev, 0); r = k->set_guest_notifiers(qbus->parent, 1, true); if (r != 0) { fprintf(stderr, "virtio-blk failed to set guest notifier (%d), " "ensure -enable-kvm is set\n", r); goto fail_guest_notifiers; } s->guest_notifier = virtio_queue_get_guest_notifier(s->vq); r = k->set_host_notifier(qbus->parent, 0, true); if (r != 0) { fprintf(stderr, "virtio-blk failed to set host notifier (%d)\n", r); goto fail_host_notifier; } s->starting = false; vblk->dataplane_started = true; trace_virtio_blk_data_plane_start(s); blk_set_aio_context(s->conf->conf.blk, s->ctx); event_notifier_set(virtio_queue_get_host_notifier(s->vq)); aio_context_acquire(s->ctx); virtio_queue_aio_set_host_notifier_handler(s->vq, s->ctx, true, true); aio_context_release(s->ctx); return; fail_host_notifier: k->set_guest_notifiers(qbus->parent, 1, false); fail_guest_notifiers: vblk->dataplane_disabled = true; s->starting = false; vblk->dataplane_started = true; }
1threat
def longest_subseq_with_diff_one(arr, n): dp = [1 for i in range(n)] for i in range(n): for j in range(i): if ((arr[i] == arr[j]+1) or (arr[i] == arr[j]-1)): dp[i] = max(dp[i], dp[j]+1) result = 1 for i in range(n): if (result < dp[i]): result = dp[i] return result
0debug
PHP variable in an <iframe> : <p>I have a PHP script where i echo an iframe. I want a variable inside of that. I think this is the right script:</p> <p>PHP: </p> <pre><code>echo "&lt;style&gt;body{margin: 0}&lt;/style&gt;&lt;iframe src='WEBURL.php? nme=$db_name' style='height: 100vh; width: 100vw; border: none; margin: 0;'&gt;"; </code></pre> <p>HTML:</p> <pre><code>&lt;?php echo $nme;?&gt; </code></pre> <p>When i run the PHP script i get an error:</p> <blockquote> <p>Notice: Undefined variable: nme</p> </blockquote> <p>Whats wrong?</p>
0debug
static uint64_t omap_mcbsp_read(void *opaque, hwaddr addr, unsigned size) { struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque; int offset = addr & OMAP_MPUI_REG_MASK; uint16_t ret; if (size != 2) { return omap_badwidth_read16(opaque, addr); } switch (offset) { case 0x00: if (((s->rcr[0] >> 5) & 7) < 3) return 0x0000; case 0x02: if (s->rx_req < 2) { printf("%s: Rx FIFO underrun\n", __FUNCTION__); omap_mcbsp_rx_done(s); } else { s->tx_req -= 2; if (s->codec && s->codec->in.len >= 2) { ret = s->codec->in.fifo[s->codec->in.start ++] << 8; ret |= s->codec->in.fifo[s->codec->in.start ++]; s->codec->in.len -= 2; } else ret = 0x0000; if (!s->tx_req) omap_mcbsp_rx_done(s); return ret; } return 0x0000; case 0x04: case 0x06: return 0x0000; case 0x08: return s->spcr[1]; case 0x0a: return s->spcr[0]; case 0x0c: return s->rcr[1]; case 0x0e: return s->rcr[0]; case 0x10: return s->xcr[1]; case 0x12: return s->xcr[0]; case 0x14: return s->srgr[1]; case 0x16: return s->srgr[0]; case 0x18: return s->mcr[1]; case 0x1a: return s->mcr[0]; case 0x1c: return s->rcer[0]; case 0x1e: return s->rcer[1]; case 0x20: return s->xcer[0]; case 0x22: return s->xcer[1]; case 0x24: return s->pcr; case 0x26: return s->rcer[2]; case 0x28: return s->rcer[3]; case 0x2a: return s->xcer[2]; case 0x2c: return s->xcer[3]; case 0x2e: return s->rcer[4]; case 0x30: return s->rcer[5]; case 0x32: return s->xcer[4]; case 0x34: return s->xcer[5]; case 0x36: return s->rcer[6]; case 0x38: return s->rcer[7]; case 0x3a: return s->xcer[6]; case 0x3c: return s->xcer[7]; } OMAP_BAD_REG(addr); return 0; }
1threat
What's the difference between `useRef` and `createRef`? : <p>I was going through the hooks documentation when I stumbled upon <a href="https://reactjs.org/docs/hooks-reference.html#useref" rel="noreferrer"><code>useRef</code></a>.</p> <p>Looking at their example…</p> <pre><code>function TextInputWithFocusButton() { const inputEl = useRef(null); const onButtonClick = () =&gt; { // `current` points to the mounted text input element inputEl.current.focus(); }; return ( &lt;&gt; &lt;input ref={inputEl} type="text" /&gt; &lt;button onClick={onButtonClick}&gt;Focus the input&lt;/button&gt; &lt;/&gt; ); } </code></pre> <p>…it seems like <code>useRef</code> can be replaced with <code>createRef</code>.</p> <pre><code>function TextInputWithFocusButton() { const inputRef = createRef(); // what's the diff? const onButtonClick = () =&gt; { // `current` points to the mounted text input element inputRef.current.focus(); }; return ( &lt;&gt; &lt;input ref={inputRef} type="text" /&gt; &lt;button onClick={onButtonClick}&gt;Focus the input&lt;/button&gt; &lt;/&gt; ); } </code></pre> <p>Why do I need a hook for refs? Why does <code>useRef</code> exist?</p>
0debug
PHP Fatal error: Cannot use try without catch or finally : <p>I am getting the following error on my web page<strong>Fatal error: Cannot use try without catch or finally <em>in apply-for-job.php on line 13</em></strong> and I cant find the error myself pleas I need help Thanks. Bellow is my code:-</p> <pre><code>&lt;?php include 'connect.php'; if(isset($_POST['apply'])) { $fname = $_POST['firstname']; $mname = $_POST['middlename']; $lname = $_POST['lastname']; $city = $_POST['city']; $state = $_POST['state']; $education = $_POST['education']; $vaccancy = $_POST['position']; try{ $stmt = $db_con-&gt;prepare('INSERT INTO tbl_employment(firstName,middleName,lastName,userCity,userState,userEducation,userPosition) VALUES (:fname, :mname, :lname, :ucity, :ustate, :uedu, :uvacca)'); $stmt-&gt;bindParam(":fname", $fname); $stmt-&gt;bindParam(":mname", $mname); $stmt-&gt;bindParam(":lname", $lname); $stmt-&gt;bindParam(":ucity", $city); $stmt-&gt;bindParam(":ustate", $state); $stmt-&gt;bindParam(":uedu", $education); $stmt-&gt;bindParam(":uvacca", $vaccancy); if ($stmt-&gt;execute()) { $message="success"; } else{ $message="error"; } } } ?&gt; </code></pre> <p>And my line 13 is located where <strong><code>try{</code></strong> is</p>
0debug
Get a list of current running APP in Anrdroid : I want use the ActivityManager to get a list of current APPs and return the newest process` name to the system clipboard.Just like this protected void onStart() { super.onStart(); Amanager=(ActivityManager)this.getSystemService(ACTIVITY_SERVICE); ActivityManager.RunningAppProcessInfo App=null; List<ActivityManager.RunningAppProcessInfo> RunningTasks; try { RunningTasks = Amanager.getRunningAppProcesses(); App = RunningTasks.get(0); }catch (final Exception e){Log.d(TAG, "List ERROR");} if(App!=null) { String result =App.processName; contentText.setText(result);; Clipboard.setText(result); }else { Log.d(TAG, "COMPONENT ERROR"); } } But when running at the Simulator, some errors occured: java.lang.RuntimeException: Unable to start activity ComponentInfo{//the absolute address}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.EditText.setText(java.lang.CharSequence)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.j
0debug
no internet inside docker-compose service : <p><strong>I cannot reach external network from docker-compose containers.</strong></p> <p>Consider the following docker-compose file:</p> <pre><code>version: '2' services: nginx: image: nginx </code></pre> <p>Using the simple <code>docker run -it nginx bash</code> I manage to reach external IPs or Internet IPs (<code>ping www.google.com</code>). </p> <p>On the other hand if I use docker-compose and attach to the container, I cannot reach external IP addresses / DNS.</p> <p>docker info:</p> <pre><code>Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 1 Server Version: 1.12.1 Storage Driver: aufs Root Dir: /var/lib/docker/aufs Backing Filesystem: extfs Dirs: 7 Dirperm1 Supported: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge null host overlay Swarm: inactive Runtimes: runc Default Runtime: runc Security Options: apparmor seccomp Kernel Version: 4.4.0-38-generic Operating System: Ubuntu 16.04.1 LTS OSType: linux Architecture: x86_64 CPUs: 2 Total Memory: 3.859 GiB Name: *** ID: **** Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false Registry: https://index.docker.io/v1/ WARNING: No swap limit support WARNING: bridge-nf-call-iptables is disabled WARNING: bridge-nf-call-ip6tables is disabled Insecure Registries: 127.0.0.0/8 </code></pre> <p>docker-compose 1.8.1, build 878cff1</p> <p>daemon.json file:</p> <pre><code>{ "iptables" : false, "dns" : ["8.8.8.8","8.8.4.4"] } </code></pre>
0debug
Line counting in Python : <p>I am a beginner in Python self studying Python 2.7. May I ask one question I got in line counting codes in Python? How do I intuitively understand why the below works, especially how I can understand what the for loop is doing with the file handle? </p> <p>Many thanks all</p> <pre><code>fhand=open('test.txt') count=0 for line in fhand: count=count+1 print count </code></pre>
0debug
static uint16_t phys_map_node_alloc(void) { unsigned i; uint16_t ret; ret = next_map.nodes_nb++; assert(ret != PHYS_MAP_NODE_NIL); assert(ret != next_map.nodes_nb_alloc); for (i = 0; i < L2_SIZE; ++i) { next_map.nodes[ret][i].is_leaf = 0; next_map.nodes[ret][i].ptr = PHYS_MAP_NODE_NIL; } return ret; }
1threat
void FUNCC(ff_h264_chroma_dc_dequant_idct)(int16_t *_block, int qmul){ const int stride= 16*2; const int xStride= 16; int a,b,c,d,e; dctcoef *block = (dctcoef*)_block; a= block[stride*0 + xStride*0]; b= block[stride*0 + xStride*1]; c= block[stride*1 + xStride*0]; d= block[stride*1 + xStride*1]; e= a-b; a= a+b; b= c-d; c= c+d; block[stride*0 + xStride*0]= ((a+c)*qmul) >> 7; block[stride*0 + xStride*1]= ((e+b)*qmul) >> 7; block[stride*1 + xStride*0]= ((a-c)*qmul) >> 7; block[stride*1 + xStride*1]= ((e-b)*qmul) >> 7; }
1threat
Example Bruteforce Algorithm : <p>I am currently getting into Pentesting and Ethical Hacking to test website security. <br> I would appreciate an example Bruteforce algorithm that is stored in a string. Not a dictionary algorithm, but a bruteforce algorithm. <br> For example, it tries the letter a. Then it tries the letter b, then it tries c and so on. Thank you in advance :)</p>
0debug
(HTML, Visual Studio) How to access an SQL server and use it as a data source in a Master Page (Markup) : I have been working on a web page in Visual Studio that allows the user to select data for an invoice. One of the areas of my page consists of a button, that when clicked, adds a drop down box as well as several text boxes in a table in the same row, every time the button is clicked, a new row is added with the same set of elements. This serves to allow the user to add several products to the invoice, which can be selected with the drop down box in each row. This is all done within the Main.Master file, through the markup section of code. My problem however, is that I only know how to add options for the drop down box that consist of a text value. More so, I don't know how to create and reference an SQL Data source in the markup file, and use the "ProductID" field within said database as the main data for my drop down box. I'll post a summary of my questions below, then my code, any help would be much appreciated please. **Summary** 1. How can you Connect to an SQL Server in the Main.Master file through the markup code and use it as a Data Source? 2. How would I use one of the fields within the data source as the main field for my drop down box? **Code** <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Main.master.cs" Inherits="DatabaseDrivenWebsite.Main" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>My Website!</title> <script type="text/javascript"> //~Function That adds the separate elements~ function addRow(btn) { var parentRow = btn.parentNode.parentNode; var table = parentRow.parentNode; var rowCount = table.rows.length; var row = table.insertRow(rowCount); //~Product Dropdown~ var cell1 = row.insertCell(0); var element1 = document.createElement("select"); element1.type = "select"; element1.style.width = "140px"; element1.style.zIndex = "100"; element1.style.marginLeft = "-1060px"; element1.style.position = "relative"; element1.dataset = HTMLSourceElement cell1.appendChild(element1); var option1 = document.createElement("option"); option1.innerHTML = "Option1"; option1.value = "1"; element1.add(option1, null); var option2 = document.createElement("option"); option2.innerHTML = "Option2"; option2.value = "2"; element1.add(option2, null); cell1.appendChild(element1); //~Description Textbox~ var cell2 = row.insertCell(1); var element2 = document.createElement("input"); element2.type = "text"; element2.style.width = "220px"; element2.style.zIndex = "100"; element2.style.marginLeft = "-1678px"; element2.style.position = "relative"; cell2.appendChild(element2); //~Quantity Textbox~ var cell3 = row.insertCell(2); var element3 = document.createElement("input"); element3.type = "text"; element3.style.width = "85px"; element3.style.zIndex = "100"; element3.style.marginLeft = "-1352px"; element3.style.position = "relative"; cell3.appendChild(element3); //~List Price Textbox~ var cell4 = row.insertCell(3); var element4 = document.createElement("input"); element4.type = "text"; element4.style.width = "82px"; element4.style.zIndex = "100"; element4.style.marginLeft = "-1165px"; element4.style.position = "relative"; cell4.appendChild(element4); //~Sell Price Textbox~ var cell5 = row.insertCell(4); var element5 = document.createElement("input"); element5.type = "text"; element5.style.width = "88px"; element5.style.zIndex = "100"; element5.style.marginLeft = "-972px"; element5.style.position = "relative"; cell5.appendChild(element5); //~Total GST Textbox~ var cell6 = row.insertCell(5); var element6 = document.createElement("input"); element6.type = "text"; element6.style.width = "90px"; element6.style.zIndex = "100"; element6.style.marginLeft = "-770px"; element6.style.position = "relative"; cell6.appendChild(element6); //~Fuel Levy Textbox~ var cell7 = row.insertCell(6); var element7 = document.createElement("input"); element7.type = "text"; element7.style.width = "100px"; element7.style.zIndex = "100"; element7.style.marginLeft = "-550px"; element7.style.position = "relative"; cell7.appendChild(element7); //~Total Price Textbox~ var cell8 = row.insertCell(7); var element8 = document.createElement("input"); element8.type = "text"; element8.style.width = "98px"; element8.style.zIndex = "100"; element8.style.marginLeft = "-325px"; element8.style.position = "relative"; cell8.appendChild(element8); } </script> <link href="Style/Main.css" rel="stylesheet" /> <asp:ContentPlaceHolder ID="head" runat="server"> </asp:ContentPlaceHolder> </head> <body> <form id="form1" runat="server"> <div id="MainData"> <div id="Header">This is the header</div> <div id="Menu"> <asp:Panel ID="pnMenu" runat="server"> <a href="Home.aspx">Home</a> | <a href="Orders.aspx">Orders</a> | <a href="Finances.aspx">Finances</a> <table style="margin-top:179px; margin-left:109px; width:999px; line-height:25px;"> <tr> //~When clicked, this button calls the AddRow Function~ <td><button type="button" onclick ="addRow(this)" style="margin-top:-70px; margin-right:960px; position: relative; z-index: 100;">Add</button></td> </tr> </table> </asp:Panel> </div> <div id="Content"> <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </div> <div id="Footer">Copyright 2016 DBS</div> </div> </form> </body> </html> Here is the JSFiddle, its very rough and the formatting isn't how it looks on my official web page, but it demonstrates the code in action and how it functions. Any help would be beyond appreciated, I couldn't find anything online that would help me out with this, it seems to be too specific. *P.S. Scroll to the right of the preview to find the "Add" Button, click that too see the functionality of the code* https://jsfiddle.net/5170hLsh/1/ ~ Luke
0debug
uint64_t helper_addlv(CPUAlphaState *env, uint64_t op1, uint64_t op2) { uint64_t tmp = op1; op1 = (uint32_t)(op1 + op2); if (unlikely((tmp ^ op2 ^ (-1UL)) & (tmp ^ op1) & (1UL << 31))) { arith_excp(env, GETPC(), EXC_M_IOV, 0); } return op1; }
1threat
Differentiate dark and light areas in image : <p>My problem is that I want to differentiate the light and dark areas in the following image to generate a binary mask.</p> <p><a href="https://i.stack.imgur.com/7ZRKB.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/7ZRKB.jpg</a></p> <p>An approximation to the output can be this:</p> <p><a href="https://i.stack.imgur.com/2UuJb.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/2UuJb.jpg</a></p> <p>I've tried a lot of things but the results still have some noise or I lost a lot of data, like in this image:</p> <p><a href="https://i.stack.imgur.com/hUyjY.png" rel="nofollow noreferrer">https://i.stack.imgur.com/hUyjY.png</a></p> <p>I've used python with opencv and numpy, gaussian filters, opening, closing, etc... Somebody have some idea to doing this?</p> <p>Thanks in advance!</p>
0debug
Download PhpSpreadsheet file without save it before : <p>I'm using <a href="https://github.com/PHPOffice/PhpSpreadsheet" rel="noreferrer">PhpSpreadsheet</a> to generate an Excel file in Symfony 4. My code is:</p> <pre><code>$spreadsheet = $this-&gt;generateExcel($content); $writer = new Xlsx($spreadsheet); $filename = "myFile.xlsx"; $writer-&gt;save($filename); // LINE I WANT TO AVOID $response = new BinaryFileResponse($filename); $response-&gt;headers-&gt;set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); $response-&gt;setContentDisposition( ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename ); </code></pre> <p>But I don't want to save the file and then read it to return to the user. I would like to download Excel content directly. Is there a way to do It?</p> <p>I've searched how to generate a stream of the content (as <a href="https://stackoverflow.com/a/39247345">this answer</a> says) but I hadn't success.</p> <p>Thanks in advance and sorry about my English</p>
0debug
can anyone tell me please why are these number are concatenating, : <p>I am a beginner at programming, i always stumble upon this problem whenever i am trying to add numbers, instead of adding, it concatenates. Please someone explain what is happening here and some solutions so that i would not come across these type of problems again thanks ^^ </p> <pre><code>function add(x,n) { let result = x + n; return result; } let x = prompt(); let n = prompt(); alert ( add(x,n) ); </code></pre> <p>if i have x=5 and n=2 it should alert 7, but it shows 52. however if i use different arithmetic operators, it works. if i use -, it subtracts.</p>
0debug
void do_migrate_set_downtime(Monitor *mon, const QDict *qdict) { char *ptr; double d; const char *value = qdict_get_str(qdict, "value"); d = strtod(value, &ptr); if (!strcmp(ptr,"ms")) { d *= 1000000; } else if (!strcmp(ptr,"us")) { d *= 1000; } else if (!strcmp(ptr,"ns")) { } else { d *= 1000000000; } max_downtime = (uint64_t)d; }
1threat
bool qemu_clock_expired(QEMUClockType type) { return timerlist_expired( main_loop_tlg.tl[type]); }
1threat
Calculate business days, Insert Keys and Diagrams : Hi everybody i'm working on a problem in C++ Builder, i have to create a task management software for a company, but i have too much trouble with some concepts. So my 1st problem is a simple one but i don't see the error: I have on my form a TrStringGrid which is a modified TStringGrid and i want that each time the user clicks on insert on the keyboard that a row is filled automatically. The app starts with a tstringgrid with 2 rows, one is fixed and can't be modified and the second one is empty. That's what it look like: [![Grid][1]][1] [1]: http://i.stack.imgur.com/K4cSl.png So what i want to do is that the first time the user press the insert key the row n°2 is filled (the row that is not grey). The second and subsequent times the user press the insert key a row is added and filled automatically. I can't get it work and i don't know if i'm doing it the good way or not. //method called each time a key is pressed void __fastcall TForm1::rStringGridEd1KeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { int counter = 1; switch(Key) { case VK_INSERT: //VK_INSERT for the insert button if(counter < 2) { for (int i = 0;i< rStringGridEd1->RowCount; i++) { rStringGridEd1->Cells[0][i] = "a"; rStringGridEd1->Cells[1][i] = "b"; rStringGridEd1->Cells[2][i] = "c"; rStringGridEd1->Cells[3][i] = "d"; rStringGridEd1->Cells[4][i] = "e"; counter++; } } if(counter >= 2){ for (int i = 0;i< rStringGridEd1->RowCount; i++) { rStringGridEd1->RowCount++; // this is used to add a row rStringGridEd1->Cells[0][i] = "a"; rStringGridEd1->Cells[1][i] = "b"; rStringGridEd1->Cells[2][i] = "c"; rStringGridEd1->Cells[3][i] = "d"; rStringGridEd1->Cells[4][i] = "e"; counter++; } } } } My next problem is how to add only business days to a specific date that the user entered. I can't get it work correctly. //Method I used to calculate date is the start date and the variable days are the days to add to date to get the new date TDate __fastcall TForm1 ::calulatenewdate( TDate date, int days) { TDate tmp; //tmp is used inside this method as date tmp = date; // j is used for to get the day of the week (Monday, Tuesday, Wesdnesday, etc..) int j; if (days == 1){ return date;} if (days == 2){ tmp= +1; j = DayOfWeek(tmp); // the day of the week is given in numbers from 1 to 7 ( 1 = Sunday, 2 = Monday, 3 = Wesdnesday,etc…) if (j == 7) { //So if j =7 which is Saturday add two days to get to monday tmp = tmp+2; return tmp; }else{ return tmp; } } if(days > 2){ // if the user enter a day greater than 2 for(int i =0; i < days;i++) { tmp=tmp+1; j = DayOfWeek(tmp); if (j == 7) { tmp =+2; } } return tmp; } and my third and last problem is that i want to draw horizontal diagrams,are there any good ones out there? Can anyone recommend me one? I'm really sorry for my bad english, it's not my mothertongue.
0debug
php impload code is not working code mising : I am using PHP add to cart insert product and gest user detail all data is inserted but product-related data is not inserted please check it. and help me... <?php $msg=''; if(isset($_POST['submit'])) { $first_name = mysqli_real_escape_string($conn, $_POST['first_name']); $last_name = mysqli_real_escape_string($conn, $_POST['last_name']); $phone_number = mysqli_real_escape_string($conn, $_POST['phone_number']); $email_address = mysqli_real_escape_string($conn, $_POST['email_address']); $address = mysqli_real_escape_string($conn, $_POST['address']); $city = mysqli_real_escape_string($conn, $_POST['city']); $zip_code = mysqli_real_escape_string($conn, $_POST['zip_code']); $state = mysqli_real_escape_string($conn, $_POST['state']); $country = mysqli_real_escape_string($conn, $_POST['country']); $total = mysqli_real_escape_string($conn, $_POST['total']); $paymentMethod = mysqli_real_escape_string($conn, $_POST['paymentMethod']); $orderStatus = '1'; $orderDate = date('Y-m-d H:i:s'); <!-----------------issue code --------------------> $productImage = array(); $productName = array(); $product_qty = array(); $price = array(); foreach($_SESSION["products"] as $product){ $productName = $product["productName"]; $productPrice = $product["productPrice"]; $product_qty = $product["product_qty"]; $productImage1 = $product["productImage1"]; } $productImage=implode(',', $productImage); $productName=implode(',', $productName); $product_qty=implode(',', $product_qty); $price=implode(',', $price); <!----------------------------------------------> $query = "INSERT INTO orders (first_name,last_name,phone_number,email_address,address, city,zip_code,state,country,productImage,productName, product_qty,total,price,orderDate,paymentMethod,orderStatus) VALUES('$first_name','$last_name','$phone_number','$email_address', '$address','$city','$zip_code','$state','$country','$productImage', '$productName','$product_qty','$total','$price','$orderDate', '$paymentMethod','$orderStatus')"; $run= mysqli_query($conn, $query); unset ($_SESSION["products"]); echo "<script>window.location.assign('thankyou.php')</script>"; } ?>
0debug
How to dismiss Keyboard if subscriber throws an error in reactive cocoa using swift? : <p>I subscribed to a service call and handling error incase if service call throws an error. This is everything done in View Model. So, when an error throws I want to dismiss Keyboard. How can I let my View Model tells to VC to dismiss keyboard. I am using reactive cocoa and swift.</p>
0debug
static void dealloc_helper(void *native_in, VisitorFunc visit, Error **errp) { QapiDeallocVisitor *qdv = qapi_dealloc_visitor_new(); visit(qapi_dealloc_get_visitor(qdv), &native_in, errp); qapi_dealloc_visitor_cleanup(qdv); }
1threat
printing token returned from strtok or strtok_r crashes : <p>I have tried a simple program on my linux machine which tokenize a string using delimiter (",") and prints all the token values. But its crashing on very first statement which tries to print the token value.</p> <p>Here is my program</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;string.h&gt; void main() { char *query = "1,2,3,4,5"; char *token = strtok(query, ","); while(token) { printf("Token: %s \n", token); token = strtok(NULL, ","); } } </code></pre> <p>output:</p> <pre><code>Segmentation fault (core dumped) </code></pre> <p>BT in GDB:</p> <pre><code> (gdb) r Starting program: /home/harish/samples/a.out Program received signal SIGSEGV, Segmentation fault. strtok () at ../sysdeps/x86_64/strtok.S:186 186 ../sysdeps/x86_64/strtok.S: No such file or directory. </code></pre> <p>Build System:</p> <pre><code>64 bit Ubuntu, gcc 4.8.4 version. </code></pre>
0debug
SPARCCPU *sparc64_cpu_devinit(const char *cpu_model, const char *default_cpu_model, uint64_t prom_addr) { SPARCCPU *cpu; CPUSPARCState *env; ResetData *reset_info; uint32_t tick_frequency = 100 * 1000000; uint32_t stick_frequency = 100 * 1000000; uint32_t hstick_frequency = 100 * 1000000; if (cpu_model == NULL) { cpu_model = default_cpu_model; } cpu = SPARC_CPU(cpu_generic_init(TYPE_SPARC_CPU, cpu_model)); if (cpu == NULL) { fprintf(stderr, "Unable to find Sparc CPU definition\n"); exit(1); } env = &cpu->env; env->tick = cpu_timer_create("tick", cpu, tick_irq, tick_frequency, TICK_INT_DIS, TICK_NPT_MASK); env->stick = cpu_timer_create("stick", cpu, stick_irq, stick_frequency, TICK_INT_DIS, TICK_NPT_MASK); env->hstick = cpu_timer_create("hstick", cpu, hstick_irq, hstick_frequency, TICK_INT_DIS, TICK_NPT_MASK); reset_info = g_malloc0(sizeof(ResetData)); reset_info->cpu = cpu; reset_info->prom_addr = prom_addr; qemu_register_reset(main_cpu_reset, reset_info); return cpu; }
1threat
import re def remove_parenthesis(items): for item in items: return (re.sub(r" ?\([^)]+\)", "", item))
0debug
what dose this code mean?(window), function (a, b, c) : <p>what does this code mean? I saw the code on some website. I don't know how it works. I have simplified the code. <code> (window), function (a, b, c){} </code></p>
0debug
Swift 4 regex custom validation : <p>i need some help to write correct regex validation. I want password with no spaces, min. 6 symbols, doesn't matter numbers or letters or symbols. Alphabet a-zA-Z and а-яА-Я(RU). How i can do that?</p>
0debug
Using enum as interface key in typescript : <p>I was wonder if I can use enum as an object key in interfaces.. I've built a little test for it:</p> <pre><code>export enum colorsEnum{ red,blue,green } export interface colorsInterface{ [colorsEnum.red]:boolean, [colorsEnum.blue]:boolean, [colorsEnum.green]:boolean } </code></pre> <p>When I run it I'm getting the following error:</p> <pre><code>A computed property name in an interface must directly refer to a built-in symbol. </code></pre> <p>I'm doing it wrong or it just not possible?</p>
0debug
i am facing in writing get method can any one help in correcting error : i want to retrive the data using rest api response and display in my html page here is the code i have written so far.can anyone help me in writting the correct code and i am new to use web servces. when i insert into database using rest api it is inserted. I want the data that is inserted into the database through the rest api response and i want to display the same result in web page. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <!DOCTYPE html> <html> <head> <title>AngularJS File Upoad Example with $http and FormData</title> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.min.js"></script> </head> <body ng-app="myApp"> <div ng-controller="MyController"> <table> <tr> <td><input type="name" ng-model="contact.name"></td> <td><input type="email" ng-model="contact.username"></td> <td><input type="password" ng-model="contact.password"></td> <td><button ng-click="addContact()">Sign In</button></td> <td><button ng-click="viewContact()">view</button></td> </tr> </table> </div> <script type="text/javascript"> var myApp = angular.module('myApp',[]); myApp.controller('MyController',['$scope','$http',function($scope,$http){ $scope.addContact = function(){ console.log($scope.contact); $http.post('http://localhost:8085/useraccount/register/doregister',$scope.contact); }; $scope.viewContact = function(){ console.log($scope.contact); $http.get('http://localhost:8085/useraccount/register/doselect',$scope.contact); }; }]); </script> </body> </html> <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> register.java package com.registration; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.Map; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.FormParam; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import org.json.JSONObject; //import org.json.simple.JSONArray; //import org.json.simple.JSONObject; //import org.json.simple.parser.JSONParser; //Path: http://localhost/<appln-folder-name>/register @Path("/register") public class Register { // public String jsonReader() // { // String response=""; // JSONParser parser = new JSONParser(); // try // { // Object object = parser // .parse(new FileReader("c:\\sample.json")); // // //convert Object to JSONObject // JSONObject jsonObject = (JSONObject)object; // String name = (String) jsonObject.get("name"); // String uname=(String) jsonObject.get("username"); // String pwd=(String) jsonObject.get("password"); // System.out.println("Name: " + name); // System.out.println("EmailId"+uname); // System.out.println("Password"+pwd); // }catch(Exception e) // { // e.printStackTrace(); // } // } // HTTP Get Method @POST // Path: http://localhost/<appln-folder-name>/register/doregister @Path("/doregister") // Produces JSON as response @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) // Query parameters are parameters: // http://localhost/<appln-folder-name>/register/doregister?name=pqrs&username=abc&password=xyz public String doLogin(String json) { JSONObject jsonobject = new JSONObject(json); System.out.println(jsonobject); String name=(String) jsonobject.get("name"); String uname=(String) jsonobject.get("username"); String pwd=(String) jsonobject.get("password"); String response = ""; System.out.println("name"+name); System.out.println("username"+uname); System.out.println("password"+pwd); int retCode = registerUser(name, uname, pwd); if (retCode == 0) { response = Utility.constructJSON("register", "Successfully Registered"); } else if (retCode == 1) { response = Utility.constructJSON("register", "You are already registered"); } else if (retCode == 2) { response = Utility.constructJSON("register", "Special Characters are not allowed in Username and Password"); } else if (retCode == 3) { response = Utility.constructJSON("register", "Error occured"); } return response; } private int registerUser(String name, String uname, String pwd) { System.out.println("Credentials are correct"); int result = 3; if (Utility.isNotNull(uname) && Utility.isNotNull(pwd)) { try { if (DbConnection.insertUser(name, uname, pwd)) { System.out.println("User Registered"); result = 0; } } catch (SQLException sqle) { System.out.println("U are already Registered"); if (sqle.getErrorCode() == 1062) { result = 1; } else if (sqle.getErrorCode() == 1064) { System.out.println(sqle.getErrorCode()); result = 2; } } catch (Exception e) { // TODO Auto-generated catch block System.out.println("Inside checkCredentials catch e "); result = 3; } } else { System.out.println("Inside checkCredentials else"); result = 3; } return result; } @GET @Path("/doselect") @Produces(MediaType.APPLICATION_JSON) public String selectUser() { Connection con = null; String response = ""; ArrayList<String> al = new ArrayList<String>(); try { Class.forName(Constants.dbClass); con = DriverManager.getConnection(Constants.dbUrl, Constants.dbUser, Constants.dbPwd); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from user"); while (rs.next()) al.add(rs.getString(1)); response = Utility.selectJson(al); } catch (Exception e) { e.printStackTrace(); } return response; } @DELETE @Path("/dodelete") public String deleteUser(@QueryParam("username") String uname) { //boolean deleteStatus = false; Connection con = null; String response=""; //int result=2; try { Class.forName(Constants.dbClass); con = DriverManager.getConnection(Constants.dbUrl, Constants.dbUser, Constants.dbPwd); String query="delete from user where username='"+uname+"' "; Statement stmt=con.createStatement(); stmt.executeUpdate(query); System.out.println("Deleted"); response=Utility.constructJSON("deleted", "deleted successsfully"); } catch(Exception e) { e.printStackTrace(); } return response; } } <!-- end snippet -->
0debug
React functional components vs classical components : <p>I'm trying to understand when to use React functional components vs. classes and reading from the <a href="https://facebook.github.io/react/blog/2015/12/18/react-components-elements-and-instances.html" rel="noreferrer">docs</a> they don't really go into detail. Can you give me some primary examples of the below of when you would want a specific feature of a class to make a component?</p> <blockquote> <p>A functional component is less powerful but is simpler, and acts like a class component with just a single render() method. Unless you need features available only in a class, we encourage you to use functional components instead.</p> </blockquote>
0debug
void block_job_pause(BlockJob *job) { job->paused = true; }
1threat
static int kvm_get_fpu(X86CPU *cpu) { CPUX86State *env = &cpu->env; struct kvm_fpu fpu; int i, ret; ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_FPU, &fpu); if (ret < 0) { return ret; } env->fpstt = (fpu.fsw >> 11) & 7; env->fpus = fpu.fsw; env->fpuc = fpu.fcw; env->fpop = fpu.last_opcode; env->fpip = fpu.last_ip; env->fpdp = fpu.last_dp; for (i = 0; i < 8; ++i) { env->fptags[i] = !((fpu.ftwx >> i) & 1); } memcpy(env->fpregs, fpu.fpr, sizeof env->fpregs); memcpy(env->xmm_regs, fpu.xmm, sizeof env->xmm_regs); env->mxcsr = fpu.mxcsr; return 0; }
1threat
document.location = 'http://evil.com?username=' + user_input;
1threat
int av_opt_set_pixel_fmt(void *obj, const char *name, enum AVPixelFormat fmt, int search_flags) { return set_format(obj, name, fmt, search_flags, AV_OPT_TYPE_PIXEL_FMT, "pixel", AV_PIX_FMT_NB-1); }
1threat
How to make a cleaner app in Android just like Clean Master : I'm creating a Cleaner app in android studio...but now i'm stuck... i have create the first two screens that contains a scan button in the first screen and a circleprogress in the 2nd screen... but now i have no idea how to scan apps and find threats and boost them...like in Clean Master and other Cleaner apps.. e.g: [Image: I want these things where i can get it?][1] [1]: https://i.stack.imgur.com/kRZp9.jpg please guide me from where i can get these things that are shown in the above image ..... any github??
0debug
how to remove objects from an array having values that are present in an other simple array (jquery) : I have following two arrays: SimpleArray = [2,3]; ObjectArray = [{id:1, name:charles}, {id:2, name:john}, {id:3, name:alen}, {id:4, name:jack}]; i want to remove objects present in ObjectArray that have id's equal to the values present in SimpleArray. Any help will be appreciated.
0debug
void helper_lswx(CPUPPCState *env, target_ulong addr, uint32_t reg, uint32_t ra, uint32_t rb) { if (likely(xer_bc != 0)) { int num_used_regs = (xer_bc + 3) / 4; if (unlikely((ra != 0 && reg < ra && (reg + num_used_regs) > ra) || (reg < rb && (reg + num_used_regs) > rb))) { helper_raise_exception_err(env, POWERPC_EXCP_PROGRAM, POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_LSWX); } else { helper_lsw(env, addr, xer_bc, reg); } } }
1threat
static void mmubooke_create_initial_mapping(CPUPPCState *env) { struct boot_info *bi = env->load_info; ppcmas_tlb_t *tlb = booke206_get_tlbm(env, 1, 0, 0); hwaddr size, dt_end; int ps; dt_end = bi->dt_base + bi->dt_size; ps = booke206_page_size_to_tlb(dt_end) + 1; if (ps & 1) { ps++; } size = (ps << MAS1_TSIZE_SHIFT); tlb->mas1 = MAS1_VALID | size; tlb->mas2 = 0; tlb->mas7_3 = 0; tlb->mas7_3 |= MAS3_UR | MAS3_UW | MAS3_UX | MAS3_SR | MAS3_SW | MAS3_SX; env->tlb_dirty = true; }
1threat
static int decode_frame_mp3on4(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MP3On4DecodeContext *s = avctx->priv_data; MPADecodeContext *m; int fsize, len = buf_size, out_size = 0; uint32_t header; OUT_INT *out_samples; OUT_INT *outptr, *bp; int fr, j, n, ch, ret; s->frame->nb_samples = MPA_FRAME_SIZE; if ((ret = avctx->get_buffer(avctx, s->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; out_samples = (OUT_INT *)s->frame->data[0]; if (buf_size < HEADER_SIZE) outptr = s->frames == 1 ? out_samples : s->decoded_buf; avctx->bit_rate = 0; ch = 0; for (fr = 0; fr < s->frames; fr++) { fsize = AV_RB16(buf) >> 4; fsize = FFMIN3(fsize, len, MPA_MAX_CODED_FRAME_SIZE); m = s->mp3decctx[fr]; assert(m != NULL); header = (AV_RB32(buf) & 0x000fffff) | s->syncword; if (ff_mpa_check_header(header) < 0) break; avpriv_mpegaudio_decode_header((MPADecodeHeader *)m, header); if (ch + m->nb_channels > avctx->channels) { av_log(avctx, AV_LOG_ERROR, "frame channel count exceeds codec " "channel count\n"); ch += m->nb_channels; out_size += mp_decode_frame(m, outptr, buf, fsize); buf += fsize; len -= fsize; if (s->frames > 1) { n = m->avctx->frame_size*m->nb_channels; bp = out_samples + s->coff[fr]; if (m->nb_channels == 1) { for (j = 0; j < n; j++) { *bp = s->decoded_buf[j]; bp += avctx->channels; } else { for (j = 0; j < n; j++) { bp[0] = s->decoded_buf[j++]; bp[1] = s->decoded_buf[j]; bp += avctx->channels; avctx->bit_rate += m->bit_rate; avctx->sample_rate = s->mp3decctx[0]->sample_rate; s->frame->nb_samples = out_size / (avctx->channels * sizeof(OUT_INT)); *got_frame_ptr = 1; *(AVFrame *)data = *s->frame; return buf_size;
1threat
Java AssertEquals on 2 Strings Using Regex : I have 2 `Strings`: `String actual = "abcd1234efgh";` `String expected = "abcd5678efgh";` The number part will always be different. They are `HBase` `Put` timestamps that are generated at the time of the creation of the `Put` object. How can I make `AssertEquals` return `true` to these `Strings` the most efficient way possible?
0debug
SQL: Need to select items by different conditions : <p><strong>My table looks like this -</strong> <a href="https://i.stack.imgur.com/yhpqJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yhpqJ.png" alt="enter image description here"></a></p> <p><strong>Explanation</strong><br> I'm working on an online shop that sells <strong>tours</strong> and <strong>spa</strong>. I'm showing all together on one page.</p> <p></p> <p><strong>What I need to select?</strong><br> 1. All spa products (based on "Spa" column), no conditions.<br> 2. All parent tours that have children with an upcoming date.</p> <p></p> <p><strong>Meaning</strong><br> Products ID 1, 4, 5.</p> <p></p> <p><strong>Why?</strong><br> Product 6 have a child, but from 1999. And although product 1 have one child at 2000, it has another one in 2017. All spa products are selected by default, without conditions.</p> <p><br><i>I hope I made my question clear as I could. I would appreciate any help, my SQL is really bad.</i></p>
0debug
capture output from .each_with_index, ignore the return - Ruby : I want to capture the string output and append it to another string. I cannot figure that out and am currently trying to append the return, which is an array, to a string, causing an error. 2.2.3 :001 > deli_line = ["stuff", "things", "people", "places"] => ["stuff", "things", "people", "places"] 2.2.3 :002 > deli_line.each_with_index do |x, i| print "#{i+1}. #{x} " end 1. stuff 2. things 3. people 4. places => ["stuff", "things", "people", "places"] I care about capturing "1. stuff 2. things 3. people 4. places" as a string. then I want to do string1 += "1. stuff 2. things 3. people 4. places"
0debug
How to setup a pipenv Python 3.6 project if OS Python version is 3.5? : <p>My Ubuntu 16.04.03 is installed with Python 3.5.2. How do I setup pipenv to use Python 3.6 when my system does not have python 3.6? </p> <pre><code>$ pipenv --python 3.6 Warning: Python 3.6 was not found on your system… You can specify specific versions of Python with: $ pipenv --python path/to/python </code></pre>
0debug
static TranslationBlock *tb_find_slow(target_ulong pc, target_ulong cs_base, uint64_t flags) { TranslationBlock *tb, **ptb1; int code_gen_size; unsigned int h; target_ulong phys_pc, phys_page1, phys_page2, virt_page2; uint8_t *tc_ptr; spin_lock(&tb_lock); tb_invalidated_flag = 0; regs_to_env(); phys_pc = get_phys_addr_code(env, pc); phys_page1 = phys_pc & TARGET_PAGE_MASK; phys_page2 = -1; h = tb_phys_hash_func(phys_pc); ptb1 = &tb_phys_hash[h]; for(;;) { tb = *ptb1; if (!tb) goto not_found; if (tb->pc == pc && tb->page_addr[0] == phys_page1 && tb->cs_base == cs_base && tb->flags == flags) { if (tb->page_addr[1] != -1) { virt_page2 = (pc & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; phys_page2 = get_phys_addr_code(env, virt_page2); if (tb->page_addr[1] == phys_page2) goto found; } else { goto found; } } ptb1 = &tb->phys_hash_next; } not_found: tb = tb_alloc(pc); if (!tb) { tb_flush(env); tb = tb_alloc(pc); tb_invalidated_flag = 1; } tc_ptr = code_gen_ptr; tb->tc_ptr = tc_ptr; tb->cs_base = cs_base; tb->flags = flags; cpu_gen_code(env, tb, CODE_GEN_MAX_SIZE, &code_gen_size); code_gen_ptr = (void *)(((unsigned long)code_gen_ptr + code_gen_size + CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1)); virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK; phys_page2 = -1; if ((pc & TARGET_PAGE_MASK) != virt_page2) { phys_page2 = get_phys_addr_code(env, virt_page2); } tb_link_phys(tb, phys_pc, phys_page2); found: env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)] = tb; spin_unlock(&tb_lock); return tb; }
1threat
static inline void gen_neon_negl(TCGv var, int size) { switch (size) { case 0: gen_helper_neon_negl_u16(var, var); break; case 1: gen_helper_neon_negl_u32(var, var); break; case 2: gen_helper_neon_negl_u64(var, var); break; default: abort(); } }
1threat
How can I make this rxjava zip to run in parallel? : <p>I have a sleep method for simulating a long running process.</p> <pre><code>private void sleep() { try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } } </code></pre> <p>Then I have a method returns an Observable containing a list of 2 strings that is given in the parameters. It calls the sleep before return the strings back.</p> <pre><code>private Observable&lt;List&lt;String&gt;&gt; getStrings(final String str1, final String str2) { return Observable.fromCallable(new Callable&lt;List&lt;String&gt;&gt;() { @Override public List&lt;String&gt; call() { sleep(); List&lt;String&gt; strings = new ArrayList&lt;&gt;(); strings.add(str1); strings.add(str2); return strings; } }); } </code></pre> <p>Then I am calling the getStrings three times in Observalb.zip, I expect those three calls to run in parallel, so the total time of execution should be within <strong>2 seconds</strong> or maybe 3 seconds the most because the sleep was only 2 seconds. However, it's taking a total of <strong>six</strong> seconds. <strong>How can I make this to run in parallel so it will finish within 2 seconds?</strong></p> <pre><code>Observable .zip(getStrings("One", "Two"), getStrings("Three", "Four"), getStrings("Five", "Six"), mergeStringLists()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer&lt;List&lt;String&gt;&gt;() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { } @Override public void onNext(List&lt;String&gt; strings) { //Display the strings } }); </code></pre> <p>The mergeStringLists method</p> <pre><code>private Func3&lt;List&lt;String&gt;, List&lt;String&gt;, List&lt;String&gt;, List&lt;String&gt;&gt; mergeStringLists() { return new Func3&lt;List&lt;String&gt;, List&lt;String&gt;, List&lt;String&gt;, List&lt;String&gt;&gt;() { @Override public List&lt;String&gt; call(List&lt;String&gt; strings, List&lt;String&gt; strings2, List&lt;String&gt; strings3) { Log.d(TAG, "..."); for (String s : strings2) { strings.add(s); } for (String s : strings3) { strings.add(s); } return strings; } }; } </code></pre>
0debug
def len_log(list1): min=len(list1[0]) for i in list1: if len(i)<min: min=len(i) return min
0debug
Sort object in array with dynamic object keys : <p>I have an array with a single object populated like so:</p> <pre><code>valueArr = [{ 485: 201.5897, 487: 698.52, 598: 351.85, ... year: '2016' }]; </code></pre> <p>Now, i want to rearange / sort the object from largest - smallest value. The Ouptput i'm looking for would be something like this:</p> <pre><code>valueArr = [{ 487: 698.52, 598: 351.85, 485: 201.5897, ... year: '2016' }]; </code></pre> <p>NOTE: The "year"-property should be excluded in the sorting. There is only one property of this inside the object. </p> <p>Is it possible to rearange/sort an object like this? </p>
0debug
Python, choose logging files' directory : <p>I am using the Python logging library and want to choose the folder where the log files will be written.</p> <p>For the moment, I made an instance of TimedRotatingFileHandler with the entry parameter filename="myLogFile.log" . This way myLogFile.log is created on the same folder than my python script. I want to create it into another folder.</p> <p>How could I create myLogFile.log into , let's say, the Desktop folder?</p> <p>Thanks, Matias </p>
0debug
Simplest examples demonstrating the need for nominal type role in Haskell : <p>I'm trying to understand what determines whether a type parameter must be nominal.</p> <p>While GADTs and type familes seem different in the sense they are not "simple containers" as their instance definitions can "look at" their parameters, can simple types have obvious need for nominal parameters, like Set?</p>
0debug
Using factory to call different ActionResult? : <p>I have a dropdown in my view which is something like 'All, Read/Unread, Categories'. The view renders notifications for a user.</p> <p>In the controller there's a default ActionResult to show all, one for read/unread, and one for something to do with categories. </p> <p>I would like to use a factory to call one of the methods based on the dropdown selected as above (i.e unread selected calls unread ActionResult, the reason being I don't want to use switch/if statements to maintain maintainable code, I'm just not sure of the implementation.</p>
0debug
How can solve JSON column in H2 : <p>I use in application MySQL 5.7 and I have JSON columns. When I try running my integration tests don't work because the H2 database can't create the table. This is the error:</p> <pre><code>2016-09-21 16:35:29.729 ERROR 10981 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: create table payment_transaction (id bigint generated by default as identity, creation_date timestamp not null, payload json, period integer, public_id varchar(255) not null, state varchar(255) not null, subscription_id_zuora varchar(255), type varchar(255) not null, user_id bigint not null, primary key (id)) 2016-09-21 16:35:29.730 ERROR 10981 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : Unknown data type: "JSON"; SQL statement: </code></pre> <p>This is the entity class.</p> <pre><code>@Table(name = "payment_transaction") public class PaymentTransaction extends DomainObject implements Serializable { @Convert(converter = JpaPayloadConverter.class) @Column(name = "payload", insertable = true, updatable = true, nullable = true, columnDefinition = "json") private Payload payload; public Payload getPayload() { return payload; } public void setPayload(Payload payload) { this.payload = payload; } } </code></pre> <p>And the subclass:</p> <pre><code>public class Payload implements Serializable { private Long userId; private SubscriptionType type; private String paymentId; private List&lt;String&gt; ratePlanId; private Integer period; public Long getUserId() { return userId; } public void setUserId(Long userId) { this.userId = userId; } public SubscriptionType getType() { return type; } public void setType(SubscriptionType type) { this.type = type; } public String getPaymentId() { return paymentId; } public void setPaymentId(String paymentId) { this.paymentId = paymentId; } public List&lt;String&gt; getRatePlanId() { return ratePlanId; } public void setRatePlanId(List&lt;String&gt; ratePlanId) { this.ratePlanId = ratePlanId; } public Integer getPeriod() { return period; } public void setPeriod(Integer period) { this.period = period; } } </code></pre> <p>And this converter for insert in database:</p> <pre><code>public class JpaPayloadConverter implements AttributeConverter&lt;Payload, String&gt; { // ObjectMapper is thread safe private final static ObjectMapper objectMapper = new ObjectMapper(); private Logger log = LoggerFactory.getLogger(getClass()); @Override public String convertToDatabaseColumn(Payload attribute) { String jsonString = ""; try { log.debug("Start convertToDatabaseColumn"); // convert list of POJO to json jsonString = objectMapper.writeValueAsString(attribute); log.debug("convertToDatabaseColumn" + jsonString); } catch (JsonProcessingException ex) { log.error(ex.getMessage()); } return jsonString; } @Override public Payload convertToEntityAttribute(String dbData) { Payload payload = new Payload(); try { log.debug("Start convertToEntityAttribute"); // convert json to list of POJO payload = objectMapper.readValue(dbData, Payload.class); log.debug("JsonDocumentsConverter.convertToDatabaseColumn" + payload); } catch (IOException ex) { log.error(ex.getMessage()); } return payload; } } </code></pre>
0debug
static void pnv_chip_power8e_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PnvChipClass *k = PNV_CHIP_CLASS(klass); k->cpu_model = "POWER8E"; k->chip_type = PNV_CHIP_POWER8E; k->chip_cfam_id = 0x221ef04980000000ull; k->cores_mask = POWER8E_CORE_MASK; k->core_pir = pnv_chip_core_pir_p8; dc->desc = "PowerNV Chip POWER8E"; }
1threat
How to use a C++ function to pass back a number : <p>I am new to C++ and using functions is still a bit unclear. I have a program started as follows below, but I keep getting compile errors that I do not understand how to fix. I feel like this is a simple fix, but I just am not seeing how to fix it.</p> <pre><code>#include &lt;iostream&gt; #include &lt;iomanip&gt; #include &lt;cstdlib&gt; #include &lt;ctime&gt; using namespace std; int roll (); int main() { srand(time(NULL)); int die1; diel = int roll(); cout &lt;&lt; die1; } int roll() { return rand()%6+1; } </code></pre> <p>Then, the compile error</p> <pre><code>dice.cpp: In function ‘int main()’: dice.cpp:15: error: ‘diel’ was not declared in this scope dice.cpp:15: error: expected primary-expression before ‘int’ dice.cpp:15: error: expected `;' before ‘int’ </code></pre>
0debug