Posts

Showing posts from May, 2013

java - Error:Content is not allowed in prolog2.0 -

Image
when go make build project in android studio ,i found problem > new android studio ,pleas me! the error> error:content not allowed in prolog.

Netbeans Screen is too tiny -

Image
i installed netbeans, , when changed theme dracula, whole appearance changed tiny window. how change normal size?

spotify - Automate\Control Spofity remotely -

i looking way automate spotify, either through controlling desktop application or through api allow me access data directly. wanting send commands control play of music. know can through web automation, there other ways this. you can use spotify connect api control playback on spotify. can read more them here , documentation here .

python - django with apache - website doesn't show properly -

Image
i try handle website running on apache redirected django (wsgi). after full day of looking online able restart apache , achieve that: website: and default-ssl.conf: https://jpst.it/13qru any appreciated!

html - Get value from input and store it to the object Javascript -

how can value input , store object? when button clicked value input - should stored in object. thank lot in advance var testobject = { 'name': nameofbook.value, 'author': nameofauthor.value, 'year': year.value }; console.log(testobject); <input type="text" id="nameofbook" required="" placeholder="book name" /> <input type="text" id="nameofauthor" required="" placeholder="athor name" /> <input type="text" id="year" required="" placeholder="add year" /> <button id="addder" type="button">storeemail</button> here's working jsfiddle you. the relevant js code here. using id tags on html elements, got of elements , stored them variables. next, added event listener on button, , on click,...

function - onmouseover Event in For Loop JavaScript Supplies Incorrect Arguments -

this question has answer here: javascript closure inside loops – simple practical example 31 answers so, have loop , array. in each of elements in array buttons, want have onmouseover event. note: code simplified make point. for(i = 0; < array.length; i++){ var button = document.createelement("button"); button.onmouseover = function() {dosomething(i)}; } where dosomething accepts 1 parameter, i . when cursor hover on of butttons, argument supplied dosomething - i , length of array , regardless of button cursor hovering over. why happen, , can ensure correct arguments supplied function? you binding variable, not value. i.e. have created closure in functions utilize same variable i , not new variable value of i . what need lock in value , 1 way can create function generator , invoke current value of i . e.g. for(i = 0; <...

sql - Is there a nesting limit for `and` `or` in MySQL? -

here code understand question: select * table1 ((((field1=value1 , field2=value2) or field3=value3) , field4=value4) or field5=value5) ... the parse tree composed of and or . there nesting limit parse tree in mysql?

r - Split-apply-combine with function that returns multiple variables -

i need apply myfun subsets of dataframe , include results new columns in dataframe returned. in old days, used ddply . in dplyr , believe summarise used that, this: myfun<- function(x,y) { df<- data.frame( a= mean(x)*mean(y), b= mean(x)-mean(y) ) return (df) } mtcars %>% group_by(cyl) %>% summarise(a = myfun(cyl,disp)$a, b = myfun(cyl,disp)$b) the above code works, myfun i'll using computationally expensive, want called only once rather separately a , b columns. there way in dplyr ? since function returns data frame, can call function within group_by %>% do applies function each individual group , rbind returned data frame together: mtcars %>% group_by(cyl) %>% do(myfun(.$cyl, .$disp)) # tibble: 3 x 3 # groups: cyl [3] # cyl b # <dbl> <dbl> <dbl> #1 4 420.5455 -101.1364 #2 6 1099.8857 -177.3143 #3 8 2824.8000 -345.1000

python - pip install package not responsive on Jupyter notebook -

Image
i attempting install package within jupyter notebook so: i assume successful because next bit comes up: however, when attempt use module package little later in notebook unable accomplish , presented following error: i thoroughly confused why happening , how can troubleshoot this? thanks

php - How to return data in loop for WP REST API? -

Image
function getprogramtourinfobyid(){ $data = getprogramtourinfobycate(); //print_r($data); foreach ($data $key => $id) { //echo( $id); $count =0; while( have_rows('package_scd', $id ) ): the_row(); //if(get_sub_field('start_date') != null){ //echo $id."\r\n"; $array[$count] = array( 'id' => $id , 'title' => get_the_title($id), 'url' => get_the_permalink($id), 'start' => get_sub_field('start_date'), 'end' => get_sub_field('end_date'), 'price_single_room' => get_sub_field('price_single_room'), 'price_adult' => get_sub_field('price_adult'), ...

python - file is backwards, literally -

Image
i have file looking at. when open in hex editor, start shows 00 00 while bottom shows 64 c4 54 f7. magic bytes elf 7f 45 4c 46 reverse of that. using python try , flip program around, when f7 54 c4 64 instead of desired 7f 45 4c 46. here code using import sys if len(sys.argv) < 2: print "error: 1 argument required!" exit(-1) try: f1 = open(sys.argv[1], 'r') except ioerror: print "error: file cannot opened." exit(-1) # else lines = [] line in f1: line = line.replace('\n', '') reversedline = line[::-1] lines.append(reversedline) f1.close() reversedlines = lines[::-1] line in reversedlines: print line any appreciated l = [] open(sys.argv[1], 'rb') f: ch = f.read(1) while ch != "": byte = ord(ch) reverse_byte = chr((byte & 15) << 4 | byte >> 4) l.insert(0, reverse_byte) ch = f.read(1) open(sys.argv[1], 'wb...

php - how to select specific columns in laravel -

i want show values of 2 specified columns 'first_name' , 'pic' 'users' table. trying 'pluck' showing json format when echo. need show it, - 'john pic' all.please, me. here sample code in 'index.blade.php' bellow - <?php $fname = db::table('users')->pluck('first_name','pic'); echo $fname; ?> use can use select $fname = db::table('users')->select('first_name','pic')->get(); since, direct access database view not preferred, can write query in controller function, public function getdata(){ $fname = db::table('users')->select('first_name','pic')->get(); return view('index',compact('fname')); } now, iterate on loop in view file, @foreach($fname $name) // access data {{$name->first_name}} , {{$name->pic}} @endforeach hope understand.

sql query to count two type in single cloumn -

buses ---------------- |bus_no |bus_name |type |avail_seat i have calculate how many ac , non ac buses there? my query count is: count(*)bus_count sum(case when type='ac' 1 else 0) sum (case when type="non ac" 1 else 0) buses group bus_number; assuming there 2 values in 'type' column, following query work: select type, count (*) bus_count bus group 1;

sql - How to check if the table is exist in mssql -

how can check if multiple tables exist in ms-sql? for example want check if these 5 tables exist: (log_2017_06_01 , log_2017_06_02 , log_2017_06_03, log_2017_06_04, log_2017_06_05) i want 5 tables each exist result sql. how should that? select * master.dbo.sysdatabases name = 'log_2017_06_01' select * master.dbo.sysdatabases name = 'log_2017_06_02' select * master.dbo.sysdatabases name = 'log_2017_06_03' select * master.dbo.sysdatabases name = 'log_2017_06_04' select * master.dbo.sysdatabases name = 'log_2017_06_05' or simpler: select * master.dbo.sysdatabases name 'log_2017_06_%' and if want check of them exist: select * master.dbo.sysdatabases name in ('log_2017_06_01','log_2017_06_02','log_2017_06_03','log_2017_06_04','log_2017_06_05')

lua - NodeMCU gpio triggering incorrectly -

i'm attempting read ir information nodemcu running lua 5.1.4 master build of 8/19/2017. i might misunderstanding how gpio works , i'm having hard time finding examples relate i'm doing. pin = 4 pulse_prev_time = 0 ircallback = nil function trgpulse(level, now) gpio.trig(pin, level == gpio.high , "down" or "up", trgpulse) duration = - pulse_prev_time print(level, duration) pulse_prev_time = end function init(callback) ircallback = callback gpio.mode(pin, gpio.int) gpio.trig(pin, 'down', trgpulse) end -- example print("monitoring ir") init(function (code) print("omg got something", code) end) i'm triggering initial interrupt on low, , alternating low high in trgpulse . in doing i'd expect levels alternate 1 0 in perfect pattern. output shows otherwise: 1 519855430 1 1197 0 609 0 4192 0 2994 1 589 1 2994 1 1198 1 3593 0 4201 1 23357 0 608 0 5390 1 1188 1 4191 ...

groovy - How to create and save data on the go in Grails? -

i have 2 domain classes expenditure class expenditure { date date supplier supplier string particular bigdecimal amount } supplier class supplier { string name string address static hasmany = [expenditures: expenditure] } what happening when create new expenditure, enter supplier list of suppliers in supplier class. when supplier not exist, have create first , select when creating expenditure. what want that, when enter supplier looked up, , when not found, created on go (when saving expenditure instance) without me having create first in supplier table , come expenditure complete form. how can achieve this? what want that, when enter supplier looked up, , when not found, created on go one option have 1 of these... supplier.findorcreatebyname('some name goes here') supplier.findorcreatebynameandaddress('some name goes here', 'some address goes here') there findorsaveby... counterparts work if supplyin...

javascript - How to make API calls with server side rendering in React -

i have server side rendering , running having trouble figuring out how include data external api in renders. here core files. server.js import express 'express' import react 'react' import { rendertostring } 'react-dom/server' import { staticrouter } 'react-router-dom' import template './template' // html template import app './client' const server = express() server.get('*', (req, res) => { const context = {} const appstring = rendertostring( <staticrouter location={req.url} context={context}> <app/> </staticrouter> ); res.send(template({ body: appstring, title: 'ssr', })); }); const port = 8080; server.listen(port); console.log(listening on port ${port}) client.js import react 'react'; import { render } 'react-dom' import { router, browserrouter, route, switch } 'react-router-dom' import home './containers/home' const ...

android - Could not find com.github.afollestad.material-dialogs:commons:0.8.6.2 -

i using material dialogs lib in android application. imported module , lib gradle. have checked thread could not find com.affolestad.material-dialogs have thats suggested there. don't know when sync looks other version of lib. in build.gradle 0.9.4.7 looks 0.8.6.2 module build.gradle buildscript { repositories { jcenter() google() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0-beta2' } } apply plugin: 'com.android.library' android { compilesdkversion 26 buildtoolsversion "26.0.1" defaultconfig { minsdkversion 16 targetsdkversion 26 versioncode 1 versionname "1.0" } } repositories { maven { url "https://jitpack.io" } jcenter() } dependencies { compille 'com.facebook.react:react-native:+' compille filetree(include: ['*.jar'], dir: 'libs') testcompile 'junit:junit:4.12...

javascript - Preventing default behavior for tab stops listeners from working -

i trying dynamically create input field , implement tab autocomplete feature. unfortunately, whenever listen tab , call preventdefault on keydown event stop tab focusing on other fields, keypress listener cannot register tab. var element = document.createelement("input"); //assign different attributes element. element.setattribute("type", "text"); element.setattribute("value", ""); element.setattribute("name", "test name"); element.setattribute("spellcheck", "false"); element.setattribute("style", "width:400px"); element.classlist.add('text'); element.onkeydown = function(e) { if(e.keycode == 9){ e.preventdefault(); } } element.onkeypress = function(e) { if (!e) e = window.event; var keycode = e.keycode || e.which; if (keycode == 13){ // code } else if(keycode == 9) { console.log("detected"); //never p...

Issue in submitting and updating the safari extension -

i have safari extension in gallery. now made few minor changes in code , resubmitted review (it takes month review, :( long time) after month, received email safari , extension rejected because of issue please strip extended attributes ( xattr -c path/to/extension.safariextension ) , rebuild safari extension package using latest version of safari. i tried above command every time face same issue. and confused if every time updtae code, need resubmit extension review, use of link: https://developer.apple.com/library/content/documentation/tools/conceptual/safariextensionguide/updatingextensions/updatingextensions.html also, when going through this, got email safari certificate (which used in extension builder create .extz file) going expire in month created new certificate , created new extz file. but don't know need resubmit extension or update on webserver. so have 3 issues/ confusions do need resubmit extension everytime update code or updating extz on web...

android - Keep fragment state/data in BottomNavigationView -

i've mainactivity following layout: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@color/lighter_gray" tools:context="com.rewardsme.merchant.activities.mainactivity"> <framelayout android:layout_margintop="?attr/actionbarsize" android:id="@+id/content" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> ...

java - Printing a string input from scanner with leading whitespaces -

i have input scanned of int type , trying take second input of string type has whitespaces @ beginning, , while printing both inputs, want second 1 printed (with white spaces). class input{ public static void main (string[] args) throws java.lang.exception{ scanner sc=new scanner(system.in); int n=sc.nextint(); string s=sc.next(); s=s+sc.nextline(); system.out.println(n); system.out.println(s); } } input: 4 hello world. expected output: 4 hello world. actual output: 4 hello world. scanner.next() uses default delimiter, capture whitespace sequence. use scanner.nextline() instead: int n = sc.nextint(); sc.nextline(); // consume newline string s = sc.nextline(); ideone demo

c# - I have created a .rdlc-Report under VS 2012 using the report i want to assign data source and report name at run time -

i have many reports project , have report viewer , want open reports in viewer, viewer data source assigned @ run time , report name also dataset ds = new dataset(); datatable dt = new datatable(); using (sqlcommand cmd = new sqlcommand("r_purchase_order_detail", parent.v_connection)) { cmd.commandtype = commandtype.storedprocedure; cmd.parameters.add(new sqlparameter("start_code", sqldbtype.varchar)).value = "0000000000"; cmd.parameters.add(new sqlparameter("end_code", sqldbtype.varchar)).value = "9999999999"; cmd.executenonquery(); sqldataadapter da = new sqldataadapter(cmd); da.fill(ds); } reportviewer1.processingmode = processingmode.local; reportviewer1.localreport.reportpath = @"e:\businessbook\businessbook\businessbook\zreports\purchase\r_purchase_order_detail.rdlc"; reportdatasource datasource = new reportdatasource("r_purchase_order_detail", ds.tables[0]); this...

How to perform Mathematical operations in Mysql through php and Mysql? -

i new mysql , have faced problem while learning:- created table named "x" in mysql 10 columns , wrote code in php enter data table form in first 8 columns of table , in column 9 need value obtained after performing mathematical operation on value in column 2. instance, have marks every student in column 2 of table , in column 9, need percentage (considering total marks constant). how can percentage in column 9 , update on every row of column 9? remember table in database in mysql. before inserting value column, make sure perform necessary calculation on incoming value. e.g $column2 = $_post['column2_field']; $calculation = $column2 * 50/100 //50 percent

Failed to deploy Artifactory OSS image in Openshift Online 3 Starter by error "Creating user artifactory failed" -

Image
i'm trying setup artifactory on openshift online 3 starter using docker image docker.bintray.io/jfrog/artifactory-oss:latest from here but when deploying got error i tried create artifactory user command oc create serviceaccount artifactory , oc adm policy add-scc-to-user anyuid -z artifactory has error: error server (forbidden): user "xxxx" cannot securitycontextconstraints @ cluster scope you need cluster admin in order able run: oc adm policy add-scc-to-user anyuid -z artifactory this because granting right run things user id, including root . normal user aren't allowed do. further, in openshift online can run things in user id range assigned. cannot override that, nor granted additional privileges. you need find version of image doesn't require run root , can run arbitrary user id.

php - How to get url in <a> tag with Simple HTML DOM Parser? -

<ul id="prlist" class="v2"> <li class="tools"> </li> <li class="firstrow"> <div class="i"> <a href="www.google.com" title="google" class="nc"> <img src="something"> </a> </div> </li> </ul> how href attribute in <div class="i"> ? i tried this- $html = file_get_html($link); $urls = []; foreach($html->find('.i') $element) { $url = $element->find('.nc')->href; if (!in_array($url, $urls)) { echo $url . "<br/>"; $urls[] = $url; } } but received error:- notice: trying property of non-object and tried:- $html = file_get_html($link); $html = $html->find('div.i'); $html -> find('a',0)->href; $echo $html; but received error again:- fatal ...

javascript - Why iframe player only destroy once -

when refresh page click on button popup shows , youtube video play via iframe , when close popup closes when play same video (without refreshing page), popup shows video played successfully. when click on close button, shows in console: "cannot read property 'id' of null". destroy player every time when click on close button. $('#clicktoplayvideo').click(function(){ $('#popup').show(); var player; ytdeferred.done(function(yt) { player = new yt.player('player', { height: '390', width: '640', videoid: 'osyqj2luhmw', events: { 'onready': onplayerready, } }); $('#closev').click(function(){ player.destroy(); document.getelementbyid('abc').style.display = "none"; }); }); function onplayerready(event) { event.target.playvideo(); player.addeventlistener("onstatechange", "myvar"); } ...

ios - perform segue from UIView -

i have viewcontroller , there uiview in it. this uiview has separate class myview , there many ui elements - 1 of them collectionview. what want perform segue when 1 of collection elements in myview selected. when try add line performsegue(withidentifier: "myidintifier", sender: self) to collection's view didselectitemat method error use of unresolved identifier 'performsegue' and understand because inside class extends uiview , not uiviewcontroller. so how can perfrom segue in case? , how can prepare segue? here going evaluate in step step manner. step - 1 create custom delegate using protocol below snippet guide on custom uiview. protocol must exist out of custom view scope. protocol celltapped: class { /// method func cellgottapped(indexofcell: int) } don't forgot create delegate variable of above class below on custom view var delegate: celltapped! go collection view didselect method below func collec...

return to startscreen of javascript video jukebox doesnot go -

i have installed small video jukebox stat can seen via link ... at first initial screen picture shown, fine. after 1 can choose via dropdown or vorige/volgende button video 1 see. however, when afterwards returning initial field of drop down (where shows: ... maak hier je keuze ... not show initial picture. what doing wrong here? how solve? advise highly appreciated. related script following: <style> .txt3 { font-weight: normal; font-size: 100%; font-weight: bold; font-family: verdana; } .txt4 { font-weight: normal; font-size: 100%; font-weight: bold; font-family: verdana; margin-top: 2px; margin-left: 0px; color:#000000; background: #f3fed0; border: 2px solid #92ad34; } .wrap { text-align:center } #div1 { display: inline-block; border: 2px solid red; float: left; } #div2 { display: inline-block; text-align: center; border: 0px solid green; } #div3 { display: inline-block; border: 2px sol...

Unable to drag and drop widgets in Grid layout after adding two widgets in GridLayout in Android Studio 2.3.3 -

i using android 2.3.3 , new android development. unable drag , drop widget in gridlayout more 2. when want place 3rd in row or column, not added. have gone through replies available here no 1 works me. here code: <?xml version="1.0" encoding="utf-8"?> <android.widget.relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.firstapplication.gridlayoutlatest.mainactivity"> <gridlayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignparentstart="true" android:layout_alignparenttop="true" android:layout_marginstart="0dp" ...

java - OkHTTP3 in Android -

i use okhttp3 in android studio 2.2.3 on simple project. project run on emulator (nexus 5 android 7 api 24) without problem in phones (lg k10 android 6 api 23) , (huawei honor 4x api 19) crashed , has stopped. use okhttp3 package com.squareup.okhttp3:okhttp:3.4.1 in project module:app is-> (compilesdkversion 25 buildtoolsversion "25.0.1" defaultconfig { applicationid "android.hrsh.okhttpv2" minsdkversion 15 targetsdkversion 25) my code is: okhttpclient client = new okhttpclient(); request request = new request.builder() .url("http://www.imodares.ir/json-url/imodares-json.html") .build(); callback callback = new callback() {...} try { client.newcall(request).enqueue(callback); } catch (exception e ){label.settext(e.getmessage());} i test code client.newcall(request).execute(); but same result please guide me thanks is possible test debug apk on emulator ...

typescript - Using Angular timer in ionic3 -

i using angular timer(i.e. http://siddii.github.io/angular-timer/index.html#/markup5 ) in ionic3, when put timer tag in html page, have error. don’t know need do. <timer end-time="{{timelimit.timelimitdate}}">{{days}} days, {{hours}} hours, {{minutes}} minutes, {{seconds}} seconds.</timer> the error: unhandled promise rejection: template parse errors: 'timer' not known element: 1. if 'timer' angular component, verify part of module. 2. allow element add 'no_errors_schema' '@ngmodule.schemas' of component. ("ate}}">{{days}} days, {{hours}} hours, {{minutes}} minutes, {{seconds}} seconds.</timer>--> did know need do, lot~ you can not use above timer ionic 3 .because uses angularjs .you need find angular module that. i think can use ng2-simple-timer module on ionic app. add simpletimer module providers (eg. app.module.ts ). import { simpletimer } 'ng2-simple-timer'; @ngmo...

vim - How to remove macvim left side menu -

Image
i want know how remove left part don't know how name using macvim. have tried below code in .vimrc . :set guioptions-=m "remove menu bar :set guioptions-=t "remove toolbar :set guioptions-=r "remove right-hand scroll bar :set guioptions-=l "remove left-hand scroll bar but left menu still there. the side pane see, nerdtree , can toggled mapping key of convenience, example f6 here. :nnoremap <f6> :nerdtreetoggle<cr> you can use :nerdtreeclose close toggling save keystrokes.

javascript - JS alert popup should stay on same page without reloading it -

the below alert popup displayed in case of error , user should stay on same page in order modify content of field. task have popup message when closed, let user on same page without reloading , showing him values put in fields. .... else{ echo " <script type='text/javascript'> alert ('error message.'); return false; </script> ";} i put 'return false' in order avoid redirect doesn'work.

ubuntu - md5sum of a file without file name assigning to a variable in python -

i'm trying assign md5 sum of file (in ubuntu) variable(any) in python script below alist=subprocess.check_output(["md5sum",filename]) i want assign sum variable used below code it's not working alist=subprocess.check_output(["md5sum",filename," | awk '{print $1}'"]) please me find out solution thanks in advance rather shelling out perform md5sum, use python's inbuilt hashlib.md5 implementation: import hashlib open(filename, 'rb') f: hexdigest = hashlib.md5(f.read()).hexdigest() print(hexdigest)

Passing Array of Objects OR Array of Arrays Between Python & C++ Library -

i've extern "c" declaration of c++ function, compiled part of shared library on ubuntu, getvphistory void getvphistory(actorpos allpostions[], uint numact, uint numdim, uint numstate) { uint actordimpaircount = numact * numdim; uint actordimpairindex = 0; float val = 1.0; (uint actor = 0; actor < numact; ++actor) { (uint dim = 0; dim < numdim; ++dim) { actorpos *ap = &allpostions[actordimpairindex]; ++actordimpairindex; ap->actor = actor; ap->dim = dim; ap->nstate = numstate; (uint state = 0; state < numstate; ++state) { ap->pos[state] = val; val += 0.5; // incrementing testing } } } } the actorpos object defined as: using actorpos = struct singleactorpositions { unsigned int actor; unsigned int dim; unsigned int nstate; float pos[1000]; // possible upper limit of nstate }; i'm using ctypes in python try use function, following code: import ctypes c actorcnt = 2 dimensio...

Asterisk AGI Python Script completed, returning 0 -

i used online tutorial run python script in asterisk using agi. returns, agi script easy.py completed, returning 0 so enabled debug mode , got output. agi debugging enabled == using sip rtp tos bits 184 == using sip rtp cos mark 5 -- executing [0112617769@from-trunk:1] answer("sip/obitrunk1-0000000b", "") in new stack -- executing [0112617769@from-trunk:2] agi("sip/obitrunk1-0000000b", "easy.py") in new stack -- launched agi script /var/lib/asterisk/agi-bin/easy.py <sip/obitrunk1-0000000b>agi tx >> agi_request: easy.py <sip/obitrunk1-0000000b>agi tx >> agi_channel: sip/obitrunk1-0000000b <sip/obitrunk1-0000000b>agi tx >> agi_language: en <sip/obitrunk1-0000000b>agi tx >> agi_type: sip <sip/obitrunk1-0000000b>agi tx >> agi_uniqueid: 1503228907.11 <sip/obitrunk1-0000000b>agi tx >> agi_version: 13.15.0 <sip/obitrunk1-0000000b>agi tx >> agi_ca...

java - What is a NullPointerException, and how do I fix it? -

what null pointer exceptions ( java.lang.nullpointerexception ) , causes them? what methods/tools can used determine cause stop exception causing program terminate prematurely? when declare reference variable (i.e. object) creating pointer object. consider following code declare variable of primitive type int : int x; x = 10; in example variable x int , java initialize 0 you. when assign 10 in second line value 10 written memory location pointed x. but, when try declare reference type different happens. take following code: integer num; num = new integer(10); the first line declares variable named num , but, not contain primitive value. instead contains pointer (because type integer reference type). since did not yet point java sets null, meaning "i pointing @ nothing". in second line, new keyword used instantiate (or create) object of type integer , pointer variable num assigned object. can reference object using dereferencing operator . (a dot...

fiddler - decode custom encrypted body in inspector by c# on the fly -

Image
the content encrypt custom encrypter. fiddler captured content body base64 encode string in plain text the application traffic flow: request: base64encode(customencryptfromstringtobytes(jsonstring) ) -> application -> http server response: customdecryptfrombytestostring(base64decode(jsonstring) ) <- application <- http server i have encrypt/decrypt class in c#: string encrypttobase64(string plaintext); string decryptfrombase64(string plaintext); i build exe transform, wonder how make fiddler decode request/respose body exe on fly i want fiddler show decrypt content in inspector , , encrypt again everytime [reissue , edit(e)] request. i found close dont know how call exe decode. http://docs.telerik.com/fiddler/knowledgebase/fiddlerscript/modifyrequestorresponse update: have implement custom inspector fiddler. see answer below. add dummy header  fiddler-encoding: base64  and encode body using base64 if contains binary data. fiddler de...

xaml - WPF Slider looks different in Visual studio and in app -

i have strange behavior. in wpf app have slider wanted change background color. made resource dictionary file , overwrite template in visual studio slider looks fine: that shown in ide but when start app see normal default slider: how looks when start app what wrong? i added customslider.xaml file in app.xaml this: <resourcedictionary.mergeddictionaries> <resourcedictionary source="./customslider.xaml" /> </resourcedictionary.mergeddictionaries> and slide defined as: <resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:xxxxx.ui"> <style x:key="sliderbuttonstyle" targettype="{x:type repeatbutton}"> <setter property="snapstodevicepixels" value="true" /> ...

kotlin - What is the purpose of having bound class reference return a covariant type? -

i'm playing reflection , came out problem. when using bound class reference via ::class syntax, covariant kclass type: fun <t> foo(entry: t) { with(entry::class) { // instance of kclass<out t> } } as learn docs, return exact type of object, in case instance of subtype of t , hence variance modifier. prevents retrieving properties declared in t class , getting value (which i'm trying do) fun <t> foo(entry: t) { with(entry::class) { (prop in memberproperties) { val v = prop.get(entry) //compile error: can't consume t } } } i found solution using javaclass.kotlin extension function on object reference, instead invariant type: fun <t> foo(entry: t) { with(entry.javaclass.kotlin) { // instance of kclass<t> } } this way, both exact type @ runtime , possibility consume type. interestingly, if use supertype instead of generic, latter method still access correct type, wi...

Python script/macro on Catia v5 toolbar -

i learning python language , learn writing script cad programs. not know 1 thing , didn`t finded information how put script/macro on catia toolbar. there no problem vba macros there other languages. you can create catscript/catvbs/catvba call ever want (macro, application...) inside catia , assign icon on toolbar these "launchers". code samples bellow in catscript. for example, run hta file. language="vbscript" sub catmain() set wshshell = createobject("wscript.shell") 'run hta. hta = "c:\temp\e3source\catvbs\your_file.hta" wshshell.run hta , 1, true set wshshell = nothing end sub run exe file sub catmain() set wshshell = createobject("wscript.shell") wshshell.run("c:\temp\your_file.exe") set wshshell = nothing end sub or sub catmain() call catia.systemservice.executebackgroundprocessus ("c:\temp\your_file.exe") end sub run bat file sub catmain() catia.systemservice.executeprocessu...

ios - How to convert a Number to NSString in Objective-C -

i have price parameter api price: 10 want show in textfield appending "$" after it. doesn't show number anyway casting it. here code : cell.price.text = [[nsstring stringwithformat:@"%i", (nsnumber*)dic[@"items"][indexpath.row][@"price"]] stringbyappendingstring:@" $"]; to print nsnumber need use %@ instead of %i cell.price.text = [nsstring stringwithformat:@"%@ $", (nsnumber*)dic[@"items"][indexpath.row][@"price"]];

c# - How to dynamically create asymmetric grid in WPF -

first things first, aware there 100s of questions similar haven't found 1 tackles kind of problem. so, want build grid 2 or more columns, each of have 3 or more rows. columns have equal width rows can have different height. grid created on application start-up , data read .xml file , stored in arrays. example 1 example 2 since ui isn't symmetric, don't know how point using correct wpf methodology. appreciate if show me example code use figure out correct way code this. private void createdynamicwpfgrid() { // data read file int columns_count = 2; int[] row_counts = { 4, 3 }; int[,] sizes = { { 2, 1, 1, 1}, { 1, 1, 2, 0 } }; // create parent grid grid parentgrid = new grid(); parentgrid.width = ((system.windows.controls.panel)application.current.mainwindow.content).actualwidth; parentgrid.height = ((system.windows.controls.panel)application.current.mainwindow.content).actualheight; ...

php - Sql Query not returning array results in model? -

Image
in scrolling feed model i'm returning number of users in database , , last 50 users added database in ascending order. reason , last 50 users not returning. model code following: <?php //display total records in db //add html echo '<link rel="stylesheet" href="assets/css/feed.css" /><div id="feed"<marquee> <b>available accounts: </b>'; //fetch amount of users $usercount="select user_name store"; if ($res=mysqli_query($conn,$usercount)) { // return number of rows in result set $rowcount=mysqli_num_rows($res); printf("%d",$rowcount); // free result set mysqli_free_result($res); } //add html echo '<b>' . ' . . . last 50 added usernames . . .</b>'; //last 50 added database $lastusers = mysqli_query ("select user_name ( select * store order user_id desc limit 50 ) store order user_id asc"); $row = mysqli_fetch_arra...

system verilog - Array of dynamic array of queue in SV -

i'm trying create array(10 elements) of dynamic array(5 elements) of queue(of size 3). i'm doing - typedef int q[$:2]; typedef q dyn_arr; dyn_arr arr_dyn_arr[][5]= new[10]; i'm not sure whether it's right way. your typedef q dyn_arr; not except alias q dyn_array . variable declaring 3-dimensional array if had declared int arr_dyn_arr [][5][$:2]; so new[10] creates 10x5 array of empty queues

inheritance - Override a non-virtual method in C++ -

i have class a , class b inherits a . a has foo method override in b . class { public: void foo(); ... } class b: public { public: void foo(); ... } the solution of course define a::foo() virtual method, declaring virtual void foo(); . problem can't that, since a class defined in third-party library rather not change code. after searching, found override keyword (so declaration b::foo void foo() override; ), didn't me since that's not override for , override can apparently used on virtual methods sure method overriding method , programmer didn't make mistake, , generates error if method isn't virtual. my question how can achieve same effect making a::foo virtual without changing of code a , code b ?

visual c++ - Create resource from existing .ico icon -

i have icon in .ico format. want add resource in vc++ project. want set main icon using wxwidgets. i right click resources, , choices existing item , new item. if select new item , .ico, brings bitmap editor. can't right. select "existing item" , put foo.ico resources. following fails: wxframe::seticon(wxicon(foo)); i have tried various decorations, foo.ico , wxbitmap_type_ico_resource, yada yada, have yet strike perfect combination. edit: found on net says need create new resource , add foo.ico that. tried following instructions, no joy. i managed it, there must better way. i copied resource file, namely sample.rc, wxwidgets samples. edited in text editor, replacing icon name foo.ico in couple of places. commented-out #include referred wxwidget project directory. in visual studio, added file resources. in myframe constructor in program, wrote, seticon(wxicon(sample)); very hackish, worked.

bluetooth - Sending keycode from Bluefruit feather 32u4 LE to connected device -

i new arduino world. problem simple create tutorial can't work. i've got adafruit bluefruit feather 32u4 , want connect button it. every time button gets pressed feather should send specific keycode (it doesn't matter one) connected device (in case laptop). i've got button part working i'm stuck bluetooth part. i've used "keyboard.write()", works when feather connected via usb doesn't work via ble. tried serial.println() or ble.println() send data doesn't seem work. for i'm trying send 1 keycode every 5000ms , that's how code looks like: #include <arduino.h> #include <spi.h> #if not defined (_variant_arduino_due_x_) && not defined(arduino_arch_samd) #include <softwareserial.h> #endif #include "adafruit_ble.h" #include "adafruit_bluefruitle_spi.h" #include "adafruit_bluefruitle_uart.h" #include "bluefruitconfig.h" #include "keyboard.h" adafruit_bl...

python - AttributeError: 'NoneType' object has no attribute 'startswith' -

using pip , happened. after that, pip didn't work anymore. every installation using pip show exception. exception: traceback (most recent call last): file "c:\users\houyin~1\appdata\local\temp\tmpfofjoh\pip.zip\pip\basecommand.py", line 215, in main status = self.run(options, args) file "c:\users\houyin~1\appdata\local\temp\tmpfofjoh\pip.zip\pip\commands\install.py", line 324, in run requirement_set.prepare_files(finder) file "c:\users\houyin~1\appdata\local\temp\tmpfofjoh\pip.zip\pip\req\req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) file "c:\users\houyin~1\appdata\local\temp\tmpfofjoh\pip.zip\pip\req\req_set.py", line 487, in _prepare_file req_to_install, finder) file "c:\users\houyin~1\appdata\local\temp\tmpfofjoh\pip.zip\pip\req\req_set.py", line 428, in _check_skip_installed req_to_install, upgrade_allowed) file "c:\users\houyin~1\appdata\local...

static - Using hashmap in C to store String - Integer mapping once and use for entire program run -

i have own implementation of c hash_map_t struct can use below? // string value allocator allocator_t *str_value_allocator; allocator_init(&str_value_allocator, string_allocate_handler, string_deallocate_handler); str_hash_map_init(&str_hash_map, str_value_allocator, 5); str_hash_map_put(str_hash_map, test_key, test_val, strlen(test_val)); str_hash_map_get(str_hash_map, test_key, null) str_hash_map_remove(str_hash_map, test_key) str_hash_map_free(str_hash_map); i use hash map in function below: void handle_keyboard_input(char **tokens, size_t num_tokens) { char *virtual_key_name = strtok(tokens[1], " "); size_t num_flags = 0; char **modifier_flags = str_split(tokens[2], ", ", &num_flags); // map virtual_key_name (char *) virtual_key code (int) // foreach modifier flag (char *) map modifier flag code (int) } i can create 2 hash_maps key_name -> key_code mapping , flag_name -> flag_code mapping. problem don...

avr - Can't update data to ThingSpeak using sim900c and atmega16 -

i can update data on thingspeak using sim800c computer (usb-ttl). but, can't update data when use atmega16 (usart). code: usart_string_tx("at+cipstart=tcp,api.thingspeak.com,80\r"); _delay_ms(3000); _delay_ms(3000); _delay_ms(1000); usart_string_tx("at+cipsend\r"); _delay_ms(2000); usart_string_tx(apikey); usart_string_tx(data); usart_char_tx('\r'); _delay_ms(3000); while ( !( ucsra & (1<<udre))) {}; udr=(26); _delay_ms(500); usart_char_tx('\r'); _delay_ms(3000); _delay_ms(3000); usart_string_tx("at+cipshut\r");. please me. i'm sorry.my english bad

cordova - Ionic - Cannot read property 'findall' of null -

Image
i getting error whenever run ionic cordova run android. post more stuff have literally no idea start solve problem , there doesn't seem many google posts on this. working hour ago , i've changed variable name in time. has ever run before? same problem , tried , working : ionic cordova platform rm android ionic cordova platform add android