Posts

Showing posts from February, 2012

c# - MVC 4: How to make DropDownListFor return 0 as optionLabel value? -

i have create view multiple dropdownlistfors. each time new object created 1 of dropdownlistfors should have value, want others return 0 result when optionlabel left selected. how assign 0 value dropdownlistfor's optionlabel? edit: here example of dropdownlistfor code in view: @html.dropdownlistfor(model => model.cardreward.id, new selectlist(viewbag.cardreward, "id","name"), "none") when render page creates list none @ top this: <option value>none</option> i want this: <option value="0">none</option> in documentation dropdownfor optionlabel parameter (where you're passing "none") described as: the text default empty item. so designed empty item. need add additional item select list in order 0 value. i have used following extension method accomplish (sorry untested, there may minor errors): public ienumerable<selectlistitem> insertemptyfirst(this ienumera

php - Parsing data bug -

i have following code: $_request[ 'lom' ] var_dump($_request[ 'lom' ]); the result following json: { "id":0, "type":"root", "related_dropzone_id":0, "related_dropzone_order":0, "children":{ "1376071054231":{ "id":"1376071054231", "type":"section", "related_dropzone_id":0, "related_dropzone_order":1, "dropzones":{ "a":1376071054231 }, "options":{ }, "children":{ "1376071056267":{ "id":"1376071056267", "type":"section", "related_dropzone_id":1376071054231, "related_dropzone_order":0, "dropzones":{ &qu

java - Why does this print out twice? -

i've noticed when use paintcomponent in java if use system.out.println(); things print out 2, 3, , 4 times. know when use extends jpanel automatically called, why more once. here code try yourself. import javax.swing.*; import java.awt.*; public class stack extends jpanel{ public stack(){ jframe frame = new jframe(); frame.setdefaultcloseoperation(jframe.exit_on_close); frame.setvisible(true); frame.add(this); frame.setlocationrelativeto(null); frame.setsize(200, 200); } public static void main(string args[]){ stack s = new stack(); } public void paintcomponent(graphics g){ super.paintcomponents(g); g.drawstring("thank you!", 100, 100); system.out.println("why?"); } } system.out.println gets called once - method called repeatedly. everytime paintcomponent called prints why? . this method being called multiple times, ie, frame resizes or such , in turn makes appear sysout being executed mor

internet explorer - HTTP POST converting to HTTPS GET on redirect by proxy server -

i have weblogic cluster domain has following configuration: 2 managed servers, 1 admin server, , proxy server.my webapp deployed in 2 managed servers. the ssl ports on both managed servers enabled , have added user data constraint confidential in web.xml, ssl ports used communication mywebapp. <user-data-constraint> <transport-guarantee>confidential</transport-guarantee> </user-data-constraint> now here issue: the http post request form internet explorer client http port of proxy server gets converted https when proxy server redirects request ssl port of 1 of managed server. hence, internet explorer client never receives response of http post. my goal here enforce https if client uses http. there problem configuration? want somehow prevent internet explorer converting http post http on receiving "302 found" if client gets http 303 see also code, unconditionally submit request. if client gets http 302 found , should submit sam

Go - how to organize code for dynamic packages -

i have small web application written in go. created base larger system , extendable components can added/removed without needing base modified in way. the structure currently: app modules core ... core files here ... app.go main.go app.go contain routing method should take web request , based on request path know module responsible handling request. each module/component having on controller. each component have own package name think going impossible since go forces explicit import. for example may add new module/component called blog such as: app modules core ... core files here ... controller.go blog ... blog files here ... controller.go app.go main.go there several ways achieve goal. since go not support dynamically loaded libraries @ moment, need recompile application whenever add/

How to query the number of elements stored in a db.ListProperty in google app engine -

the entity class defined like: class item(db.model): list = db.listproperty(db.key) what's attribute or function return number of elements stored in listproperty, can use like {{ item.list.... }} to display in html. it's list can use len() on it. total = len(item.list) or if using jinja on html can use count filter {{ item.list|count }}

javascript - sp.js get all lists by content type -

i have combed through sp namespace docs , not found go on. i found snippet http://www.c-sharpcorner.com/blogs/12134/how-to-get-the-list-content-types-using-csom-in-sharepoint-2.aspx //// string variable store siteurl string siteurl = "http://c4968397007/"; //// context sharepoint site access data clientcontext clientcontext = new clientcontext(siteurl); //// content type collection list "custom" contenttypecollection contenttypecoll = clientcontext.web.lists.getbytitle("custom").contenttypes; clientcontext.load(contenttypecoll); clientcontext.executequery(); //// display content type name foreach (contenttype ct in contenttypecoll) { console.writeline(ct.name); } console.readline(); which a lists content type. my thought lists, content types, use id/title query lists data. seems ton of work in display template. am on rig

java - File.canExecute() says every file is executable? -

this question has answer here: in java file.canexecute() do? 3 answers i using code test it; public class canexecutetest { public static void main (string[] args) { file currentdir = new file(system.getproperty("user.dir")); traverse(currentdir); } public static void traverse(file dir) { string[] filesanddirs = dir.list(); (string fileordir : filesanddirs) { file f = new file(dir, fileordir); if (f.isdirectory()) { traverse(f); } else { system.out.print(f); if (f.canexecute()) { system.out.println(" can execute"); } else { system.out.println(" cannot execute"); } } } } } this outputs every file executable file. d

this - PreloadJS + Typescript -

i have been stuck 4 days going on so! please reference preloadjs definitions: https://github.com/borisyankov/definitelytyped/blob/master/preloadjs/preloadjs.d.ts from line 26. my question is, how addeventlistener in typescript while binding class scope? imagine (semi psudo): class test { private _loader:createjs.assetloader; constructor() { this._loader = new createjs.assetloader(); this._loader.addeventlistener(???????????); this._loader.load(); } onloadcomplete(???): ??? { } } using typescript 0.9.1.0: class test { private _loader: createjs.assetloader; constructor() { this._loader = new createjs.assetloader(); this._loader.addeventlistenerthis.onloadcomplete); this._loader.load(); } onloadcomplete = () => { console.log(this.whatever); }; } the important part here using member initialization syntax ( member = v

Include image file in svn diff patch -

i creating svn diff patch, seems image files not getting included. patch contain similar lines each image file, shown below: index: crimgeoprofile/code/jquery/css/ui-lightness/images/animated-overlay.gif =================================================================== cannot display: file marked binary type. svn:mime-type = application/octet-stream index: crimgeoprofile/code/jquery/css/ui-lightness/images/animated-overlay.gif =================================================================== --- crimgeoprofile/code/jquery/css/ui-lightness/images/animated-overlay.gif (revision 1510040) +++ crimgeoprofile/code/jquery/css/ui-lightness/images/animated-overlay.gif (working copy) i using following command create patch: svn diff > test.diff any suggestions on how can include image files appreciated. svn not support include binary files in diffs. side note: git support binary files. resulting patch file looks this: diff --git a/bin/windows/sdl_mixer.dll b/bin/

css - Draw a Border but have it not have it inherit object opacity -

please see following jsbin: http://jsbin.com/uyonux/1 it working desired on hover state. focus state not work desired on focus blue color not inherit opacity of .4 want solid #13a3f7 color. there way append border without having use element opacity? i tried pseudo elements inherit opacity. the other solution take 60% plus of #13a3f7 don't think works due saturation. i know change image point trying use 1 black icon , adjust opacity on various states. thanks button { background-image: url("data:image/png;base64,ivborw0kggoaaaansuheugaaabaaaaaqcayaaaaf8/9haaaaleleqvr42mngwa/+qzhzygam2e8adwed6b+i+yneppslzfjbygbfytdemxma8sa+m9tict0aaaaasuvork5cyii=") ; border: none; height: 23px; width: 26px; background-repeat: no-repeat; opacity: 0.4; filter: alpha(opacity=40); background-position: center center; } button:focus { border: 1px solid #13a3f7; } button:hover { background-color: #cfcfcf; box-shadow: 0 1px #696969; opacity: 0.65;

java - AspectJ pointcut in object-aspect is not working -

i can't find out why pointcut not working. compiler not give warnings, cannot explain why not working. i'm using aspectjrt 1.7.2 , aspectjtools 1.7.0 in maven javafx application. my aspect looks this public privileged aspect movieaspect perthis(movieinit()) { pointcut movieinit(): execution(movie.new(..)); pointcut reloadmainpanelview(): cflow(execution(void main.views.mainframe.mainpanel.fillmainpanel(..))); before(arraylist tar): target(tar) && reloadmainpanelview() && call(void java.util.arraylist.clear()) && !within(movieaspect) { system.out.println("test"); } my movieaspect located in package main.models and here little explanation of happening within code when gui loads initialize mainframe class. before aspect loads movie-objects. , when mainframe initializes views movie-objects in mainpanel first clears view-objects , reloads them. because added views listener corresponding movie-object need

javascript - Proper Switch Statement? -

<script language="text/javascript"> var url = document.url; <--switch (url) { case "http://www.greatarchitect.us/defatank": document.write("displaying defatank"); break; case "seeingblue": document.write("displaying seeingblue"); break; case "shiroshii": document.write(""); break; case "theend66": document.write(""); break; case "wakawaka647": document.write(""); break; case "xtheguythatplays": document.write(""); break; }--> </script> what wrong above code? i'm trying load specific data based on page url. i updated code. how display url sure i'm checking case against right url? document.url returns entire web address. need filter/chop down in order manipulate part want. also you're declaring script wrong. should <scr

image - opening a raw with imagej in command prompt -

i'm trying create .bat file read .bsv files , turn them color pngs. first part of using imagej open .bsv, , using "save all" plugin added. tried making macro gives me errors. how i, in command prompt, image j, do: file->import->raw->myfile.bsv , select 8-bit, width: 4000, height: 2672, offset first image: 0, number of images: 40, gap between images: 0, little-endian byte order. then plugins->save all thanks can offer! using macro recorder ( plugins > macros > record... ) in imagej, described procedure produces following code: run("raw...", "open=/path/to/myfile.bsv image=8-bit width=4000 height=2672 offset=0 number=40 gap=0 little-endian"); run("save all"); if save macro file e.g. mymacro.ijm , should able run imagej macro option (depending on platform): -macro mymacro.ijm hope helps.

android - How TXT file write and clean -

i want write 1 value example 'm' txt file , next time want write new value before write clean value in txt , new write. example : i save 'm' write in m.txt next time write in txt file delete valaue 'm' in txt file , write new value example 'n' (any platform) delete previous file (if exists) , create again.

How can I mux (or encapsulate) H.264 RTP output into a container using FFMPEG? -

i working on effects of network losses in video transmission. in order simulate network losses use simple program drops random rtp packets output of h.264 rtp encoding. i use joint model (jm) 14.2 in order encode video. however, don't use annexb format output, instead choose output rtp packets. jm output generated rtp packets rtp headers , payload sequence. after that, of rtp packets dropped using simple program. then, can decode output bitstream using jm , it's error concealment methods. the main purpose of process evaluate differences created network losses on human video quality perception. in order measure perceived quality, shown video must in decoded form (i.e. full resolution) or can decodable @ receiver side. rtp packets created jm encoder cannot decoded without jm software installed. however, proper header (or container) video players able decode bitstream. so, goal in question encapsulate encoded rtp packet bitstream in common container such avi or mp4 have c

c++ - Should the order of import statements matter when importing a .so? -

i getting following import error when trying load python module compiled using boost python. importerror: /path/to/library/libxml2.so.2: symbol gzopen64, version zlib_1.2.3.3 not defined in file libz.so.1 link time reference strangely don't see error if non standard module imported. i.e if import other module , module, fails import error. not sure what's going wrong or how debug. edit: show issue: $ python -c 'import json, libmyboost_py_lib' # not work!!! traceback (most recent call last): file "<string>", line 1, in <module> importerror: path/to/xml_library/libxml2.so: symbol gzopen64, version zlib_1.2.3.3 not defined in file libz.so.1 link time reference $ python -c 'import libmyboost_py_lib, json' # works now!!! $ its not json, few other modules cause same issue when imported before module. eg. urllib2 the order of import statements matter. as documented in python language reference : once name of module

text - Matching brackets and indentation in RichTextBox using C#? -

i want make code editing control can format text visual studio,till have implemented syntax highlighting , autocompletion want format text in nested curly braces.for example:consider loop, for(int i=0;i<=10;i++) { function_one(); //this should tab away first brace function_two(); //so if(a==b) //so { //this should 4 tabs away first brace messagebox.show("some text");//this should 6 tabs away first brace } //this should 4 tabs away first brace } now want should this, for(int i=0;i<=10;i++) { function_one(); function_two(); if(a==b) { messagebox.show("some text"); } } i have tried regular expressions @ point fail match,so tried match code code cannot match nested code or hard implement ,so there way achieve this,and 1 more thing

How webpages like Statigram doesn't exceed Instagram API rate limits -

well, pretty says on tin. i'm curious how pages statigram search functionality without users authentication , not exceeding limits? if i'm correct, instagram api allows 5000 calls per hour, believe it's indeed have more traffic 5000 requests per hour. maybe it's dumb question , statigram has special deal instagram use api or maybe don't use api , use other method? most they're using 1 of following methods: an arrangement instagram credential rotation ip rotation heavy caching (especially across credentials or ips) screenscraping in cases this, if don't have special arrangement, you're violating terms of service. if think service useful enough instagram willing whitelist make more requests, in touch them.

Experiment trying to avoid Python circular dependencies -

i have testing environment try understand how python circular dependencies can avoided importing modules import x statement, instead of using from x import y : test/ __init__.py testing.py a/ __init__.py m_a.py b/ __init__.py m_b.py the files have following content: testing.py: from a.m_a import m_a.py: import b.m_b print b.m_b class a: pass m_b.py: import a.m_a print a.m_a class b: pass there situation can't understand: if remove print statements modules m_a.py , m_b.py or m_b.py works ok, if print present @ m_b.py , following error thrown: file "testing.py", line 1, in <module> a.m_a import file "/home/enric/test/a/m_a.py", line 1, in <module> import b.m_b file "/home/enric/test/b/m_b.py", line 3, in <module> print a.m_a attributeerror: 'module' object has no attribute 'm_a' do have ideas? it "works" p

facebook - Uploading image to FB staging server using jssdk returns error -

i'm creating fb app upload , post images user's wall, , i'm stuck @ point. upload images on fb staging server, because server small. when try post image code fb.api('/me/staging_resources?access_token='+access_token, 'post', {file: file_uri}, function(response) { if (!response) { alert('error occurred.'); } else if (response.error) { console.log('error: ' + response.error.message); } else { console.log('file uri ' + response.uri ); file_uri = response.uri; } }); where file_uri variable contain https address image, receive error "(#100) invalid file. expected file of 1 of following types: image/jpg, image/jpeg, image/gif, image/png" . tested graph api explorer, same error. tried everything, put url file generate image, put direct url image, http, https, image other site... same. have me, maybe missing something? thanks in advance, nikola edit - solution tha

ios - Xcode 5 shrinks every object on Storyboard by 20px -

recently i've opened old ( xcode 4.6 ) project in xcode 5 , has automatically converted uistoryboard new format (sdk 7). when run on ios 7 simulator , ok, when i'm trying run on ios 6 , layout pretty broken. height of every object in storyboard shrinken 20px . same thing happens when set view as- ios 6 , earlier. , when i'm trying open in xcode 4.6, shows same picture (shrinken objects). expect navbar-related. don't use autolayout . how can solve this?

javascript - Using document.write with an <object> -

the code below works is. want use code display specific twitch streams based on page loaded. <script type="text/javascript"> var stream = location.pathname; switch (stream) { case "/defatank": document.write("defatank's live stream page"); break; case "/seeingblue": document.write("seeingblue's live stream page"); break; case "/shiroshii": document.write("shiroshii's live stream page"); break; case "/theend66": document.write("theend66's live stream page"); break; case "/wakawaka647": document.write("wakawaka647's live stream page"); break; case "/xtheguythatplays": document.write("xtheguythatplays' live stream page"); break; } </script>

javascript - First element in array -

why indexes in arrays start 0? have binary? example: var myarray = [5,6,7,8]; to access number 5, have myarray[0] but why? no, don't have real problem. can evidently tell i'm new stuff. i'm sure has been asked answered hundred times, i'll bite. one way of looking @ "index" or "key" "offset". myarray acts pointer first item in series of items. specifically, points number "5" in memory. when myarray[1] it's saying "the location of first element in myarray plus 1 item over", jumping on first element. in c, when write *myarray (pointer dereference) gives first element. #include <stdio.h> int main(void) { int myarray[] = {5,6,7,8}; printf("%d",*myarray); // prints "5", equivalent myarray[0] printf("%d",*(myarray+1)); // prints "6", equivalent myarray[1] return 0; } there more practical reasons "that's way compute

eclipse - C++ HelloWorld program compiled with MinGW crashes with "Illegal Argument" -

i decided time learned c++, , after struggling 3+ hours trying compiler work, created working program. however, seemingly spontaneously broke when tried refactor project in eclipse cutting , pasting it. program crashes, , windows brings dreaded dialogue "helloworld.exe has stopped working." bit of debugging revealed "cout" considered illegal argument. looked more issue, , i'm suspicious has compiler apparently being 32-bit, have 64-bit system. executable listed in eclipse "helloworld.exe - [x86/le]." (minus period.) program in full below: #include <iostream> using namespace std; int main(){ cout << "hello world!" << endl; return 0; } i've discovered creating new "helloworld" c++ project in eclipse absolutely nothing fix issue, using unmodified code , settings. have suggestions why happen? edit: debugging information: upon running program: hello world! program received signal signill, illeg

xml - Spring 3.1 : Cannot find the declaration of element 'beans' -

here's applicationcontext.xml: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemalocation="http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"> <bean name="documenttrashcleanerjob" class="org.springframework.scheduling.qu

idangerous swiper prevents HTML5 play button working in ie10 -

i have embedded html5 video works fine in browsers (or fails gracefully, if browser old or lacks video support). since site uses idangerous swiper ( http://www.idangero.us/sliders/swiper/api.php ), custom video controls - 'play/pause' button - not work in internet explorer 10. if remove swiper js code embed head area of html, embedded video plays fine in ie10. problem seems swiper intercepting click on play button in ie10 - , therefore solution seems to disable swiper @ least small area of page. but it's not clear how it. there seems scantly documented new feature in june 2013 swiper release lets 1 create 'noswiping' class, wrapping video in div class not solve ie10 problem. has else needed disable swiper element , succeeded in doing so, particularly regarding ie...? glad see code example. own project still on localhost. all have add html5=1 in src attribute of iframe : the video displayed html5 if available, or fallback flash player. you

wpf - Communicating between Views -

my wpf app has 2 views , each view has own view model. 1 view shows customer names on left side. second view shows list of items ordered selected customer(on first view) on right side. data in second view should changed automatically based on selection on first view(customer names view). suggestions. in advance. what you're describing called 'master-detail' binding. general idea left hand customer-list view (the master view) bound viewmodel comprising list of customerviewmodels, , selected customerviewmodel. changing selected item in customer list update selected customerviewmodel in viewmodel. each of customerviewmodel should have collection of purchaseviewmodels detail customer's orders. right hand side view (the detail view) should set it's datacontext selected customerviewmodel, , use list of purchases. here eerily well-suited project use example: http://www.codeproject.com/articles/332615/wpf-master-details-mvvm-application

Set Firefox to Allow Cross-Domain Fonts -

i have read firefox disables cross-domain fonts "by default." use website stores @font-face on cdn subdomain , have apparently not added header information .htaccess file. enable cross-domain fonts in firefox configuration @ least can view website way it's meant seen. i've done lots of research can't find way enable it, have read it's not supported "by default" leads me believe option. if it's not, know of add-on enables it, or way enable cross-domain fonts?

javascript - Dropdown menu item reversal -

i new javascript , code looks below in html: <select name="dropdown" onchange="javascript: alertuser()" > <option value="0" selected>eat</option> <option value="1">work</option> <option value="2">sleep</option> <option value="3" >enjoy</option> in javascript: function alertuser() { confirm("are sure?"); } now, here problem. when select element dropdown, pop confirmation dialogue "are sure?". if click ok, selection should change selected value. if cancel, selected value should reset selected value in dropdown list. could please me solve problem. thank you you can use this: window.onload = function () { var select = document.getelementsbyname('dropdown')[0]; var lastselected = select.value; select.onchange = function () { var newselected = select.value; if (confirm("are su

database - Restricting a Char to Two Values in Oracle -

i'm creating table in pl/sql, want char column allowed r or d . i've been looking around haven't found concrete answer online. maybe i'm not using right search term. alter table tablename add constraint constraintname check (columnname in ('r', 'd')); find out more

Writing SQL query: slightly complicated -

i have table primary key id , 2 columns order , status. value status of 'a', 'p', 's', 'o' or 'c'. need to find values of order status 'a' or 'c'. how should write sql query that? know basic sql unable results using that. sample table: id order status 1 1234 2 2343 p 3 4351 s 4 8675 c 5 9867 6 9867 c 7 1234 8 2343 expected result: 1234 8675 9867 select distinct t.[order] table1 t not exists ( select * table1 t2 t2.[order] = t.[order] , t2.status not in ('a', 'c') ) or select t.[order] table1 t group t.[order] having sum(case when [status] in ('a', 'c') 1 else 0 end) = count(*) or select distinct t.[order] table1 t t.[order] not in (select t2.order table1 t2 t2.status not in ('a', 'c')) see sql fiddle example details btw, order not best name column, avoid using k

caching - Chrome Extension avoid reloading popup -

i'm developing chrome extension has popup browser action, , i've realized every time user clicks extension icon, reloads script. if have ajax call in extension, how can cache or save data, such not have make same call every time user opens extension popup?

javascript - Value becomes empty when selecting button -

my html code : <div class="span3"> <div>debit/credit</div> <div class="btn-group" data-toggle="buttons-radio" id="investadjust-debitcredit-button"> <button name="debitcredit" type="button" id="credit-button" class="btn active" value="credit" >credit</button> <button name="debitcredit" type="button" id="debi-button" class="btn" value="debit" >debit</button> </div> </div> javascript code data: $("#investadjust-debitcredit-button>.active").val() when load page values empty value because of unable value of selected button. how resolve this. first of all, dont think switching between button or input elements help. jquery entirely independent of that well, have not mentioned javas

php - 2 Mysql query for number of rows and main query? -

i'm trying find solution have total rows affected of query without "limit" clause , records of query limit clause... how without 2 queries (count(*) , main query? thanks edit: here query: $result = mysqli_query($link,"select distinct p.* posts p join abos on p.userid = a.blogid or p.userid = 11 left join posts_denied r on r.post_id = p.id , r.userid = 11 (a.userid = 11 or p.userid = 11) , r.post_id null order p.id desc limit 5"); try mysql_affected_rows like mysql_query($sql_query); echo "number of rows effected = ".mysql_affected_rows(); see link and try avoid using mysql_* functions due deprecated.instead use mysqli_* functions or pdo statements.

c++ - When I write a file in mode "wb", what will happens? -

when write "asklfj123" file in mode "wb", open in vim, why can still see asklfj ?but can not see 123 in vim. mean when write in mode "wb", program not convert ascii code, editor open ascii code, should garbage values in text editor, isn't it? why can still see them? binary mode means "don't translate anything". in "text" mode (that "not binary mode"), on systems, representation of example newlines different between os's file representation , standard '\n' c uses newline representation. in systems there special characters represent end of file. when in text mode, these characters translated , understood mean newline , end of file, respectively. now, writing text in "binary" mode work fine, , suspect problem else - without code, it's impossible answer what. mention of vim makes me think using linux or other unix-based system, newline indeed same '\n' , no translati

autotools - Testing for infinite loops -

i'm horsing around esoteric programming language, small s.c.r.i.p.t. at same time trying come grips gnu autotools, , autotest. just curious if there preferred methods of testing around infinite loops. meaning, i'd test infinite loops expected behaviour constructs. is there paradigm, or just; bad, don't bother, write different tests? edit: adding corollary; there in autotest performance testing? know edge cases can't nailed down run run, 'test took longer 1 second' warning level nice feature. i've been looking, , don't see in framework, did find samples of tests (i had build carl9170 device driver , sources have examples), explicit tests, , not framework warning if things taking long.

dataset - Error in reading in data set in R -

when reading in data set in r follows: dataset.df <- read.table("c:\\dataset.txt", header=t) i following error message: error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 1 did not have 145 elements what mean , can tell me how fix it? this error pretty self-explanatory. there seem data missing in first line of data file (or second line, case may since you're using header = true ). here's mini example: ## create small dataset play cat("v1 v2\nfirst 1 2\nsecond 2\nthird 3 8\n", file="test.txt") r automatically detects should expect rownames plus 2 columns (3 elements), doesn't find 3 elements on line 2, error: read.table("test.txt", header = true) # error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : # line 2 did not have 3 elements look @ data file , see if there indeed problem: cat(readlines("test.txt"), sep = "\n")

wpf - Elysium style destroyed when using WindowsFormsHost -

i'm using elysium in wpf application metro styled interface. style not preserved when try use windows forms control. example: <grid> <richtextbox /> </grid> gives perfect result (with thin white border around wpf control) however: xmlns:winforms="clr-namespace:system.windows.forms;assembly=system.windows.forms" . . <grid> <windowsformshost name="wfh"> <winforms:richtextbox /> </windowsformshost> </grid> gives me different legacy windows form type of border. i want thin white border around windowsformelement if possible. i'm out of ideas @ moment.

knockout.js - How can I bind selectedItems in kendoGrid? -

i'm using rniemeyer's kncokout-kendo.js http://rniemeyer.github.io/knockout-kendo/web/grid.html i've 'people' , need selected person. <div id="grid" style="width:450px" data-bind="kendogrid: {height:400,columns:['id','name'],navigatable:true,selectable:true,rowtemplate: 'rowtmpl', usekotemplates: true,data: people, select: selectedperson,value:selectedperson }" ></div> neither 'select' nor 'value' works. people observablearray the example not work both selectedperson observable, selectedperson observablearray. i'm not familiar kendo, judging this existing fiddle think need use change option part of grid configuration: kendogrid: { change: function (event) { self.selecteddata(this.dataitem(this.select()[0])); } } see this fiddle contains code question (with few options commented out because no view code pos

Django: constructing dyanamic query -

i have table genre having values drana, thriller, sci-fi, etc under "name" column. , table movie . in movie table genre manytomanyfield genre table scenario movie_1 = {d,s, t} movie_2 = {s,t} movie_3 = {d} movie_4 = {d, t} d: drama, s: sci-fi, t: thriller case 1: let user choses d , t (which checkbox options) all d movies : movie_1, movie_3, movie_4 ---(a) t movies : movie_1, movie_2, movie_4 ---(b) when user selects options : want show movie_1, movie_2, movie_3, movie_4 intersection of both (a) , (b) above case following query can done like: qs_d = genre.objects.get(name="drama") qs_t = genre.objects.get(name="thriller") m_d = movies.objects.filter( q(gen__id=qs_d.id) | q(gen__id=qs_t.id)).distinct() movie_name in m_d: print movie_name in above queries have hard-coded genre "drama" , "thriller" (for explanation) , but i'll movie genre in list {"drama",

objective c - Changing bitrate on the fly in AVCaptureSession -

i developed functional live streaming app on ios biggest issue right quality of service. implemented rtsp protocol on phone send sr packets , handle rr packets qos informations. need find way change bitrate settings stream session on fly in order smooth stream. currently can set own custom settings method : (avassetwriterinput *)assetwriterinputwithmediatype:(nsstring *)mediatype outputsettings:(nsdictionary *)outputsettings however, outputsettings readonly need find way deal it. @property(nonatomic, readonly) nsdictionary *outputsettings i saw livu app can it, there should way :) so possible change bitrate of avcapturesession without restarting , configuring new avcaptureinput? saw can change defined presets want configure bitrate more accuracy.

android - Convert to time to millisecond -

i want checked if set time less calender(mobile device)time. shows alarms set , if set time not more 1.5 hr shows "ruko ruko" message. if both conditions false go else condition. not gave me expected results. here code: gregoriancalendar mcalender=new gregoriancalendar(); mcalender.set(2013, 7, 17, 13, 0); if(mcalender.gettimeinmillis()<=cal.gettimeinmillis()){ toast.maketext(getbasecontext(), "sets ", toast.length_short).show(); } else if(mcalender.gettimeinmillis()+5400000<=cal.gettimeinmillis()){ toast.maketext(mcontext, "ruko ruko", toast.length_short).show(); } else{ toast.maketext(getbasecontext(), "time not gone ", toast.length_short).show(); } the problem mcalender.gettimeinmillis() checked first. example, when alarm set 5:30, @ 4:30 first part true already, else if section entirely skipped. got reverse order , :) if(mcalender.gettimeinmillis()+5400000<=cal.gettimeinmillis()){ //if sti

unity3d - Messing up Vectors in C# (Unity Engine) -

i'm new programming in c# in unity , there problems when moving in z-axis. problem continue move when let go of button. however, when move in x-axis fine, letting go of button stop player. code below: using unityengine; using system.collections; public class player : monobehaviour { public vector3 motion = new vector3(); private charactercontroller controller; private bool onground; private float xrot, yrot; public static float x_rotation = 0; public static float y_rotation = 0; private const float lookspeed = 2.0f; public void start() { controller = getcomponent<charactercontroller>(); } public void fixedupdate() { if(screen.lockcursor) { vector3 impulse = new vector3(); if(input.getkey(keycode.w)) impulse.z+=1; if(input.getkey(keycode.a)) impulse.x-=1; if(input.getkey(keycode.s)) impulse.z-=1; if(input.getkey(keycode.d)) impulse.x+=1; if(impulse.sqrmagnitude > 0) { motion += quaternion.euler(

c++ - Implementing a split() function -

accelerated c++, exercise 14.5 involves reimplementing split function (which turns text input vector of strings). 1 must use store input in std::string - class ( str ) & use split function return vec<str> , vec being std::vector - container. str class manages custom pointer ( ptr ) underlying vec<char> data . the str class provides constructor str(i,j) , in str.h below, constructs ptr underlying vec problem arises when try create substrings calling str(i,j) i've detailed in code the issues arise. here whittled-down version of str class (can post more code if needed): str.h #include "ptr.h" #include "vec.h" class str { friend std::istream& operator>>(std::istream&, str&); public: // define iterators typedef char* iterator; typedef char* const_iterator; iterator begin() { return data->begin(); } const_iterator begin() const { return data->begin(); } iterator e

facebook graph api - How to obtain not-friend's public photos -

i trying user public photos (friend's friend). when browse facebook see them, can't access them via api. neither select created, link, caption, images, like_info photo owner in (select uid user username = "...") or object_id in (select uid user username = "kaja.szuminska") or object_id in (select object_id photo_tag subject in (select uid user username = "...")) order like_info desc limit 0, 100 nor .../albums nor .../photos nor .../photos/uploaded works. any ideas? to access photos (public or not) need permission. it's possible access photos (using user_photos permission) or friends' photos (using friends_photos permission). if want scrape public photos, can checking user's public feed. i.e. making api call to: https://graph.facebook.com/{user_id}/feed , filter through entries see if photos posted.

c++ - g++ program linked against clang++ shared lib with shared_pointers -

i've been working on personal parser few month now. @ each step, have verified able compile , work either clang++ or g++. , ok since ( project doesn't use other library stl ). want slice project in 2 part : shared library , program main.cpp file. want because "real" project library, executable exemple of application and/or way test library. note : compile library no warning : for each cpp file : g++/clang++ -std=c++11 -wall -fpic -c file.cpp -o file.o for lib : g++/clang++ -std=c++11 -wall -fpic -shared -wl,-soname,libname.so.0 files.o... -o libname.so.0.1 when compile program same compiler library, good. when compile other (still no warning), application crashes @ execution : *** error in `./math': double free or corruption (fasttop): 0x0000000000f55910 *** ======= backtrace: ========= /lib64/libc.so.6(+0x7b1d6)[0x7f80d76eb1d6] ./libtssa.so.0(__gnu_cxx::new_allocator<std::shared_ptr<textnode> >::deallocate(std::shared_ptr<textnode>

c++ - Delimiter extracting out a range of data -

from textfile(range.txt), range:1:2:3:4:5:6....:n: there's list of result, need extract digit 1 2 3 last digit, last digit may varies so read in file, extract out delimiter , push vector. ifstream myfile; myfile.open("range.txt"); istringstream range(temp); getline(range, line,':'); test.push_back(line); how capture value? have , capture 1 digit. i have , capture 1 digit you need use loop :- while (getline(range, line, ':')) test.push_back(line); later using vector can process integers only.

javascript - Node.js MongoDB .findOne returns best match when querying a String -

if create document in mongodb using create method. ua.create({mystringfield: 'mystringdata'}, function(err, myua){ callback(err,myua); }); later want search new string in database , use method. ua.findone({mystringfield: 'mystringdatanew'}, function(err, myua){ callback(err,myua); }); notice set original mystringfield data 'mystringdata' , searching 'mystringdatanew'. findone() method returns document containing 'mystringdata' result of query. how query exact matches strings in mongodb? many help. i'm pretty getting confused. findone call exact, case-sensitive match. partial matches or case-insensitive need use regexp instance not basic string. suggestion make simple test case separate app, , suspicion db not behaving way think is.

c# - How to use prepared statement using entity framework with MYSQL DB? -

i have been trying incorporate prepared statements application using ef 5.0. kindly @ script below. int parametervalue = 100000; var addparameters = new list<mysqlparameter>(); var param1 = new mysqlparameter(); param1.direction = system.data.parameterdirection.input; param1.value = parametervalue; param1.parametername = "user_id"; addparameters.add(param1); db.database.executesqlcommand(@"delete tbl_user user_id = @user_id", addparameters); it produces error exception: {"fatal error encountered during command execution."} innerexception: {"parameter '@user_id' must defined."} so based on innerexception description changed parameter nae "@user_id" int parametervalue = 100000; var addparameters = new list<mysqlparameter>(); var param1 = new mysqlparameter(); param1.direction = system.data.parameterdirection.input; param1.value = parametervalue; param1.parametername = "@user_id"; addparameters.a

Change a simple html form to be mobile compatible -

i have html form (an image text & select fields) change available mobile devices. what's simplest solution accomplishing task ? i found many explanations on web, complex needs... want have width of form adjustable according device, nothing more :) any reference simple tutorial explains how basic adjustments mobile ? you use css3 media queries build responsive layout. for instance: @media (max-width: 767px) { .yourformclass { /* rules */ } } @media (min-width: 768px) , (max-width: 979px) { .yourformclass { /* rules */ } } /* other resolutions... */ i suggest read these articles: how use css3 media queries create mobile version of website ; css media queries mozilla dev .

c# - attach standard database with connection string -

i use sql server r2 2008 standard , c#. use connection string: <add name="conn" connectionstring="metadata=res://*/dbl.model.csdl|res://*/dbl.model.ssdl|res://*/dbl.model.msl;provider=system.data.sqlclient;provider connection string=&quot;data source=.;initial catalog=dbfactor1;integrated security=true;multipleactiveresultsets=true&quot;" providername="system.data.entityclient" /> but want attach database file in connection string , use connection string: <add name="conn" connectionstring="metadata=res://*/dbl.model.csdl|res://*/dbl.model.ssdl|res://*/dbl.model.msl;provider=system.data.sqlclient;provider connection string=&quot;data source=.\sqlexpress;attachdbfilename=|datadirectory|\db\program1.mdf;initial catalog=program1;integrated security=true;user instance=true;multipleactiveresultsets=true&quot;" providername="system.data.entityclient" /> but connection string sql server express,