Posts

Showing posts from March, 2014

php - SQL Left join Many to Many, only display distinct ID in left table -

tablea id name 1 peter 2 mary 3 john tableb id event 1 eventa 2 eventb 3 eventc tablec id aid bid 1 1 1 2 1 3 3 2 1 i doing this select distinct a.id, b.id tablea left join tablec c on a.id = c.aid left join tableb b on c.bid = b.id it shows 1 peter eventa 1 peter eventc i want output follows 1 peter eventa eventc how that? many thanks. amendment: actually displaying records below: 1 peter eventa eventc from suggestion works fine, wanna add hide show function. function reversedisplay(d) { if(document.getelementbyid(d).style.display == "none") { document.getelementbyid(d).style.display = "block"; } else { document.getelementbyid(d).style.display = "none"; } } select distinct a.id, b.id, b.event from tablea a left join tablec c on a.id = c.aid left join tableb b on c.bid = b.id $lastid = ""; while($row = mysql_fetch_array($rs)) { if ($lastid != $row[0]){

angularjs - Ionic app not working on mobile device -

i have created ionic application, accessing data different domain. in order make work, have done following @ server side(express): app.use(function(req, res, next) { res.header("access-control-allow-origin", "http://localhost:8100"); res.header("access-control-allow-methods", "get,put,post,delete,options"); res.setheader('access-control-allow-headers', 'x-requested-with,content-type, authorization, access-control-allow-origin, access-control-allow-headers'); res.header("access-control-allow-credentials", "true"); next(); }); as seen, have set origin localhost:8100, making application work , run on browser. however, when create .apk file , install on mobile device, not working i.e. data not coming. could please me out issue. issue arising because of origin specified ? if yes, there solution same. do have cordova whitelist plugin. if yes , check access origin settings in config.xml , meta tag

php - Javascript onBlur - Magento Billing Email -

on magento onepage checkout want place onblur event on billing:email input, here code: <div class="field col-md-6"> <div class="input-box"> <input type="text" onblur="showme()" name="billing[email]" id="billing:email" value="<?php echo $this->escapehtml($this->getaddress()->getemail()) ?>" title="<?php echo $this->__('email address') ?>" class="form-control input-text validate-email required-entry" /> </div> <script language="javascript" type="text/javascript"> function showme() { alert('hello'); } </script> </div> i expecting showme() function fire nothing happens, have done wrong?

node.js - Have to run sudo npm install -g everytime -

i getting started on command line application node, have noticed every time make change index.js file have run "sudo npm install -g" relfect change. example index.js #!/usr/bin/env node console.log("hello"); under package.json "bin": { "movie": "index.js" }, if run "movie" terminal prints out "hello". now if change print statement under index.js console.log("world") , run "movie" terminal prints outs "hello" rather "world". if "sudo npm install -g" , run "movie" command, picks "world". i not sure why happening? use npm link instead of npm install . create symlink on directory can use testing if intalled locally on directory.

java - Read an xml file from a servlet -

i can't load correctly file xml servlet: that's code: try{ documentbuilderfactory dbf = documentbuilderfactory.newinstance(); documentbuilder db = dbf.newdocumentbuilder(); document doc = db.parse("db.xml"); } catch (exception ex) { ex.printstacktrace(); out.print("file not found!"); } the db.xml inside classes folder class , java file... if have xml file in root folder of war file, can read using real path context application folder. string contextpath = request.getsession().getservletcontext().getrealpath("/"); in way, can use context class loader in multi-module environment : classloader classloader = thread.currentthread().getcontextclassloader() document doc = db.parse(classloader.getresourceasstream(contextpath+ "/db.xml")); in environments, additional slash not necessary.

python - Pandas sum column with scalar results in zeros -

i summing column of pandas dataframe scalar , result column full of zeros. weird thing return zeros , won't. if tell me wouldn't believe it, that's why made video showing result: https://dl.dropboxusercontent.com/u/15853805/pandas%20bug.mp4 can explain me black magic? loosing trust on pandas , need work. ok code can similar error: import pandas pd import numpy np pdb import set_trace pdb _ in xrange(100): data = np.random.randint(1,100000,1000000) df = pd.dataframe(data,columns=['column']) scalar = np.random.randint(1,100000) df.column += scalar if df.column.max()==0: pdb() my data variable gets full zeros. memory issues? if data smaller doesn't happen, need process big data in safe way! >> print pandas.__version__ 0.17.1 >> print numpy.__version__ 1.10.1 python 2.7.11 |anaconda 2.4.1 (64-bit) the problem version of numexpr=2.4.4 updating numexpr=2.4.6 fixes problem. github issue: https://git

android - Which Facebook application security Settings shall I disable / enable -

i'm using facebook sdk in android application, count on fb sdk user logged application , grant application needed permissions, , know fb sdk offers user login dialog whether android facebook application installed or not. my question is, options should enable / disable based on info provided above application secured as possible? p.s: have no experience on web programming or dealing sending / receiving data servers, , no experience in creating oauth flows, these options confusing me. p.s -2: set these options in picture based on facebook security tool check recommendation secure app, , based on reading login security facebook login security options (click here see options picture) and confused me more , though disabled ( client oauth settings ), facebook security check tool informs me: **state parameter used on embedded browser oauth login:** *it looks you're using embedded browser oauth login flow. use state parameter guard against cross-site request forgery. se

csv - How to read index data as string with Python pandas? -

i'm trying read csv file dataframe pandas, , want read index row string. however, if row index doesn't have characters, pandas handles data integer. how read string? to specific, code follow. sample.csv uid,f1,f2,f3 01,0.1,1,10 02,0.2,2,20 03,0.3,3,30 the code df = pd.read_csv('sample.csv', index_col="uid" dtype=float) print df.index.values the result >>> [1 2 3] but, hope result >>> ['01', '02', '03'] and additional condition. the rest of index data have numeric value , they're many , can't point them specific column names. pass dtype param specify dtype: in [159]: import pandas pd import io t="""uid,f1,f2,f3 01,0.1,1,10 02,0.2,2,20 03,0.3,3,30""" df = pd.read_csv(io.stringio(t), dtype={'uid':str}) df.set_index('uid', inplace=true) df.index out[159]: index(['01', '02', '03'], dtype='object', nam

javascript - Utilities.formatString() New Apps Script method, not working as intended -

Image
i using new method: utilities.formatstring() in google documentation says similar sprintf %-style. i searched , read this article sprintf in php. i cannot seem work intended. meant pad 8 character string 4 leading zeros. know there other ways this, trying handle on sprintf / formatstring thing. var noformat = "12345678"; var formatted = utilities.formatstring("%012s", noformat); i expected var formatted equal "000012345678". debugger tell me formatted = 0, or throws error.. i confused. try : function xxx(){ var noformat = '12345678' var formatted = utilities.formatstring("%012d", noformat); logger.log(formatted) } the different parameters can used easy find on web, here example explains how argument must evaluated in php usage same. logger result :

objective c - How to view .dwg (AutoCAD) files in webview in ios -

want view .dwg files in uiwebview in iphone, have tried load url of . dwg file in webview .but not loading. please suggest 3rd party browser or other way viewing . dwg files. in advance. here list of supported document formats, it's no autocad there https://developer.apple.com/library/ios/qa/qa1630/_index.html#//apple_ref/doc/uid/dts40008749 you can try use autodesk dwf toolkit http://usa.autodesk.com/adsk/servlet/index?id=823771&siteid=123112

php - Friendly URLs cakephp 2.3 -

i'm new using cakephp, , i'm trying set friendly urls site, i'm having problems. i've made steps cakephp 2.3 book says, , apache configuration says mod_rewrite being executed. and when enter main page of cake, says url rewriting not configured, , when want acces web need go throught www.mysite.com/index.php/controller/function , of course, want this: www.mysite.com/controller/function, , if try route, says not found in server (and have controller , function created). this .htacces files: root directory: <ifmodule mod_rewrite.c> rewriteengine on rewriterule ^$ app/webroot/ [l] rewriterule (.*) app/webroot/$1 [l] </ifmodule> app directory: <ifmodule mod_rewrite.c> rewriteengine on rewriterule ^$ webroot/ [l] rewriterule (.*) webroot/$1 [l] </ifmodule> webroot directory: <ifmodule mod_rewrite.c> rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request

javascript - Create a class extending from ES6 Map -

trying away custom get/set functionality on es6 maps. using babel transpile code es5. chrome version 41.0.2272.101 m class mymap extends map { get(key) { if (!this.has(key)) { throw new error(...); } return super.get(key); } set(key) { if (this.has(key)) { throw new error(...); } return super.set(key); } } not sure if got syntax wrong or i'm missing implementation of sort. following error: method map.prototype.foreach called on incompatible reciever babel explictly states not support extending built-in classes. see http://babeljs.io/docs/usage/caveats/#classes . reasons not quite simple "limitations in es5", however, since map not es5 feature begin with. appears implementations of map not support basic patterns such as map.prototype.set.call(mymap, 'key', 1); which babel generates in case. problem implementations of map including v8 overly restrictive , check this in map.set.call cal

xslt - Attempts to use following-sibling to convert -

i try convert old html xslt-script new xml stucture. have problem converting folowing source needed xml structure. source <p> <a class="dropdown">example text</a> </p> <div class="collapsed"> <table>..</table> <p>..</p> </div> xml structure <lq> <p>example text</p> <table>..</table> <p>..</p> </lp> i tried following xls, div class="collapsed" not adopted lp tag. <xsl:template match="p/a[@class='dropdown']"> <lp> <p><xsl:apply-templates select="text()"/></p> <xsl:if test="/p/a/following-sibling::*[1][self::div]"> <xsl:apply-templates select="*|text()"/> </xsl:if> </lp> </xsl:template> can tell me did wrong ore mistake is? thanks much imho, want do: <!-- identity transform --> <xsl:te

css - HTML Masonry Image layout -

i added wordpress theme new images post vertically instead of horizontal. new images display on green line instead of red line on image: image . great. html: <section> <img src="https://unsplash.it/700/345?image=564" /> <img src="https://unsplash.it/700/550?image=587" /> <img src="https://unsplash.it/700/450?image=589" /> <img src="https://unsplash.it/700/500?image=421" /> <img src="https://unsplash.it/700/300?image=455" /> <img src="https://unsplash.it/700/150?image=406" /> <img src="https://unsplash.it/700?image=594" /> <img src="https://unsplash.it/700/450?image=417" /> <img src="https://unsplash.it/700/400?image=410" /> <img src="https://unsplash.it/700/550?image=582" /> <img src="https://unsplash.it/700/175?image=591" /> <img src="https://unsplash.it/700/345?image=421" /> <im

c# - Is an interface can be used for common methods between class? -

i want have common method between many classes tasks. work i'm not sure it's acceptable.. example of 2 classes implement interface freeview() method: class browserview : chromiumwebbrowser, iview { public void freeview() { // work } } class videoview : canvas, iview { public void freeview() { // work } }` and call method in main module : private object activeview = null; switch (settings.vue) { case vue.website: activeview = new browserview(this, settings.sourcepath); gridview.children.add(activeview browserview); break; case vue.video: activeview = new videoview(this, settings.sourcepath); gridview.children.add(activeview videoview); break; } and when need call freeview() method, cast activeview private void dele

javascript - Display empty grid message on igheirarchical grid -

as per post in forum http://www.infragistics.com/community/forums/t/93487.aspx i want display same no data found message in igheirarchical grid dont find events can write function same. you can use rowsrendered event this: $("#gridid").ighierarchicalgrid({ ... rowsrendered: function (event, ui) { var hasdata = ui.owner.options.datasource.root().data().length; if (!hasdata) { // render empty data message } } });

php - Ebay developer Improvements -

i have been trying list of current active products after s**t load of research , practice managed script list information require stock available , sku. issue have have manually input ebay id website need automatically pull out list of active ebay listings. here script gather information single product. error_reporting(e_all); ini_set('display_errors', '1'); // load configuration file $sandbox = false; $compat_level = 753; $api_endpoint = $sandbox ? 'https://api.sandbox.ebay.com/ws/api.dll' : 'https://api.ebay.com/ws/api.dll'; $dev_id = $sandbox ? " " : " "; $app_id = $sandbox ? " " : " "; $cert_id = $sandbox ? " " : " "; $auth_token = $sandbox ? " " : " "; $site_id = 3; $call_name = 'getitem'; // create headers send curl request. $headers = array ( 'x-ebay-api-compatibility-level: '

java - Android notification is not showing it's content when app is not running -

here interesting problem. android notification comes gcm not showing title , content ( just shows app name, , when click, open mainactivity) when app not running. but when app open, it's showing successfully title , content. can problem? running without problem , didn't change anything. manifest: <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.access_phone_state" /> <uses-permission android:name="android.permission.access_wifi_state" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.wake_lock" /> <uses-permission android:name="android.permiss

jquery - how can i make live Like button with Asp.net MVC 5 and Ajax -

i new @ stackoverflow , first question. i making first blog site, , want button, facebook. 2 problems button. it wont update counts in articles same data-id. avaible update (this) article-link when user likes/dislikes article, should able unlike without refreshing page. because wont check if there data in database without refreshing page. how can without refresh? controller: public string likethis(int id) { article art = db.articles.firstordefault(x => x.id == id); if (user.identity.isauthenticated || session["username"] != null) { var username = user.identity.name; member m = db.members.firstordefault(x => x.username == username); art.likes++; like = new like(); like.articleid = id; like.userid = m.id; like.likeddate = datetime.now; like.liked = true; db.likes.add(like); db.savechanges(); }

javascript - Rename legend on export in highchart -

i know highcharts makes possible update legend using following function: chart.legend.allitems[0].update({name:'aaa'}); also possibility hide or show legends on export working. exporting:{ chartoptions:{ legend:{ enabled:true } } } but now, rename specific legend during export. there way bind update code export-function in highcharts? update series in chart.events.load event, example: exporting: { chartoptions: { chart: { events: { load: function (e) { this.series[0].update({ name: "new name." }); } } } } }

windows - Dark theme of app -

i writing application windows phone. i want set dark theme of app. i set on window, when deploy app on device, theme light. theme code of xaml: <page x:class="murakami.mainpage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:murakami" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:ignorable="d"> <grid background="{themeresource applicationpagebackgroundthemebrush}"> <button x:name="button" content="" horizontalalignment="left" margin="10,10,0,0" verticalalignment="top" width="48" height="46"> <button.background> <imagebrush stretch="fill" imagesource="images/menu.png"/>

dataframe - Easy way to transform data frame in R - one variable values as separate columns -

Image
this question has answer here: how reshape data long wide format? 7 answers what have (obviously i'm presenting small fraction of current data): my_df <- structure(list(x = structure(c(48.75, 49.25), .dim = 2l), y = structure(c(17.25, 17.25), .dim = 2l), time = structure(c(14625, 14626), .dim = 2l, class = "date"), spei = c(-0.460236400365829, -0.625695407390594)), .names = c("x", "y", "time", "spei"), row.names = 1:2, class = "data.frame") what need: new_df <- structure(list(x = structure(c(48.75, 49.25), .dim = 2l), y = structure(c(17.25, 17.25), .dim = 2l), "2010-01-16" = c(-0.460236400365829, nan), "2010-01-17" = c(nan, -0.625695407390594)), .names = c("x", "y", "2010-01-16", "2010-01-17"), row.names = 1:2, class = "data.fra

security - jQuery-1.11.3 violates CSP eval policy. Is there a fix or workaround? -

i'm implementing header content-security-policy , cleaning (a mountain of) code go. my main sticking point on javascript side of things jquery-1.11.3 violates eval policy: uncaught evalerror: refused evaluate string javascript because 'unsafe-eval' not allowed source of script in following content security policy directive: "script-src 'self' is there way around other unsafe 'unsafe-eval' policy? seems me go down route negates large part of security header provides. devdatta akhawe points out, protection against code injection not protect against eval being used execute code when jquery used. there doesn't seem awful lot on jquery forum , there is old . surely somewhere has had make decisions concerning problem. i'll have take no, then.

eclipse - avrdude programmer is not responding when uploading a .hex file -

i'm trying upload hex file atmega328 on arduino uno board builded eclipse's avr plugin when run avrdude -pm328p -carduino -p/dev/ttyacm0 -b9600 -uflash:w:/home/bruno/workspace/testavr/release/testavr.hex:a avrdude: stk500_recv(): programmer not responding i tried upload blink led code using arduino ide , worked fine. this general error can caused number of things. try adding -vvv flag (or maybe -vvvv ) give more verbose output when programming. one thing try hitting reset button on arduino after avrdude writes first few bytes. ensure there nothing shorted, , uno has stable power source. also, if there connected rx/tx pins, can cause programming issue. make sure using correct programmer, if arduino clone, might need -c arduino-ft232r .

linux - Get systemd's default limits -

is there way find out default values of parameter set in /etc/systemd/system.conf file? the manual page of systemd-system.conf says: when run system instance systemd reads configuration file system.conf, otherwise user.conf. these configuration files contain few settings controlling basic manager operations. the variables outcommented (in user.conf + system.conf) , file /etc/security/limits.conf ignored systemd. so, default values? set unlimited? the answer is: systemctl show :)

mainframe - initialize an index variable in cobol -

we have cobol program in populate values cobol internal table , search table find out value. prior search, initialize tables index variable. set paf-idx 1. could clarify, if allowed in cobol initialize index variable loke this. initialize paf-idx. no. , why want "initialize" it? this ibm enterprise cobol manual: identifier-1 receiving areas. identifier-1 must reference 1 of following: v alphanumeric group item v national group item v elementary data item of 1 of following categories: alphabetic alphanumeric alphanumeric-edited dbcs external floating-point internal floating-point national national-edited numeric numeric-edited v special register valid receiving operand in move statement identifer-2 or literal-1 sending operand. when identifier-1 re edit: the opencobol programmer's guide documents specifically: the list of data items eligible set new values statement is: every elementary item specified ident

javascript - Custom form integrated with Google Forms does not capture data -

i have set custom html & javascript form integrates google forms capture data. doesn't work @ moment though, data not sent @ times. $(document).ready(function () { function validateemail(email) { var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-za-z\-0-9]+\.)+[a-za-z]{2,}))$/; return re.test(email); } function posttogoogle() { var fname = $('#fname').val(); var lname = $('#lname').val(); var email = $('#email').val(); var mobile = $('#mobile').val(); var answer = $('#answer').val(); if ((fname !== "") && (lname !== "") && (email !== "") && (mobile !== "") && ((answer !== "") && (validateemail

jquery - display random text from a list on submit from textarea -

i'd achieve following: i have text area input ( button type). the user fill text area, otherwise, on submit, text being display ( in div) should different ( taken randomly list or other word ). on moment have following: <div class="row"> <div clas="col-md-12"> <form name="myform"> content added: <textarea name="mycontent">add name</textarea> <input type="button" value="add content" onclick="addcontent('result', document.myform.mycontent.value); setcookie('content', document.myform.mycontent.value, 7);"> </form> </div> </div> <script> function addcontent(divname, content) { document.getelementbyid(divname).innerhtml = content; } </script> which make appear text added in area in other div. have no idea of path should take display text fro specific list randomly instead. any highlight, amazing ! th

python - Determine what file a syntax error coming from -

i having incredibly frustrating time trying off ground django setup. i'm sure has no-no regarding python3 , in requirements file. anyways when run command django project directory: python3 manage.py runserver --settings=my_test_app.settings.development the output is syntaxerror: invalid syntax (__init__.py, line 6) i can't, life of me, figure out __init__.py file error message talking about. i've tried set breakpoint pdb, tried catch exception around calling code, , put print statements in of __init__ files in project no dice. have idea of might going on here? or @ least how figure out file causing syntax error? help. i had same problem when: starting django-twoscoops-project template django-admin.py startproject --template= https://github.com/twoscoops/django-twoscoops- project/archive/master.zip --extension=py,rst,html project_name app_name with django-debug-toolbar ver 0.9.4 disabling django-debug-toolbar or upgrading django-d

c# - Does finding element confirm page being fully loaded? -

in reference answer: https://stackoverflow.com/a/7811812/3146582 does waiting random page element being found by _wait.until(d => d.findelement(by.id("id_your_uielement")); really confirms page loaded ? as loaded assume: all required , designed elements displayed browser not downloading more data page option 1: driver.manage().timeouts().implicitlywait(timespan.fromseconds(120)); option 2: webdriverwait wait; wait = new webdriverwait(driver, timespan.fromseconds(60)); wait.until(driver1 => ((ijavascriptexecutor)driver).executescript("return document.readystate").equals("complete"));

py2neo - Neo4j - poor performance -

i receive daily full csv file customers. need insert/update neo4j database. using query: i create indexes on hash field. merge (xfewyx:customer_bseller {hash:'xyz@hotmail.com'} ) on create set xfewyx.hash = 'xyz@hotmail.com',xfewyx.name = 'xyz ',xfewyx.birthdate = '1975-05-20t00:00:00',xfewyx.id = '1770852',xfewyx.nick = 'clarissa',xfewyx.documentnumber = 'xyz',xfewyx.email = 'clarissajuridica@hotmail.com' xfewyx merge (whhekx:email {hash:'clarissajuridica@hotmail.com'} ) on create set whhekx.hash = 'clarissajuridica@hotmail.com',whhekx.email = 'clarissajuridica@hotmail.com' xfewyx,whhekx merge (jjkont:document {hash:'06845078700'} ) on create set jjkont.document = 'xyz',jjkont.hash = '06845078700' xfewyx,whhekx,jjkont merge (merucb:phone {hash:'nonenone'} ) on create set merucb.areacode = 'none',merucb.hash = 'nonenone',merucb.number = 

html - Make image divs horizontally overflow parent div -

i'm having simple problem can't overcome. have parent div, 4 images inside, images overflow parent div (horizontally) can't seem achieve this. .imgbanner { border: 1px solid black; width: 400px; height: 400px; display: inline-block; } .slideshow { width: 400px; } <div class="slideshow"> <img class="imgbanner"> <img class="imgbanner"> <img class="imgbanner"> <img class="imgbanner"> </div> this code using, doesn't seem overflow, though using display inline-block. the outcome hide overflown images, , use javascript create slideshow. edit: forgot add fiddle. https://jsfiddle.net/pwl2hy7s/ thanks :) you can use white-space: nowrap; on container. allow elements continue being inline, without being forced break.

java - Netty - Reuse Channel for periodic HTTP requests -

i want establish connection https server (for example google.com) , periodically obtain fresh content. i wrote simple http client: public class asyncloader { private static final string host = "google.com"; private static final int port = 443; public static void main(string[] args) throws interruptedexception, ioexception, urisyntaxexception { final sslcontext sslctx = sslcontextbuilder.forclient().trustmanager(insecuretrustmanagerfactory.instance).build(); eventloopgroup elg = new nioeventloopgroup(); bootstrap cb = new bootstrap() .option(channeloption.tcp_nodelay, true) .option(channeloption.so_keepalive, true) .option(channeloption.so_reuseaddr, false) .option(channeloption.allocator, pooledbytebufallocator.default) .group(elg) .channel(niosocketchannel.class) .remoteaddress(host, port) .handler(new c

bash - insert single quote with sed -

i want add text on line: sudo sed -i '5imytext 16/16' /file now i've added mytext 16/16 on line 5 of file want add text 'mytext' 16/16 (mytext between single quotes) i tried sudo sed -i '5i'mytext' 16/16' /file but didn't work. can me? the single quotes you're trying use in insertion string interfering ones around sed command. the simplest thing use different quotes around sed command: "5i'mytext' 16/16" normally it's best use single quotes around sed command more tricky in case: '5i'"'"'mytext'"'"' 16/16' basically, need put single quotes inside double quotes somehow , in case there's no reason not double quote whole command. as suggested 123 in comments, alternative put sed command script file: 5i'mytext' 16/16 then use -f switch sed: sed -f script this avoids need use 2 kinds of quotes.

exception - All unit tests throwing BadImageFormatException with Moq? -

i'm in process of increasing code coverage on our software products , have ran issue; of unit tests (when compiled using 'any cpu') failing due throwing 'badimageformatexception'. this exception can circumvented building solution using 'x86' instead of 'any cpu', requirements such need able run them using cpu/x64 bit. all unit tests involving moq follow pretty same format: [testmethod] public void getproduct_validid_productreturned() { //setting object product prod = new product(); prod.id = 7; prod.name = "test"; //create mocks var mockproductrepo = new mock<irepository<product>>(); var testdb = new mock<iunitofwork>(); //setup repo needs return, in case it's product mockproductrepo.setup(m => m.getbyid(7)).returns(prod); //setup database needs return, in case it's our repo we've setup testdb.setupget(m => m.productrepo).returns(mockproductrepo.o

javascript - Make a delegated jQuery Auto-complete -

i using following code create auto-complete textbox. jquery follows. $(function() { $( "#items .slno" ).autocomplete({ source: 'search.php' }); }); the html follows. <table id="items"> <tr class="item-row"> <td class="item-name"><div class="delete-wpr"><a class="delete" href="javascript:;" title="remove row">-</a></div></td> <td><input type="text" id="slslno" class="slno"/></td> <td><input type="text" class="cost"/></td> <td><input type="text" class="qty"/></td> <!-- <td><span class="price"></span></td>--> <td class="price"></td> <a class="add" i

java - Why doesn't all `Executors` factory methods wrap in a `FinalizableDelegatedExecutorService`? -

executors#newsinglethreadexecutor() returns threadpoolexecutor wrapped in finalizabledelegatedexecutorservice (not public). finalizabledelegatedexecutorservice makes sure thread pool shut down when garbage collected. why aren't executorservice s returned executors wrapped in finalizabledelegatedexecutorservice ? threadpoolexecutor shut down without being wrapped in finalizabledelegatedexecutorservice if garbage collected? first of all, shouldn't relying on finalization in first place. 1 argue none of them should wrapped. anyway, not pools created executors factory methods same. of core pool size of zero, there no threads clean up. similarly forkjoinpool cleans idle threads after 2 seconds , becomes gcable once there no threads keep alive, there's no need explicit finalization.

c - icon showing on window but not on .exe file (gtk3 windows7) -

i'm compiling c application gcc uses gtk3 i use gtk_window_set_icon() set icon, , shows on window , taskbar. i want know how can compile application file .exe has same icon. (i.e. when open folder .exe located see icon on .exe file, before launching program) any idea ? (note, running on windows 7 64bit) in fact gtk has nothing with. gtk library graphical user interface . here want manage exectuable file . since you're on windows, achived using resource file . icon can have (name resource.rc example): 1 icon test.ico then gcc suite, can use windres compile this: windres resource.rc resource.o and compile , link together: gcc test.c resource.o

rspec - Ruby Spinach Html Result Page -

i've started looking @ spinach bdd framework , 1 thing i'd have results html page generated similar rspec options: --format html --out rspec_results.html does know of way achieve spinach? thanks! i found created formatter. https://github.com/codegram/spinach/issues/98

linux - Installing devtools fails beacuse of dependency, but dependency is not available for the R version I have -

configure: error: --------------------------------------------- openssl library required please install: libssl-dev (deb) or openssl-devel (rpm) --------------------------------------------- see `config.log' more details error: configuration failed package ‘git2r’ * removing ‘/home/udi/r/x86_64-pc-linux-gnu-library/3.2/git2r’ error: dependency ‘openssl’ not available package ‘httr’ * removing ‘/home/udi/r/x86_64-pc-linux-gnu-library/3.2/httr’ error: dependencies ‘httr’, ‘git2r’ not available package ‘devtools’ * removing ‘/home/udi/r/x86_64-pc-linux-gnu-library/3.2/devtools’ however, when try install libssl-dev (i have ubuntu 14.04.3) got message "‘libssl-dev’ not available (for r version 3.2.2)". any idea do? download new r version or there other solution? thank in advance. that system package - not r package. command line can run sudo apt-get install libssl-dev

javascript - Simulate real click programatically -

i using code identify if click programatically triggered. how should edit $('#x').trigger('click') simulate real click? (hasownproperty should return true 'real') $('#x').click(function(e) { if(e.hasownproperty('originalevent')) { $('#out').append('<li>real</li>'); } else { $('#out').append('<li>unreal</li>'); } }); $('#y').click(function() { $('#x').trigger('click'); //how edit }); so want not possible . real click - elevated permissions (like window.open no being blocked popup blockers) cannot simulated. if insist though... particular case might solved dispatching click event programmatically element. in many ways can error prone. var event = new event('click'); $('#x')[0].dispatchevent(event);

sql server ce - how to insert multiple rows/bulk records in MS SQL CE database with SQL insert statement? -

i insert multiple records (bulk insert) in ms sql ce. can access ce (*.sdf) database via vs 2010 studio. i googled , found link below bulk insert syntax. inserting multiple rows in single sql query? i prepared following syntax (just showing 3 records now) : insert comptegenerals (company, lineid, account, description1, description2) values (999999, 1, n'4000', n'clients', n'klanten') ,values (999999, 2, n'4400', n'fournisseurs', n'leveranciers') ,values (999999, 3, n'4510', n'tva à payer', n'verschuldigde btw') but how can insert bulk records? (since sql ce database re-created regularly (development), don't want add records manually) please advice. that syntax not supported sql server compact. can bypass query processor fast inserts, sqlcebulkcopy library simplifies that, available @ http://sqlcebulkcopy.codeplex.com

java - Use IntelliJ structural search to replace field and its expression with new field -

Image
i want use butterknife android. need annotate fields based on expressions elsewhere in code. have code this private string myfield; ... public myclassconstructor() { ... myfield = res.getstring(r.string.my_string_id); ... } i want this @bindstring(r.string.my_string_id); string myfield; ... public myclassconstructor() { ... ... } in result expression gone, , field annotated based on old expression. is possible kind of search , replace in intellij's structural replace? seems not gracefully handle case when lines of interest not adjacent , in different locations structurally. tried basing on class template, , used $statement$ (0-unbounded occurrences) did not work me. i realized relatively simple regular expressions, simpler getting intellij structural search play ball, learn tools, still know if possible. while search structurally somehow working , it's possible make search query, replace structuraly kind of tools made "aliens

elixir - How to add computed values to a map inside a pipe? -

i have situation. collect files ftp servers. example sample file 41199999 32355830 00003800 484e0040 48096e40 479e9b80 471b3f00 470a2100 431f0000 30305332 00003000 00003432 ... each line in each file converted using conversion formula each line converted key in map. have %{"ax"=>value} being x number of line , value converted value. apart need more keys,calculated keys, based on keys read each file in code i map this %{"a1"=>1,"a2"=>2, etc} at line enum.at(0) in next code |>enum.map(&tools.processfile(pid,&1,conversion)) |>enum.at(0) then problem how add calculated keys map. have example f1 function takes map , calculates f1 key def f1 map %{"f1": map["a1"]+2} end how add f1 key map in pipe code above %{"a1"=>1,"a2"=>2, "f1"=>3} regards if understand right, should define f1 function such append value existing map, rather retu

subclass - Nested subclasses in C++ -

i'm trying make nested class subclass of parent: struct x { struct y : public x {}; }; unfortunately, doesn't seem allowed in c++, g++ produces error error: invalid use of incomplete type 'struct x' however, actual code has x templated class: template<typename t> struct x { struct y : public x {}; }; i same message, time it's warning: warning: invalid use of incomplete type 'struct x< t >' my question is: why former case illegal, while templated case gives warning? templated version works expect (i can create instances of x<t>::y , cast them x<t> , , on), warning mean shouldn't use it? problems can expect run if ignore warning? technically, far compiler concerned, layout of base ( x ) not need known until template ( x ) instanciated. , template ( x ) may not istantiated before defined. @ point, it's layout known. simplest way error template try istantiate y inside x : template<ty

Login & Signup iOS Swift - Core Data -

Image
i want create login , signup functions within swift using core data. this code store data in signupvc; let appdel:appdelegate = (uiapplication.sharedapplication().delegate as! appdelegate) let context:nsmanagedobjectcontext = appdel.managedobjectcontext let newuser = nsentitydescription.insertnewobjectforentityforname("users", inmanagedobjectcontext: context) nsmanagedobject newuser.setvalue(txtusername.text, forkey: "username") newuser.setvalue(txtpassword.text, forkey: "password") newuser.setvalue(txtemailadd.text, forkey: "email") { try context.save() } catch {} print(newuser) print("object saved.") this code in loginvc; @ibaction func signintapp(sender: uibutton) { let appdel:appdelegate = (uiapplication.sharedapplication().delegate as! appdelegate) let context:nsmanagedobjectcontext = appdel.managedobjectcontext let request = nsfetchrequest(entityname: &qu

ruby on rails - How to create booking according to its pitch? -

i have model pitch fetching grounddetail_id. want show pitch available in ground. how can book pitch of ground.. grounddetails_controller.rb class grounddetailscontroller < applicationcontroller before_action :find_ground, only: [:show, :edit, :destroy, :update] def index @grounddetails = grounddetail.all.order('created_at desc') end def new @grounddetail = grounddetail.new end def edit end def show end def create @grounddetail = grounddetail.new(ground_params) if @grounddetail.save redirect_to @grounddetail else render 'new' end end def update if @grounddetail.update(ground_params) redirect_to @grounddetail else render 'edit' end end def destroy @grounddetail.destroy redirect_to root_path end private def find_ground @grounddetail = grounddetail.find(params[:id]) end def ground_params params.require(:grounddetail).permit(:name, :working_hours, :end_time, :address, :contact_no, :email, :numbe