Posts

Showing posts from January, 2015

C++ Could not convert input string when using cin and variables -

i'm trying simple program user inputs string his/her name, if string equal name, executes different commands. it's this: #include <iostream> #include <string> #include <sstream> using namespace std; int main() { string input = ""; cout << "what's name?:\n>"; getline(cin, input); if(input = "micaela"){ cout << "you're best" << input << endl << endl; } else cout << "you kinda suck" << input << endl << endl; return 0; } when compiling, following error: 13 22 c:\users\francisco\desktop\cpp\holanena.cpp [error] not convert 'input.std::basic_string<_chart, _traits, _alloc>::operator=, std::allocator >(((const char*)"micaela"))' 'std::basic_string' 'bool' the problem occurs in line if(input = "micaela") which assigns "micaela" input . use comparison op

Android: NullPointerException Unable to load database into listview within a fragment -

i've been searching while trying find how populate listview information mysqlite database. when think found information come nullpointers. here code (homefragment.java) : package zygs.com.seniorproject.fragments; import android.app.fragment; import android.database.cursor; import android.database.sqlite.sqlitedatabase; import android.os.bundle; import android.util.log; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.view.view.onclicklistener; import android.widget.arrayadapter; import android.widget.button; import android.widget.edittext; import android.widget.listview; import java.util.arraylist; import java.util.list; import zygs.com.seniorproject.r; import zygs.com.seniorproject.database.databasehandler; import zygs.com.seniorproject.database.inventory; public class homefragment extends fragment { // initializing variables button item_button; button display_button; edittext box_item_des; edittext box_item_q

c# - Migrate web forms ASP.NET Membership OpenAuth for Google from OpenID 2.0 to OpenID Connect -

i have existing web forms site utilizes built-in asp.net membership openauth model. has worked on year , half, found out google has deprecated openid 2.0 , shut down on april 20, 2015 (just on week). this abstraction bites in ass, because have single line of code in authconfig.cs openauth.authenticationclients.addgoogle(); i've updated of openauth related nuget packages, hoping there fix under covers - no joy. is there easy solution this, or need strip out , rewrite google authentication piece? (lots of questions related this, haven't found related web forms membership.openauth implementation.) the nuget package " dotnetopenauth oauth2 client google " solved me. in authconfig.cs, replace openauth.authenticationclients.addgoogle(); with: var client = new googleoauth2client(clientid, clientsecret); var extradata = new dictionary<string, string>(); openauth.authenticationclients.add("google", () => client, extradata); get

jquery - Managed metadata column in SharePoint 2013 -

how can value of managed metadata column's value , corresponding change event using jquery? i'm working nintex forms , requirement read selected value. regards, vikrant managed metdata column should have following: "store client id in javascript variable" set "yes". javascript id can anything, e.g. ctrlname using variable defined above in form custom javascript add: nwf$("#" + ctrlname).bind('change', function(event) { var result = nwf$("#" + ctrlname).val(); });

c# - Changing Textblock background in WPF resetting itself after color change -

i have textblock in wpf usercontrol defined as: <textblock grid.column="0" text="{binding recognitionresults}" background="{binding resultbackground}" /> the usercontrol in textblock displayed being presented string usercontrol as: <itemscontrol itemssource="{binding strings}" > <itemscontrol.itemcontainerstyle> <style> <setter property="control.margin" value="{binding margin}"/> </style> </itemscontrol.itemcontainerstyle> </itemscontrol> essentially, itemscontrol presenting list of "strings", each string being represented own usercontrol . now, when tap on display of textblock , gesture performs action change background color yellow green in viewmodel: public void refill() { resultbackground = brushes.green; } the resultbackground color defined

dm script - What are the commands to get and set the contrast Gamma setting of raster image displays? -

i trying overlay 2 images, want able pass gamma each of images final image. know 1 can , set contrast limits adjust intensity transformation (itt), have not found commands access gamma value. am missing something? helpful able set gamma both images separately before overlaying them. the according commands number imagedisplaygetgammacorrection( imagedisplay imgdisp ) and void imagedisplaysetgammacorrection( imagedisplay imgdisp, number gamma ) and used in following example: image img1:=realimage("test1",4,256,256) img1 = icol showimage(img1) img1.imagegetimagedisplay(0).imagedisplaysetgammacorrection(0.6)

internet explorer 11 - Handle multiple pointer events in IE11 Metro/Mobile with pan-x and pan-y touch-action allowed -

i have web application want handle pinch zooming gesture in javascript rather allowing browser scale of ui. in ie11, it's understanding need specify touch-action css on element wish handle pointer events for. in application, i've disabled touch behavior except panning (touch-action: pan-x pan-y). i've wired pointerdown, pointerup, , pointermove events in javascript , i've added own calculations determine level of zoom perform based on distance between 2 active pointers (pinch gesture). in ie11 on desktop, works i'd expect; however, on mobile/metro version of ie (i've been testing on surface pro), can never seem detect more 1 pointer event @ given time. fires pointercancel on first captured event , fails fire second pointerdown. if disable touch gestures (touch-action: none), i'm able multi-touch pointer events in mobile browser well, no longer allows panning, undesirable. here's simple jsfiddle demonstrates issue: http://jsfiddle.net/wqgg0ly7

javascript - JSON stringify and then parse works unexpectedly for the object with local variable -

why json stringify , parse not working object. works bad objects local variables? function task(description) { var _description = description; this.getdescription = function() { return _description; } } var task = new task('wash car'); console.log(task.getdescription()); var json = json.stringify(task); console.log(json.parse(json).getdescription()); json can't stringify functions (and it's not supposed able to). but technically when need stringify object should not need functions. can pass object within application. edit: if need object stored locally saving functions along not idea anyway. can store properties of object , create new instance when retrieve it.

postgresql - Join Help Needed -

i have postgresql question think simple i'm having trouble conceptualizing joins need achieve this. i have table in format: company agreement_num end_of_agreement contract_amount abc 2 (null) (null) abc (null) 2015-01-10 10 abc (null) 2015-09-01 12 acme 2 (null) (null) acme (null) 2014-06-05 5 i table this: company agreement_num end_of_agreement contract_amount abc 2 (null) (null) abc 2 2015-01-10 10 abc 2 2015-09-01 12 acme 2 (null) (null) acme 2 2015-06-05 5 so basically, insert agreement_num corresponding company. so know i'm going, after this, i'll clause grab rows haven't rea

security - Converting this Encrypt - Decrypt PHP Class into a full static PHP class -

here great php class make safe 2 way encryption in php. using in project requires make thousands of calls it's methods, i'd convert full static class methods performance boost , avoid new instance @ every new method call /** * class handle secure encryption , decryption of arbitrary data * * note not straight encryption. has few other * features in make encrypted data far more secure. note * other implementations used decrypt data have same exact * operations. * * security benefits: * * - uses key stretching * - hides initialization vector * - hmac verification of source data * */ class encryption { /** * @var string $cipher mcrypt cipher use instance */ protected $cipher = ''; /** * @var int $mode mcrypt cipher mode use */ protected $mode = ''; /** * @var int $rounds number of rounds feed pbkdf2 key generation */ protected $rounds = 100; /** * constructor! *

datastep - Set multiple datasets with similar names in sas -

suppose have varying number of datasets in work environment, of start similar name: name_abc, name_efg, name_1ky, etc. datasets have same variables , characteristics, , want set them 1 dataset. data bigdataset; set [all datasets begin name_]; run; is there way can in sas without typing datasets? need flexible number of datasets available in work environment. use variable name wildcard : data bigdataset; set name_:; run; a colon following variable name prefix selects variable name starts prefix. ability of colon along simple naming standards enables programmer manage temporary variables better, format many variables quicker, determine unknown number of variables, clean macro generated datasets, , shorten code variety of procs. example data adlb; set lb:; this data step reads data sets in work library begin lb. also, when programmer coded step, he/she did not need know how many dataset read, he/she wants read of dataset particu

Java ArithmeticException BigInteger would overflow supported range -

i working on algorithm check if number prime , need work big numbers therefore using biginteger class. problem exception thrown arithmeticexception biginteger overflow supported range . exception in thread "main" java.lang.arithmeticexception: biginteger overflow supported range @ java.math.biginteger.reportoverflow(unknown source) @ java.math.biginteger.checkrange(unknown source) @ java.math.biginteger.<init>(unknown source) @ java.math.biginteger.shiftleft(unknown source) @ java.math.biginteger.pow(unknown source) @ kitas.main(kitas.java:118) and line exception thrown: b = biginteger.valueof(2).pow((int) (35*(math.pow(2, counter)))); once counter reaches value of 26, exception thrown. (int) (35 * math.pow(2, 26)) == (int) (2348810240d) = integer.max_value with result power you're trying raise 2 integer.max_value, result have on integer.max_value binary digits. biginteger isn't big enough that, , storing numbers

.htaccess - redirect one file to two differents files depending on the presence of a query string -

i'm in process of migrating blog new platform (dotclear > drupal) , i'm trying redirect old urls rss feeds new feeds. there 2 types of feeds (articles or comments), each in 2 flavors (rss or atom), that's 4 urls redirect. my problem comes fact feeds comments same articles, plus query-string ( ?type=co ). here rules have: redirect 301 /blog/rss.php?type=co /rss-comments.xml redirect 301 /blog/rss.php /rss.xml redirect 301 /blog/atom.php?type=co /rss-comments.xml redirect 301 /blog/atom.php /rss.xml this works fine articles feeds (without query-string), rules comments feeds seem ignored , redirect article feed (useless) query-string. so /blog/rss.php?type=co rewritten /rss.xml?type=co instead of /rss-comments.xml . what doing wrong? tried changing order of rules, same effect... you can't match query string using redirect directive. use rewriterule this: rewritecond %{query_string} ^type=co$ [nc] rewriterule ^blog/(

How can I refresh a javascript variable, populated by JSF, via ajax? -

i want following: select item h:selectonemenu update backing bean new value, via ajax run javascript function new value in following code though, alert(#{backingbean.derivedvalue}) still contains value last change (i.e. it's 0 when select "two", 4 when select "one", , on): <h:form> <h:selectonemenu value="#{backingbean.input1}"> <f:selectitem itemlabel="one" itemvalue="1"/> <f:selectitem itemlabel="two" itemvalue="2"/> <f:ajax render="@form" onevent="function(data) { if (data.status === 'success') { alert(#{backingbean.derivedvalue}) }}"/> </h:selectonemenu> input value: #{backingbean.input1} derived value: #{backingbean.derivedvalue} </h:form> and backing-bean: @managedbean @viewscoped public class backingbean { private int input1; private int derivedvalue; public int ge

c# - joining a twitch IRC channel -

my function should join channel doesn't response server. weird thing when join server response. somehow, when try join channel don't receive return. private void join() { connection.writer.write("join #" + channelname.trim().tolower() + "\r\n"); console.writeline("join #" + channelname.trim().tolower() + "\r\n"); connection.writer.flush(); //debug code while (true) { while (connection.reader.peek() >= 0) { string line = connection.reader.readline(); if (line.contains("ping :")) { connection.writer.write("pong :" + line.substring(line.indexof("ping :") + 6) + "\r\n"); connection.writer.flush(); } console.writeline(line); } } } edit: it seems twitch doesn't do &

java - ECKeyAgreement in Generating public and private key using ecc -

i working on concept of encryption , decryption using ecc. generated public , private key. while encrypting text getting error: java.security.invalidkeyexception: eckeyagreement requires ecprivatekey @ org.bouncycastle.jce.provider.jceecdhkeyagreement.engineinit(jceecdhkeyagreement.java:121) @ javax.crypto.keyagreement.init(keyagreement.java:462) @ javax.crypto.keyagreement.init(keyagreement.java:436) @ rbl2015.encryec.main(encryec.java:67) this encryption java file: import java.io.file; import java.io.fileinputstream; import java.security.key; import java.security.keyfactory; import java.security.keypair; import java.security.keypairgenerator; import java.security.privatekey; import java.security.publickey; import java.security.security; import java.security.spec.ecparameterspec; import java.security.spec.ellipticcurve; import java.security.spec.keyspec; import java.security.spec.pkcs8encodedkeyspec; import java.security.spec.x509encodedkeyspec; import java.util.scanner; i

php - bootstrap date picker blocking dates -

i have used date picker bootstrap. wondering how exclude 10 days selected day user has clicked for example user chooses 10th april 2015. user can select dates 10th april 2015 - 19th april 2015 ending date. here code date picker. <script type="text/javascript"> var nowdate = new date(); var today = new date(nowdate.getfullyear(), nowdate.getmonth(), nowdate.getdate(), 0, 0, 0, 0); $(function () { $('#startdate').datetimepicker({ mindate:today, format: 'yyyy-mm-dd hh:mm:ss' }).change(function (selected) { var startdate = new date(selected.date.valueof()); $('#enddate').datetimepicker('maxdate', startdate+10); }); $('#enddate').datetimepicker({ mindate:today, format: 'yyyy-mm-dd hh:mm:ss' }); });

javascript - Why isnt the old background being overwriten? -

i have canvas background image i'm filtering to gray scale. when save canvas json want background's image filter removed. how come when overwrite canvas background setter method filtered background remains in json? applying filtering background fabric.image.fromurl(image_library_selected_url, (function(image){ image.filters[0] = grayscale; image.applyfilters((function(){ this.canvas.backgroundimage = image.getelement(); canvas.backgroundimage.name = image_library_selected_url; this.canvas.renderall(); }).bind(this)); }).bind(this)); removing filtering , converting canvas json //canvas.backgroundimage.name holds src of original image var bg_img = canvas.backgroundimage.name; canvas.setbackgroundimage(bg_img, canvas.renderall.bind(canvas)); canvas.foreachobject(function(obj) { if (obj.type === 'named-image') { obj.filters=[]; obj.applyfilters(canvas.renderall.bind(canvas)); } }); canvas.deactivateal

html - XPath for two different tags (either one) that contain a specific word? -

i need xpath can find either <a> tag, or <option> tag, each 1 containing "something". so xpath able match either <a attributes='value'>something</a> or <option attributes="value">something</option> i tried this: $x("//*[local-name()='a' contains(.,'something') or local-name()='option' contains(.,'something')]") i tried this: $x("//*[local-name(contains(.,'something'))='a' or local-name(contains(.,'something'))='option']") but neither of them work. in first one, can exclude contains() , finds tags, need able search tags containing specified "something" text. you should post input xml. let's it's this: <r> <a>xxx something</a> <a>yyy nothing</a> <option>something xxx</option> <option>nothing xxx</option> </r> (1) (if

Multi Section form hiding and showing sections with jQuery -

i'm working on long form has fit 1 page. section should disappear when completed , next section should appear. know how dynamically can reuse multiple times. need create sort of breadcrumb previous sections can changed if wanted. i form move on next section once user clicks radio button. $('.section:not(.active)').hide(0); .active { } .breadcrumbs>ul>li { display: inline-block; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="breadcrumbs"> <ul> <li><a href="#"></a></li> <li><a href="#"></a></li> <li><a href="#"></a></li> </ul> </div> <form role="form"> <div class="section active"> <img src="http://placehold.it/350x150"/><br/> <input type=&q

java - Generic Map<String, Object> JSON marshalling and unmarshalling with Moxy -

is there way marshal map<string, object> moxy json result uses natural constructs of json? is, keys strings , possible values following rules apply (possibly not complete set): number (e.g., integer ) becomes json number (or string if it's big) string becomes json string set , array , iterable become json array and map<string, object> , same rules recursively applied any other object marshalled in natural moxy way there example how marshal map<string, integer> , other specific maps using @xmlvariablenode (see http://blog.bdoughan.com/2013/06/moxys-xmlvariablenode-using-maps-key-as.html?m=1 ), unable extend idea point subtypes can inserted value. note moxy should able unmarshal json original map. jackson capable of doing default. i've tried want jaxb ri (xml): @xmlrootelement public class foo { @xmljavatypeadapter(mapadapter.class) public map<string, object> map; } public class mapadapter extends xmladapter&l

d3.js - Dynamically Updating A D3 Treemap Datasource -

i think i'm missing obvious here. trying create treemap on button click go server , retrieve next level treemap...this necessary because treemap structure large , takes long calculate jumping 1 level @ time option have. [note ie users, in example treemap node names don't appear working. try using chrome] http://plnkr.co/edit/simvgu this code taken http://bost.ocks.org/mike/treemap/ i'm using vizdata1.json "first" level , on mouse click i'm using vizdata2.json "second" level. can see 2 end overlapping. i've tried svg.exit() svg.clear() without luck. i should note have tried sticky(false) suggestion post does d3 treemap layout cached when root node passed it? update: continue hunt have found example adds new nodes existing treemap. having trouble adapting logic treemap attempting fit logic has been heavily customized michael bostock - @mbostock allow nice breadcrumb trail bar @ top. code snippet proves appending existing

ios - Add padding around ASTextNode -

i working asyncdisplaykit (for first time) , have astextnode inside ascellnode . want adding padding or inset around text inside astextnode . attempted wrap asdisplaynode whenever calculated it's size in calculatesizethatfits: returned 0. suggestions appreciated. code in ascellnode subclass is: - (cgsize)calculatesizethatfits:(cgsize)constrainedsize { cgsize textsize = [self.commentnode measure:cgsizemake(constrainedsize.width - kimagesize - kimagetocommentpadding - kcellpadding - kinnerpadding, constrainedsize.height)]; return cgsizemake(constrainedsize.width, textsize.height); } - (void)layout { self.imagenode.frame = cgrectmake(kcellpadding, kcellpadding, kimagesize, kimagesize); self.imagenode.layer.cornerradius = kimagesize / 2.f; self.imagenode.layer.maskstobounds = yes; self.imagenode.layer.bordercolor = [uicolor whitecolor].cgcolor; self.imagenode.layer.borderwidth = 2.f; self.commentnode.backgroundcolor = [uicolor whitecolor];

ruby - Using Sequelize like Rails console -

i new using nodejs , sequelize, coming rails. love sequelize , how it's similar activerecord. 1 thing miss though rails console can ar queries make sure logic correct or getting right data before putting code base. great testing migrations , associations. is there similar sequelize can test queries without having run server , throwing controllers? thanks! you can run code in node.js console, start nodejs.exe (or whatever os using) in command line , write code in it

c++ - building problems with odb in QtCreator -

i want make sql application in qtcreator qt libary , orm libary odb when try build hello example odb site list of errors , couldn't find out problem. my ideas missing includes or haven't install right. building errors : " ..\test\main.cxx:40:15: error: cannot convert 'odb::access::object_traits<person>::id_type' 'long unsigned int' in assignment " ..\test\main.cxx:42:14: error: cannot convert 'odb::access::object_traits<person>::id_type' 'long unsigned int' in assignment in file included c:/qt/qt5.4.0/tools/mingw491_32/i686-w64-mingw32/include/odb/database.hxx:26:0, ..\test\main.cxx:8: c:/qt/qt5.4.0/tools/mingw491_32/i686-w64-mingw32/include/odb/query.hxx: in instantiation of 'struct odb::query_selector<person, (odb::database_id)5u>': ..\test\main.cxx:47:30: required here c:/qt/qt5.4.0/tools/mingw491_32/i686-w64-mingw32/include/odb/query.hxx:104:10: error: invalid use of

javascript - How to draw connecting lines for bar charts in Kendo-UI -

Image
i have started on kendo-ui. i have following bar charts. add draw lines connects bar charts shown in second figure. here have: here wish achieve: function createchart() { $("#chart").kendochart({ title: { text: "hybrid car mileage report" }, legend: { position: "top" }, series: [{ type: "column", data: [20, 40, 45, 30, 50], stack: true, name: "on battery", color: "#003c72" }, { type: "column", data: [20, 30, 35, 35, 40], stack: true, name: "on gas", color: "#0399d4" }], valueaxes: [{ title: {

sql - MySQL Function Oddness When Using IN Operator -

i have below query runs ok , returns string 2,3 . fn_get_plan_upgrade_options returning varchar . select fn_get_plan_upgrade_options(1); now when add function call clause using in operator returns result act_id contains 2 , no results act_id contains 3 , there data both both should returned, suggestions or ideas, no errors thrown!? select act_id , act_name account_types act_id in (fn_get_plan_upgrade_options(1)); the query want run this: select ... act_id in (2,3) but query running this: select ... act_id in ('2,3') because function returns string (not list of values), , since comparing string number (act_id), mysql automatically cast string number, end running this: select ... act_id in (2) you can use find_in_set solve problem: select ... find_in_set(act_id, fn_get_plan_upgrade_options(1))>0

vb.net - dynamically create a new tab with textbox, button in the tab with click and keypress events (AddHandler is what i cant get to work) -

i creating tabs , need 2 things work can't work. need addhandler textbox.keypress event , button.click event. can make these things work outside of tabcontrol not in. in example below text box , buttons have same name on tab another, thought might problem changing names between tabs not work. assume need more specific in addhandler part give tab name control. there logic in real code allow me give unique names each tab panel , controls, can't simple part work. i left of things tried commented, tried lots , lots of other things. public class form1 public sub addtab(tabpagename string) dim tabpage new tabpage tabpage.text = tabpagename tabpage.name = "tabpage1" 'real code has logic make sure names unique dim label1 new label dim txtcreator new textbox dim combox1 new combobox dim tabpagebutton2 new button tabpagebutton2.parent = tabpage label1.parent = tabpage txtcreator.parent = tabpage combox1.parent

Android post authorization -

Image
i trying http post server check if login credentials valid of this tutorial. need make request server have add authorization, string function getb64auth this answer . function logs right variable, (the same use postman). reason program stops running if run code. tried adding code comments didn't help. what doing wrong? private string getb64auth (string login, string pass) { string source=login+":"+pass; string ret="basic "+base64.encodetostring(source.getbytes(),base64.url_safe| base64.no_wrap); log.d("authy", ret); return ret; } /** called when user clicks login button */ public void login(view view) { // getting username , password edittext usertext = (edittext) findviewbyid(r.id.inputloginusername); edittext passtext = (edittext) findviewbyid(r.id.inputloginpassword); string usernameinput = usertext.gettext().tostring(); string passwordinput = passtext.gettext().tostring(); string authorizationst

cryptography - Explain Key Block and master secret with padding and encrytion in SSL/TLS? -

how see encrypted key in wireshark, during ssl key exchange? referring this answer question: could explain why pre-master encrypted 128 bits, how rsa public key of 2048 bits encrypt 48 bits data 128 bits, because client , server confirms , use symmetric encryption after change_cipher_spec record. the key expanded 136 bits, master secret padded , used in encryption. can explain use/generation of "key-block" in ssl/tls ? why have client_write_key , server_write_key if using symmetric encryption, wouldn't single key used both encryption , decryption. and having 2 different mac keys, produce same result message send authenticated if securely client , server , not exchanged. could explain why pre-master encrypted 128 bits, how rsa public key of 2048 bits encrypt 48 bits data 128 bits it doesn't. pre-master secret 48 bytes, , encryption 128 bytes , including padding, , public key length of 2048 bits has nothing that. because client , se

SQL Injection trouble SQLite Python -

how can correct code less vulnerable sql injection? sqlite3 audit((cursor, connection, 0), "registeration error {0}".format(username)) sql="""insert activitylog(userid, activity, start, stop) values({0}, '{1}', '{2}','{3}') """.format(handle[2], activity, start, stop) i suggest use parameter substitution built-in sqlite3 dbapi2. con.execute('insert activitylog (userid, activity, start, stop) values (?, ?, ?,?)',(handle[2], activity, start, stop)) you can split onto multiple lines triple quote string literal have in code.

java - Issue executing OpenCV native functions via JNI -

i'm attempting run native opencv functions via java native interface on unbuntu. i'm trying accomplish use bagofwords functions available in default version of opencv, time being i'm trying test out running simple functions using interface. so, have following java file relative native functions. class opencvsample { static { system.loadlibrary("bridge1"); } public native int bridgefunction(); public static void main(string[] args) { opencvsample b = new opencvsample(); b.bridgefunction(); } } here c++ bridge file. #include "opencvsample.h" #include <string.h> #include <cv.h> jniexport jint jnicall java_opencvsample_bridgefunction(jnienv *env, jobject obj) { iplimage *img = cvcreateimage( cvsize( 640, 480 ), ipl_depth_8u, 1 ); return 1; } int main(){} now mentioned, i'm doing on ubuntu, i'm first compiling opencv shared lib