Posts

Showing posts from March, 2014

c++ - CRC16 calculation in c#? -

i have c code used calculate crc16 , can 1 convert c#? static const unsigned short crc16tab[256]= { 0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7, 0x8108,0x9129,0xa14a,0xb16b,0xc18c,0xd1ad,0xe1ce,0xf1ef, 0x1231,0x0210,0x3273,0x2252,0x52b5,0x4294,0x72f7,0x62d6, 0x9339,0x8318,0xb37b,0xa35a,0xd3bd,0xc39c,0xf3ff,0xe3de, 0x2462,0x3443,0x0420,0x1401,0x64e6,0x74c7,0x44a4,0x5485, 0xa56a,0xb54b,0x8528,0x9509,0xe5ee,0xf5cf,0xc5ac,0xd58d, 0x3653,0x2672,0x1611,0x0630,0x76d7,0x66f6,0x5695,0x46b4, 0xb75b,0xa77a,0x9719,0x8738,0xf7df,0xe7fe,0xd79d,0xc7bc, 0x48c4,0x58e5,0x6886,0x78a7,0x0840,0x1861,0x2802,0x3823, 0xc9cc,0xd9ed,0xe98e,0xf9af,0x8948,0x9969,0xa90a,0xb92b, 0x5af5,0x4ad4,0x7ab7,0x6a96,0x1a71,0x0a50,0x3a33,0x2a12, 0xdbfd,0xcbdc,0xfbbf,0xeb9e,0x9b79,0x8b58,0xbb3b,0xab1a, 0x6ca6,0x7c87,0x4ce4,0x5cc5,0x2c22,0x3c03,0x0c60,0x1c41, 0xedae,0xfd8f,0xcdec,0xddcd,0xad2a,0xbd0b,0x8d68,0x9d49, 0x7e97,0x6eb6,0x5ed5,0x4ef4,0x3e13,0x2e32,0x1e51,0x0e70, 0xff9f,0xefbe,0xdfdd,0xcffc,0xbf1b,0xa...

ios - Correctly releasing returned UIImage -

i call following method image display in uiimageview. when done uiimageview release myimageview.image. happy how instruments showing leak of uiimage. how should releasing below instance of uiimage? -(uiimage *)getimagewithref:(nsstring *)ref { uiimage *myimage = [[uiimage alloc] initwithcontentsoffile:[nsstring stringwithformat:@"foobar_%@",ref]]; if (myimage == nil) { myimage = [[uiimage alloc] initwithcontentsoffile:@"foobar_defaultimage"]; } return myimage; } thanks in advance try using auto-release when return image. -(uiimage *)getimagewithref:(nsstring *)ref { uiimage *myimage = [[uiimage alloc] initwithcontentsoffile:[nsstring stringwithformat:@"foobar_%@",ref]]; if (myimage == nil) { myimage = [[uiimage alloc] initwithcontentsoffile:@"foobar_defaultimage"]; } return [myimage autorelease]; }

Java check if file is empty: IOException: null -

i'm trying load file arraylist, program creates file if doesn't exist. i'm getting ioexception: null @ beginning file empty. how can avoid error , check if file empty or not? here's code: file f = new file(filename); try { if( !f.exists() ){ f.createnewfile(); } inputstream = new objectinputstream(new fileinputstream(f)); scores = (arraylist<score>) inputstream.readobject(); } catch (ioexception e) { system.out.println("io error: " + e.getmessage()); } { ... } use file.length() obtain size number of bytes of file: the length, in bytes, of file denoted abstract pathname, or 0l if file not exist. operating systems may return 0l pathnames denoting system-dependent entities such devices or pipes.

c# - Select property of an object that is in a list of objects which is also in another list of objects -

i have next arhitecture: public class element { public uint id { get; set; } public icollection<elementdetails> elementdetails { get; set; } } public class elementdetails { public string elementtitle { get; set; } public string content { get; set; } } and there's list<element> somelist contains hundreds of elements. i'm trying obtain list of elementtitle (strings) contains text (i've called "seed"). want accomplish it's typeahead. here attempt: list<element> suggestedelements = somelist.where(s => s.elementdetails.any(ss => ss.elementtitle.contains(seed))).tolist(); list<string> suggestions = suggestedelements .selectmany(t => t.elementdetails.select(x => x.elementtitle)).tolist() }); // contains elementtitle, including elementtitle don't contain "seed"... how can rid of elements don't contain seed? list<string> suggestions = somelist.selectmany(x => x.elementd...

java - Is there a way to update Key to include ancestor -

i have update entities include ancestor in google app engine need migrate existing data have ancestor. is there way update key include ancestor? creating new key same id , kind , ancestor includes creates new record in datastore instead of updating existing one. i aware resave entities in new format , delete old ones, there other way? no, keys immutable, can not update key of existing entity. need create new entity, copy key/properties, save , delete old one.

internet explorer 8 - How to clear browser cache automatically in Selenium WebDriver? -

how clear browser cache before every test run? tried driver.manage().deleteallcookies(); in setup method after creating driver instance, working firefox, ie no use. there solution ie please provide me.. there driver capability can set follows: desiredcapabilities capabilities = desiredcapabilities.internetexplorer(); capabilities.setcapability(internetexplorerdriver.ie_ensure_clean_session, true); it worked me on ie11. source: http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/ie/internetexplorerdriver.html

hadoop - Creating Hive Metastore Database Tables Error -

i'm running through cloudera manager (free edition) , reached point wizard creating hive metastore database. error shown , halts configuration process. using /var/run/cloudera-scm-agent/process/40-hive-metastore-create-tables/hadoop-conf hadoop_conf_dir i cant seem find information might cause this? every thing has been configured correctly point, installed , user names , passwords correct. has seen error before? thoughts? error log: at sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:27) @ java.lang.reflect.constructor.newinstance(constructor.java:513) @ com.mysql.jdbc.util.handlenewinstance(util.java:411) @ com.mysql.jdbc.sqlerror.createcommunicationsexception(sqlerror.java:1116) @ com.mysql.jdbc.mysqlio.readpacket(mysqlio.java:688) @ com.mysql.jdbc.mysqlio.dohandshake(mysqlio.java:1094) @ com.mysql.jdbc.connectionimpl.coreconnect(connectionimpl.java:2337) @ com.mysql.jdbc.connectionimpl.connectonetryonly(connectioni...

Type mismatch error in Scala -

i blocked since yesterday type mismatch error , don't see how correct it. maybe can me it. def combine( head : (char,int), xs : occurrences) : list[occurrences] = xs.map { case (x,i) => ( occu <- 1 head._2 ) yield list((x,i), (head._1, occu)) } here error : type mismatch; found : list[scala.collection.immutable.indexedseq[list[(char, int)]]] required: list[forcomp.anagrams.occurrences] the type occurrences defined type occurrences = list[(char, int)] how can fix error? you solve problem using flatmap concatenate (flatten) lists you. def combine( head : (char,int), xs : occurrences) : list[occurrences] = xs.flatmap { case (x,i) => (1 head._2).map(occu =>list((x,i), (head._1, occu))) } now each occurance it'll produce list has (x,i) tuple , (head._1, occu) tuple , of lists ++ 'd flatmap. note i'm blindly converting code since know homework won't attempt analyze if algorithm correct.

layout - Android - Custom GridView with separated XML -

my goal display chessboard. have activity displays menu , load instance of "chessview" extends gridview. i've created custom gridview because want have class dedicated display. class have own layout.xml etc ... gameactivity.java : protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_game); //init game cchess.getinstance().init(); //creating chessboard chessview lchessview = (chessview) findviewbyid(r.id.chessview); } activity_game.xml : <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/background" tools:context=".gameactivity" > <project.chess.view.chessview android:l...

c# - DateTime format with milliseconds for DevExpress control EditMask property -

i need display date , time using devexpress dateedit control. can achieved setting mask dateedit control. so, have taken datetime pattern current thread ui culture , set devexpress dateedit controls editmask property. the problem here is, need show milliseconds user. existing cultures not have milliseconds in datetime pattern. so, need add milliseconds field("fff") datetime pattern of selected culture , set dateedit controls editmask property. my current code block shown below, var dateedit = new dateedit(); dateedit.properties.vistadisplaymode = devexpress.utils.defaultboolean.true; dateedit.properties.vistaedittime = devexpress.utils.defaultboolean.true; cultureinfo currentuiculture = thread.currentthread.currentuiculture; string editmask = currentuiculture.datetimeformat.generallongtimepattern; dateedit.properties.editmask = editmask; below datetime pattern of cultures , expected pattern, culture datetime pattern expected datetime pattern -----...

javascript - How can I close the browser window after redirecting to an MS office(word,excel, powerpoint) document automatically opened? -

in web application working on, have long-running processes in charge of getting office documents. open popup window.open takes care of polling server report process status , wait availability of document, , redirect generated document when ready (window.location = the_url_of_the_file). when redirection happens, depending on user configuration (see microsoft knowledge base), ms office document may opened/embedded directly in internet explorer, or may open file in new instance of office suit. in latter case, document opens in excel, window caused opening stays there forever. is there way force window close excel has loaded file ? i expect somehow related how integration between ie , windows works ... edit $.ajax({ async: false, type: 'post', datatype: 'json', url: '/controller/action/' + docid, data: $('form').serialize(), success: function (url) { window.open(...

c - Why is {typedef int* PTR;const PTR p=&num;} not equivalent to "const int* p=&num" but to "int *const p=&num"? -

this thing partly touched upon in question on so, casually not main question. confusion still persists, putting in separate question. why following 2 statements equivalent int* const p=&num , not const int* p=&num when latter seems more logical , intuitive? rigorous reasons behavior of typedef ? typedef int* ptr; const ptr p=&num; and finally, in question 1 member remarks bad practice use typedef ed pointers. have seen being used in many books , websites , seems convenient thing do. makes code more understandable. final word on it? should 1 avoid typedef ed pointers as possible? edit: , correct syntax typedef statement if intend following: const int* const p=&num; edit: inadvertently forgot ask important thing. correct syntax using typedef statement following then? const int* p=&num; //instead of int* const p=&num got generally, const type var = ini; declares const variable var of type type . so const ptr p=&...

python - CSRF Error when accessing django API code using POSt -

i using django rest api. here;s code: @api_view(['post']) def user_login(request): profile = request.post if ('user_name' not in profile or 'email_address' not in profile or 'oauth_secret' not in profile): return response( {'error': 'no data'}, status=status.http_400_bad_request) username = 'l' + profile['user_name'] email_address = profile['email_address'] oauth_secret = profile['oauth_secret'] password = oauth_secret firstname = none if 'first_name' in profile: firstname = profile['first_name'] lastname = none if 'last_name' in profile: lastname = profile['last_name'] bio = none if 'bio' in profile: bio = profile['bio'] oauth_token = none if 'oauth_token' in profile: oauth_token = profile['oauth_token'] investor = none if 'investor' in profile: investor = profile['investor...

sql server - dml query within WITH sql -

i supposing put set query within with statement in sql server 2008. so wrote few lines of code: with temp ( select row_number() on (order [shareitems].itemid) row, itemid [shareitems] ) set @row = itemid //<---error but getting error above, in case of select statement using with keyword, there no error??? with temp ( select row_number() on (order [shareitems].itemid) row, itemid [shareitems] ) select itemid temp //<--- ok (no error) any suggestion ? try way: with temp ( select row_number() on (order [shareitems].itemid) row, itemid [shareitems] ) select @row = itemid temp

Parsing a number in a string in C++ -

i'm trying parse number stored in char[] variable can run if statement against it. ive tried using atoi doesnt work, maybe im implementing wrong. i in c++ aswell here both codes snippets c char data[50]; do{ printf("enter data number between 1-50:\n"); scanf("%i", &ppacket->data); atoi(&ppacket->data); if(ppacket->data < 1 || ppacket->data > 50){ printf("incorrect input retry.\n"); } } while(ppacket->data < 1 || ppacket->data > 50); c++ char data[50]; do{ cout<<"enter port number between 1-1024"<<endl;; cin>> data; if(data < 1 || data > 50){ cout<<"incorrect input retry"<<endl;; } }while(data < 1 || data > 50); since want user enter integer, want use int variable hold enter: int port_number; do{ cout<<"enter port number between 1-1024"<<endl;; ...

latex - Reduce doxygen PDF index depth + remove extra indices -

is possible reduce depth of index created doxygen latex pdf? e.g. doxygen creates index in pdf 4 levels deep: file name - documentation type - documentation items. i'd reduce 1 level - file names , possibly rid of data structure index (chapter 2) , file index (chapter 3) couldnt see in header.tex etc. nearly sure saw similar q on here few weeks ago couldn't find it (note relevant pdf produced, im not using html output) as @albert commented controlled line \setcounter{tocdepth}{n} in header.tex file. where n number indicating number of levels required.

c# - The process cannot access the file XXX because it is being used by another process -

when run application, error on first "using" here: public void createfile(string filepath) { //create file string fileloc = filepath; filestream fs = null; if (!file.exists(fileloc)) { using (fs = file.create(fileloc)) { } } } public void writefile(string filepath) { //write file string fileloc = filepath; if (file.exists(fileloc)) { using (streamwriter sw = new streamwriter(fileloc)) { sw.write("some sample text file"); } } } a file directory opened , read from, streamreader closed after read. i'm not sure if has significance error. thanks. your check of file.exists before line error suggests strange going on, such trying use directory path filepath , or multithreaded race conditions.

ruby - How to reorder activerecord array based on array of ids -

i have existing activerecord array, gotten following: @posts = post.where(["created_at > ?", n_days.days.ago]) and order array based on value needs calculated in real-time multiple columns: posts_array = posts.map { |p| [p.id, f(t, p.x,p.y)] } this gives array [[1,20],[2,11],[3,14], ...] , sort based on function value give [[1,20],[3,14],[2,11],...] , , order_array want: [1,3,2,...] . what best way reorder original @posts array based on new order_array [1,3,2,...] ? don't want touch database again if possible, since information contained in @posts array. is there straightforward way this? if don't need posts_array array do @posts = post.where(["created_at > ?", n_days.days.ago]) @posts.sort_by! { |p| f(t, p.x, p.y) }

vb6 - VB user controls not resizing in windows 8 -

i'm updating vb6 application run in windows 8, , 1 of issues user control windows not resizing (via window edge drag handles). works fine under other oses. the same issue plagues main project window. the elements of window controlled in function, window doesn't respond resizing. private sub usercontrol_resize() if g_shuttingdown exit sub ' test 0 size if scalewidth = 0 or scaleheight = 0 exit sub ' min size 'if scalewidth < imin_form_width usercontrol.width = imin_form_width 'if scalewidth < imin_form_height usercontrol.height = imin_form_height ' form dimensions dim x, y, w, h long x = scaleleft y = scaletop w = scalewidth h = scaleheight pictitlebar.move 0, 0, w - 30, 240 imgtitlebar.move 0, 0, pictitlebar.width, 240 lblcaption.move 45, 15 imgclose.move pictitlebar.width - imgclose.width - 60, 60 chkverbose.move 15, pictitlebar.top + pictitlebar.height cmdclear.move chkverbose.left + chkverbose.width, chkverbose.top chkpause.move cmdcle...

php - wrong output in mysql_fetch_array -

here snippet of code : require_once('functions.php'); include('dbinfo.php'); connectdb(); $querys= "select 'score' solve (problem_id='".$_get['id']."' , username='".$_session['username']."')"; $resultscore=mysql_query($querys); $scorefetch=mysql_fetch_array($resultscore); $subractscore=$scorefetch['score']; echo $subractscore; ideally output should value stored in score field of database..but prints ' score ' .. wrong in this?also the query results 1 record @ time. the reason why query won't work expected because wrapping column name single quotes. ( column name , table name ) identifiers , not string literals shouldn't wrap single quote. select score solve where.... if happens column names and/or tables names used reserved keywords, can escape backticks not single quotes. in case, backticks aren...

objective c - Attempt to present modal VC on VC whose view is not in the window hierarchy -

Image
i have storyboard looks this: this how works: initialslidingviewcontroller instantiates navigation vc topviewcontroller follows in .m file: -(void)viewdidload { [super viewdidload]; self.topviewcontroller = [self.storyboard instantiateviewcontrollerwithidentifier:@"navigation"]; } after navigation vc gets instantiated, creates underlying menu , sets underleftvc. using ecslidingviewcontroller . creates sliding menu uses pan gesture, similar facebook. the rootvc navigationvc itemscdtvc. when click + button, pops action sheet allows me take photo camera or choose photo library. however, want modally segue manageitemvc , set picture chose/took uiimageview. when try present, throws following error: warning: attempt present <manageitemviewcontroller: 0x81d52a0> on <initialslidingviewcontroller: 0x8122ce0> view not in window hierarchy! which true, because initialslidingvc not on screen, itemcdtvc is, how fix this? i have set modal type segue ...

Python get last reading time of a file -

this question has answer here: get last access time of file? 2 answers i'm looking solution time file read @ last. file not modified or created opened in reading mode. works writing in file. if open file in read mode, time not correct: f = open('my_path/test.txt', 'r') f.close() print time.ctime(os.stat('my_path/test.txt').st_mtime) any hints? you looking @ wrong entry in stat structure. want use .st_atime value instead: print time.ctime(os.stat('my_path/test.txt').st_atime) from os.stat() documentation : st_atime - time of recent access, note not systems update atime timestamp, see criticism of atime . of 2.6.30, linux kernels default use relatime setting, atime values updated if on 24 hours old. can alter setting strictatime option in fstab . windows vista disabled updates atime , can re-...

php - Retrieve data from database in CakePHP -

i have database 2 tables: users , mails. in mailscontroller.php controller have function history() : public function history() { $mails = $this->mail->find('id'); $this->set('mails', $mails); $result = $this->mail->find('fromusername'); foreach($result $row){ $this->set('mails', $row); } } my goal print on page $mails sent username. in case this, not know code should put in history.ctp page. can please me bit? fromuserame in column save usernames in 'mails' table of database. in mailscontroller.php:history() sent variable $mails view (history.ctp). in view, can access $mails other php variable. since array, want use loop display data: foreach ($mails $mail) { echo $mail['mail']['fromusername']; // modify according data , required output. } to see $mails contains in script (for debugging purposes), can dump contents: var_dump($mails);

java - How to create hyperlink to other stage from the text area -

in javafx application there 1 text area in want create hyperlink after clicking on hyperlink new stage open @ run time(which contain 1 text area) , text coming main text area forwarded new text area of new stage.is achievable? suggestion? i having below code in application "actlogtarea" text area in want give hyperlink/button , want transfer text coming main text area new text area can suggest how can changed? new thread(new runnable() { protected logger logger = logger.getlogger(unixboxtask.class.getname()); public void run() { try { string user = username; string pass = pwd; string host = lanip; jsch jsch = new jsch(); session session = jsch.getsession(user, host, 22); //session.sethostkeyalias(sshhostkey); java.util.properties config = new java...

file - what is the equivalent of the instruction sed -i in solaris? -

i searching equivalent of line: sed -e /$line/d -i tels/telephonenumbers.txt it works fine in ubuntu, fedora, opensuse , cygwin, not work in solaris, find can use loop, trying avoid use of loop. suggestions? sed -e "/$line/d" tels/telephonenumbers.txt > tmp && mv tmp tels/telephonenumbers.txt

javascript - get id from html table when clicking an input inside the table -

Image
how can id of table when click input element? don't need rowid etc. i've tried parentnode.id can't seem id. in end i'd this. var tabelid = input....parentnode.parentnode.id; var table = document.getelementbyid(tabelid); example: how this:- demo html <table id="tbltest"> <tr> <td> <input type="text" id="txttest" onclick="getparent.call(this)" /> </td> </tr> </table> i using call here elements context inside getparent event callback. javascript function getparent() { var parent = this.parentnode; var tagname = "table"; while (parent) { //loop through until find desired parent tag name if (parent.tagname && parent .tagname.tolowercase() == tagname) { alert(parent .id); return; } else { parent = parent .parentnode; } } } if using jquery:- in click...

c# - Azure Cloud Service Losing Session if URL doesn't contain WWW -

my azure cloud service app has users logged in session data. if click on link internally doesn't have preceding www, session data not applied. if go , click on link have preceding www, session data works expected. know how resolve this? tia sounds session cookies not tuned wildcard of domain. can problem? check forms section of web.config if contains domain attribute , if doesn't, set it. <authentication mode="forms"> <forms loginurl="/account/logon" timeout="43200" domain="yourdomain.com"/> </authentication>

hibernate - JSON unmarshalling to POJO and inserting -

i unmarshal json string pojo class. reading existing url: https://builds.apache.org/job/accumulo-1.5/api/json i using apache camel unmarshal url @component public class routebuilder extends springroutebuilder { private logger logger = loggerfactory.getlogger(routebuilder.class); @override public void configure() throws exception { logger.info("configuring route"); //properties die hij niet vindt in de klasse negeren objectmapper objectmapper = new objectmapper(); objectmapper.configure(deserializationconfig.feature.fail_on_unknown_properties, false); dataformat reportformat = new jacksondataformat(objectmapper, healthreport.class); from("timer://foo?fixedrate=true&delay=0&period=2000&repeatcount=1") .routeid("accumolotojsonroute") .setheader(exchange.http_method, constant("get")) .to("https:/...

Passing Arguments from a paginated Drupal Views Page url -

i have page generated views lists 5 articles @ time. view paginated page 2 of view list second batch of 5 articles, page 3 list third batch of articles, on , forth. my question: somehow possible extract fields articles listed on page you're on, perhaps via url? , want them on articles being displayed page viewer on , not articles. my intent have views block ... determine page of paginated view above you're looking at determine articles listed on specific page aggregate , display taxonomy terms of listed articles (articles have taxonomy term field) in block do above automatically change page you're looking at the way i'm going list the taxonomy terms in block relatively straightforward. can't figure out how filter based on articles being displayed me in paginated page. i thinking maybe possible use using url of paginated page goes along format: ?page=1, ?page=2, etc. if point me right direction, appreciate it. i'm open alternatives. ...

Showing the audio player in Wordpress 3.5.1 -

i trying insert mediaelement player in page on wordpress 3.5.1. according documentation used [audio src="file.mp3"] shortcode, doesn't seem work. nothing showing black box "download now" link on it. if click on it, reloads same page without doing nothing. thank folks help! you need equals sign between 'src' attribute , argument. try this: [audio src="file.mp3"] and should find works.

ruby on rails - factory_girl: Factories fails validation(of time) on create, but in my app, the validation passes -

i have created application strict input validation time.. have type in time format: 14:00 . this works fine, when create factories factory-girl, tests, validation fails , can see factory-girl tries create them data: 2000-01-01 14:00:00 utc this factory: factory :stamp end_time "14:00" end so when run factorygirl.create(:stamp) fg tries set end_time to: 2000-01-01 14:00:00 utc , , validation fails. this validation method: validates :start_time, :end_time, :format => { :with => /[0-2][0-3]:[0-5][0-9]/, :message => "you have enter time in format 14:00" how can make factorygirl create models without tampering time-data , fail validation? you can try force factorygirl format end_time: factory :stamp end_time time.new(2013,1,1,14,0,0).strftime("%h:%m") end strftime("%h:%m") converts time format looking for

c# - REST post request with optional file upload -

while creating wcf rest service, receiving data in json , able save in database. need give option upload file(optional, image or video) same service. tried sending byte array giving bad request error possibly because of serialization of such long array. read upload large files need use stream. how while sending other parameters? creating service receive data mobile device. here service interface [webinvoke(uritemplate = "savefbpost", method = "post", bodystyle = webmessagebodystyle.wrapped, requestformat = webmessageformat.json, responseformat = webmessageformat.json)] [operationcontract] void savefacebookpost(fbpostdata fbpostdata); public class fbpostdata: [datamember] public string scheduledate { get; set; } [datamember] public string userid { get; set; } [datamember] public string groupid { get; set; } [datamember] public string posttext { get; set; } [datamember] public byte[] file { get; set; } [datamember] public string file...

store - adding multiple options in magento -

i'm making site t-shirt screen printer. offer 10 different styles of shirts, 8 colors per shirt, , 5 sizes. of prices vary depending on style , size. what need show main product screen print design, , must pick shirt options. how configure menu when select "shirt style x" gives them custom options , prices style. i want add these options each screen print design addon prices , options. you can use magento's configurable products accomplish this. http://www.magentocommerce.com/knowledge-base/entry/tutorial-creating-a-configurable-product/

Multithreading using VB.net Throws error -

am new vb.net multithreading. currect me if i'm doing wrong. what i'm trying : user's needs put serial no's textbox program needs pick model , warranty infomation vendor website when user hit search button. my windows form have 2 textbox's , 2 webbrowsers , 1 datagridview control. what i'm trying when user hit search buttom code needs below things thread1: pick serial no textbox1 , needs information web using webbrowser1 thread2:pick serial no textbox2 , needs information web using webbrowser2 my code looks dim thread1 system.threading.thread dim thread2 system.threading.thread private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click thread1 = new system.threading.thread(addressof thread11) thread1.start() thread2 = new system.threading.thread(addressof thread22) thread2.start() end sub private sub form1_load(byval sender system.object, byval e system.eventargs...

Mysql sorting by -

i'm working on how implement leaderboard. i'd able sort table several different filters(score,number of submissions, average). table might this. +--------+-----------------------+------+-----+---------+-------+ | field | type | null | key | default | | +--------+-----------------------+------+-----+---------+-------+ | userid | mediumint(8) unsigned | no | pri | 0 | | | score | int | yes | mul | null | | | numsub | int | yes | mul | null | | +--------+-----------------------+------+-----+---------+-------+ and sample set of data so: +--------+----------+--------+ | userid | score | numsub | +--------+----------+--------+ | 505610 | 1245 | 2 | | 544222 | 1458 | 2 | | 547278 | 245 | 1 | | 659241 | 12487 | 8 | | 681087 | 5487 | 3 | +--------+----------+--------+ my queries coming php. // top 100 scores $q = "select user...

r - Sampling package - strange behaviour of strata function -

in function strata declare numer of units drawn each stratum , after executing strange result. numer of units different declared. here example: library(sampling) data(swissmunicipalities) st=strata(swissmunicipalities,stratanames=c("reg"),size=c(30,20,45,15,20,11,44),method="srswor") result: > table(st$reg) 1 2 3 4 5 6 7 20 15 45 30 20 11 44 should be: 30,20,45,15,20,11,44 i grateful anwsers. if read page of strata function, have : size: vector of stratum sample sizes (in order in strata given in input data set). let's check order in numbers in reg variable require(sampling) data(swissmunicipalities) swiss <- swissmunicipalities unique(swiss$reg) ## [1] 4 1 3 2 5 6 7 as can see not naturally orderered, have 2 options. first options, write size in same order original data. size <- c(15, 30, 45, 20, 20, 11, 44) st <- strata(swiss, stratanames = "reg", size = size, method = "sr...

xaml - textblock not wrapping when set in code behind in background agent -

i'm making custom image in background agent on windows phone 8 display on of live tile. i've hit small problem, cannot text wrapping work. i first create canvas, holds textblock. i've tried putting stackpanel in between no luck. set textwrapping wrap, set (max)height & (max)width on elements no luck. i've tried setting trimming none. here's code: private void updateapptile(string message, int stuntcount) { system.threading.manualresetevent mre = new system.threading.manualresetevent(false); deployment.current.dispatcher.begininvoke(() => { var can = new canvas(); can.background = new solidcolorbrush(color.fromargb(255, 255, 204, 0)); can.width = 336; can.height = 336; can.maxheight = 336; can.maxwidth = 336; textblock textblock = new textblock(); textblock.fontsize = 26; ...

neo4j - Sorting a collection in Cypher and ordering results in the same order as the collection -

i'm new cypher , i'm trying following. have graph relationships have numeric property. want write query like: start n=node(*) match n-[r *1..3]->m return n,m, r order r.myproperty this doesn't work since r in case collection. this hard @ moment. i've been wanting implement functionality handle it--my idea here: https://github.com/neo4j/neo4j/issues/30 please comment on issue if you'd see happen.

Mac open grep file list -

i want search string in files , pipe resulting file list osx's "open" command, opening files contain said string editing in default editor (aka not vim). for example, running: find . -name "*.txt" | xargs grep -l "randomstring" might return: ./folder1/file1.txt ./folder1/file2.txt ./folder2/file3.txt ./file4.txt however, piping list open command fails: find . -name "*.txt" | xargs grep -l "randomstring" | open i think it's because of "newlines" or "carriage returns" because running: open ./folder1/file1.txt ./folder1/file2.txt ./folder2/file3.txt ./file4.txt works. i'm not sure how remove newline characters returned output , pipe open command. need command pipe output through format file list pipe list open command. although newline characters may not problem. p.s. - don't want create temp file this. open creating .zshrc or .bashrc function. find . -name "*.tx...

linux - How to disable/enable cpu cores *without* root access -

i have been trying disable or enable 1 or more cpu cores in linux machine using sudo sh -c "echo 'n' > /sys/devices/system/cpu/cpu1/online" just thinking if there way out there same no root access. thanks you can use setuid http://www.linuxnix.com/2011/12/suid-set-suid-linuxunix.html however, setuid disabled security reasons bash scripts, can write program, maybe in c, symply calls system("echo 'n' > /sys/devices/system/cpu/cpu1/online"); name executable stopcpu, following chmod a+x stopcpu sudo chown root stopcpu sudo chmod u+s stopcpu from moment, ./stopcpu run root permissions without having put root password, , valid file only.

java - Content coming from a web application sometimes randomly shuffled -

we develop java web application run on tomcat. it's been installed on many computers , it's working without problems. recently, on single remote installation, exhibits strange behavior: content coming through http browser randomly shuffled - wrong data being served given url. manifests images being randomly exchanged on web page. it's not limited images, happened me instead of html page browser got 1 of images instead. i tried debug problem using firebug + netexport , , far gathered: it appears randomly. of time content error-free, problem occurs time time. the same application runs on many installations, single installation produces error. it's not connected particular browser - tried different browsers different computers , problem persists. it occurs when viewed server (localhost) too, rules out broken transparent proxy on way. both images , html pages affected. if wrong content received, data consistent: content-length , content-type , etags , etc. - m...

.net 4.5 - "csc.exe" exited with code 1 in Visual Studio 2012 -

the visual studio 2012 professional edition installed on pc keeps on showing in error list "csc.exe" exited code 1 in visual studio 2012 instead of actual error (e.g. syntax error). how can fix this? i turned on detailed logging in tools -> options ... -> projects , solutions -> build , run. when rebuild solution, can see command gives error. copy command, open cmd window, go project folder, paste , run command. output give actual error. it's sort of bug in vs2012 suppose. try cleaning solution, restart visual studio , try rebuilding? above solution should point in right direction finding error. when opening file containing error, errors should appear in error list.

curl - R - devtools Github install fails -

trying use hadleys devtools package getting certification error: install_github("devtools") installing github repo(s) devtools/master hadley installing devtools.zip https://github.com/hadley/devtools/archive/master.zip error in function (type, msg, aserror = true) : peer certificate cannot authenticated given ca certificates google search tells me curl issue. no nearer. using "git" command line can pick want github, - don't error. appears when try connect github r. i using ubuntu 12.10, libcurl 7.22.0 , r 3.0 does have idea fix this? sincerely h. this issue resolved. there mismatch between version of rcurl , curl library. re-installing rcurl fixed problem.

python - How to merge PDFs with only PHP and keep internal and external links -

how merge pdfs php , keep internal , external links? simple question can't find solution. no access shell pdftk , on unacceptable. i'm looking pure php (gpl-like licencing policy) design , can't find week. iis , apache (linux) server sides python too, php preferred. please help! the python module, pypdf2 looks work you. http://knowah.github.io/pypdf2/

c++ - Compiler error when calling connect(2) with sockaddr_un -

i making simple call connect(2), in c++ program. code is: connect(socket_fd, (struct sockaddr *)&name, sun_len(name)); (here, name struct sockaddr_un ). when try compile this, following error g++: error: base operand of '->' has non-pointer type 'sockaddr_un' i totally baffled this, because i'm not using -> operator anywhere in program! there wrong way i'm taking address of name , or way casting it? the macro sun_len expects passed structure pointer, should use sun_len(&name) .

php - echo $_GET['id'] not displaying anything -

i have page in user chooses recipe has unique id, sent page information recipe displayed not displaying anything. $recipes = mysql_query(" select distinct `name`, `step1`, `step2`, `step3`, `image`, `reference` `recipe` r inner join `recipe_ingredients` ri on r.id = ri.recipe_id ri.ingredient_id in (".$ingredient1.",".$ingredient2.",".$ingredient3.") "); this query on main page, allows user choose set of ingredients , retrieve recipes them. echo '<form action="recipe.php?id=<?php echo $recipe_id;?>" method="post">'; echo '<input id="search" name="look" type="submit" value="look" >'; echo '</form>'; under each recipe there button user presses, send user specific recipe. $sql = mysql_query("select `name`, `image` `recipe` `id` = ".$_get['id']." l...

.net - Exempt control in AdornerLayer from ViewBox stretching -

i have wpf control layed out this: <viewbox stretch="uniform" name="viewboxname"> <itemscontrol> <itemscontrol.itemtemplate> <datatemplate> <!-- bunch of controls here want stretched in viewbox --> </datatemplate> </itemscontrol.itemtemplate> </itemscontrol> </viewbox> then, in adornerlayer, have (using technique based on http://shevaspace.blogspot.com/2007/02/visual-level-programming-vs-logical.html ) button control defined as <button> <image source="/acchimageload;component/icons/metrostudio/imagerotation.png" stretch="none" /> </button> how can button in adornerlayer use image's native resolution, instead of stretching viewbox? basically, idea transform viewbox , apply inverse, binding converter. the binding converter can inverse following code: ((containervisual)visualtreeh...

Can't open subdirectory with Opencart -

i have problem opening subdirectories. have opencart installed in root of server. have other subdirectories other things scripts , pages. when try open them, custom 404 opencart page. when direct url/subdirectory/index.php or so. this because of last rewrite rule in .htaccess file: rewriterule ^([^?]*) index.php?_route_=$1 [l,qsa] - redirecting url not containing question mark ( ? ) opencart router fails route url , falls 404 default page. for case work have add rewritecond , test path not contain name of subdirectory(ies). for example, run scripts in /<oc_root>/my_subdirectory/... , add condition: rewritecond %{request_uri} !(my_subdirectory)\/.* should your_subdir , his_subdir , add condition: rewritecond %{request_uri} !(my_subdirectory|your_subdir|his_subdir)\/.* make sure last rule goes after condition: rewritebase / rewriterule ^sitemap.xml$ index.php?route=feed/google_sitemap [l] rewriterule ^googlebase.xml$ index.php?route=feed/google_bas...

android - Using "getBaseContext" Or "this" when using Toast to display Messages -

i having button laid out in linear layout on activity . when clicked on it, message appear on screen using toast class two methods works fine me first 1 : private void displaytoast(string msg) { toast.maketext(getbasecontext(), msg, toast.length_short).show(); } and second 1 : private void displaytoast(string msg) { toast.maketext(this, msg, toast.length_short).show(); } my question deference between getbasecontext() , this ,and when should use getbasecontext() , when should use this ?? your activity context, use directly this . keep getbasecontext special cases activity not reachable directly.

javascript - Add new series to the top of a highcharts stacked column chart -

i'm trying control order in new (after first render) series added stacked column chart in highcharts. right now, if use addseries, newly added series added bottom of stack. here's simplified version of i'm doing var chart = new highcharts.chart({ chart: { type: 'column', renderto: 'container' }, xaxis: { categories: ['jan', 'feb', 'mar'] }, plotoptions: { series: { stacking: 'normal' } }, series: [{ name: 'base', data: [10, 20, 30] }, { name: 'sec', data: [30, 20, 10] }] }); var = 0; $('#add').on('click', function (e) { chart.addseries({ data: [32, 43, 42], name: ++i, index: 0 //?????? }); }); here's fiddle of this: http://jsfiddle.net/6bcbf/ any 1 can think of way reverse/control highcharts inserts new series? i've tried...

What is the backport of Rails 3 style finders (.where) to Rails 2? -

i know i've heard of library provides rails 3 style finders ( .where ) earlier versions of rails, web search failing me. i've got 2.3 project needs new feature, , i'd rather use newer style in case gets upgraded. would fake_arel gem help? fake_arel simulates , supports variety of features rails 3 earlier rails versions. major requirement currently-used activerecord gem needs greater or equal version 2.3.5. the documentation notes fake_arel can used bridge between rails 2 , rails 3 apps, ease future transitions later rails versions.

filter - jQuery Masonry - re-align tiles when removed -

i have script on page removes "tiles" using filter. is possible re-align when tiles removed? this doesn't seem doing it: $wrapper.masonry( 'reloaditems' ); i'm using following filter: $('.tags:not(.tags:contains('+filter_text+'))').parent().fadeout('slow'); cheers! use "remove" method of masonry removing elements instead of removing them using jquery yourself. so, instead of: $wrapper.find(<filter criteria>).remove(); do: $wrapper.masonry("remove", $wrapper.find(<filter criteria>));

javascript - Extend Zepto.js so don't need jQuery anymore -

i idea of cutting out 80% of jquery using zepto.js. however, when making switch, clear of jquery plugins i'm using, example jqueryui draggable(), can't find in zepto need. is there sane way go switching zepto? or going have extend function function until stop getting errors? hear me out. in perfect world have frameworks need. don't live in such world. different projects - different requirements. jquery designed cover of usual requirements, therefore saving time. may sound tempting try optimize project needs, in wrong run, worth building frameworks every small project? in end it's 15 kbs of difference, fraction of second. javascript not compiled don't save compilation-time or anything. little tiny bit of bandwidth. i'm not aware of importance of project, wouldn't sacrifice time build custom jquery distribution every new project i'm creating. if stripped down zepto doesn't work out, i'd stick jquery. if determined this, think easie...

html - XPath searching multiple nested elements -

i have following html document <div class="books"> <div class="book"> <div> there many deep nested elements here, somewhere there 1 span text e.g. 'mybooktext' within these <div> <div> <div> <span>mybooktext</span> </div> </div> </div> </div> <div> there many nested elements here, somewhere there link class called 'mylinkclass' within these. (this element want find) <div> <div> <a class="mylinkclass">bla</a> </div> </div> </div> </div> <div class="book"> <div> there many deep nested elements here, somewhere there 1 span text e.g. 'mybooktext' within these <div> <span>mybooktext</span> </div> <div> </div> <div> there many nested elements ...

php - Break from try/catch block -

is possible in php? try{ $obj = new clas(); if($obj->foo){ // how exit try block? } // other stuff here }catch(exception $e){ ] i know can put other stuff between {} , increases indenting on bigger code block , don't :p i know increases indentation an answer try { $obj = new clas(); if ($obj->foo) { // stuff here } else { // other stuff here } } catch (exception $e) { // handle exceptions here }