Posts

Showing posts from May, 2010

php - add records in two different tables -

i created table stores users details create table if not exists `users` ( `userid` int(11) not null auto_increment, `name` varchar(25) not null, `username` varchar(25) not null, `password` varchar(25) not null, primary key (`userid`), key `userid` (`userid`), key `userid_2` (`userid`) ) engine=innodb default charset=latin1 auto_increment=18 ; this 1 keep first name , last name 2 textboxes create table if not exists `data` ( `dataid` int(11) not null auto_increment, `firstname` varchar(25) not null, `lastname` varchar(25) not null, primary key (`surveyid`), key `firstname` (`firstname`), key `firstname_2` (`firstname`) ) engine=innodb default charset=latin1 auto_increment=2 ; and table has userid , dataid foreign keys. create table if not exists `jointable` ( `jointableid` int(11) not null auto_increment, `dataid` int(11) not null, `userid` int(11) not null, primary key (`jointableid`), key `surveyid` (`dataid`,`userid`), key `userid` (`userid`)

jquery - Hiding and showing list under ul tags -

how use jquery hide/show (toggle) elements class secondlevel upon clicking on toplevel link? <ul> <li><a class="toplevel" href="#">hardware</a> <ul> <li><a class="secondlevel" href="#">bottling</a></li> <li><a class="secondlevel" href="#">brewing</a></li> <li><a class="secondlevel" href="#">cleaning</a></li> <li><a class="secondlevel" href="#">fermenting</a></li> <li><a class="secondlevel" href="#">kegging</a></li> <li><a class="secondlevel" href="#">measuring</a></li> <li><a class="secondlevel" href="#">testing</a></li> </ul> </li> like this? jsfiddle $('li ul').

winforms - Combobox "Select All" in linq query -

i have multiple comboboxes pass value linq query. handling if(combobox.text == "select all") {combobox.text = "") and using startswith(combobox.text) method comparison, know wrong. since "jim" return "jimmy". how select when "select all" selected? the best conditionally add query filter: var query = datasource.foo.asqueryable(); //you may or may not need asqueryable() depending on "foo" //if not queryable, may need asenumerable(), or nothing if (!combobox.text.equals("select all")) query = query.where(x => x.equals(combobox.text)); return query.tolist(); the "simpler" way use boolean or , resulting query uglier , may or may not translatable sql (if using): var query = datasource.foo .where(x => combobox.text.equals("select all") || x.equals(combobox.text));

sharepoint designer - Consume WCF Service in Office365 from window Azure -

i have wcf service hosted in window azure virtual machine , trying consume in office 365 sharepoint developer site create external content type. when create external content type sharepoint designer 2013, following error coming "unknown error occured. unable load 1 or more of requested types. retrieve loadexceptions property more information". when try consume same wcf service on over premise sharepoint 2013 site, working fine. coniguration require on office 365? i ran exact same problem, , got workaround can use. here's answer, , hope find helpful. solution error creating wcf data source bcs external content types in sharepoint online

delphi - TChromium LoadString - Not allowed to load local resource -

if trying load page loadstring recource load in it, example: < style> body { background-image:url(local://c/background.gif); background-repeat:no-repeat; background-size: 100% 100%; } < /style> it not loading recource, gives not allowed load local resource error in console. question: need do, fix problem or maybe workaround it? tnx

c - Why does i=2+2*i++ give the wrong result? -

this question has answer here: why these constructs (using ++) undefined behavior? 12 answers i felt such expression should invalid able compile , got answer 5. @ end felt if answer should 4 not 5. int main(void) { int i=1; // how next line evaluated ie in sequence?? i=2+2*i++; printf("%d",i); return 0; } the output got 5. can not understand how should give value. this undefined behaviour, since i modified more once between sequence points. instance, this compiler gives 4 answer, because puts increment after assignment. reasonable answer 6, if increment before assignment. but, you've found, compiler permitted make answer whatever wants, including 5. see here more sequence points , undefined behaviour.

Error: Your PHP installation appears to be missing the MySQL extension which is required by WordPress -

i changed configurations on web server , moved mysql databases remote server. upon making changes, removed mysql web server make minimal possible. wordpress site working perfect remote sql until removed on local server. got error: your php installation appears missing mysql extension required wordpress i'm curious why wordpress forces have installed while using remote connection? there way around this? worst case scenario guess i'll reinstall mysql. its not mysql issue need enable mysql extensions required wordpress in php.ini file or install them if don't exist. when removed mysql removed or diabled extensions in php, atleast sounds like. should able install or enable extensions in without reinstalling of mysql

c# - Is it possible to have multiple MVC routes point to the same controller/view? -

(disclaimer: new mvc) i trying setup website product listing categories lets user request pages both productfolder/productname , productfolder/category/productname. possible? the closest have gotten far adding following routeconfig.cs registerroutes method, , placed productnameone.cshtml in views\products solution folder. results in being able see '.../products/index' , '.../products/productnameone' pages '.../products/categoryone/productnameone' returns 404 routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.maproute(name: "products", url: "products/{action}/{id}", defaults: new { controller = "products", action = "index", id = urlparameter.optional }); routes.maproute(name: "categoryoneproducts", url: "products/categoryone/{action}/{id}", defaults: new { controller = "products", action = "productnameone", id =

explicitly set a field's width in css to "no-auto" -

in css field, 1 can set field like .foo {width:auto;} is there non-auto can use value should not auto? (the system working on has bunch of css files, possibly overwriting 1 another, because of localisation, fix quick bug, want to unset auto attribute.). auto default value , means width calculated browser. if don't want calculated automatically, alternative have set specific value in relative or absolute units ( px , em , etc. or % ). can use value inherit take width parent, in case element must have width. the concept of 'no-auto' means set value explicitly. there no other possible values (except experimental keywords, modify how auto width calculated).

websphere - Can Liberty apps be deployed to WAS 8.0 also -

i'm interested in developing locally on liberty profile 8.5.5 , dev tools eclipse. however, company uses 8.0.0.6. can java ee artifacts developed liberty deployed 8.0.0.6 without xml changes or otherwise? i guess both java ee 6 servers... yes, intent allow development on liberty profile , deployment on full profile. there might system configuration differences, particularly around class loading, should able leave application unchanged.

Error with GlassFish 4 and Eclipse Juno JavaEE -

i downloaded eclipse juno while ago until used java se perspective only. today downloaded glassfish 4 windows , installed it. during installation got screen showed installation process didn't find java jdk allowed browse it. found c:\program files\java\jdk1.7.0_17 directory , selected it. finished installation , able start , stop domain , see both application , admin pages. i wanted install glassfish plug-in eclipse . found through marketplace , downloaded , installed it. i switched eclipse's perspective javaee , tried pick glassfish server. such option indeed there. however, got screen titled new glassfish 4.0 runtime following error: glassfish server runtime requires full jdk instead of jre the enabled buttons back , cancel . i googled around didn't find useful such case. can guess have happened , suggest troubleshooting steps? on screen define glassfish runtime, there link labeled "installed jre preferences". if click o

ruby on rails - How can I prevent SQL injections during CSV uploads? -

i've started learning rails security, , i'm wondering how can avoid security issues while allowing users upload csv files our database. we're using postgres' "copy stdin" functionality upload data csv temp table, used upserts table. basic code (thanks this post ): conn = activerecord::base.connection_pool.checkout raw = conn.raw_connection raw.exec("copy temp_table (col1, col2) stdin delimiter '|'") # read column values csv line line in following format: # attributes = {column_1: 'column 1 data', column_2: 'column 2 data'} # line = "#{attributes.values.join('|')}\n" rc.put_copy_data line # wrap copy process & insert & update primary table i wondering can or should sanitize column values. we're using rails 3.2 , postgres 9.2. no action required; copy never interprets values sql syntax. malformed csv produce error due bad quoting / incorrect column count. if you're sending ow

hex - convert a hexadecimal into a decimal via string convert in java -

i want convert string hexadecimal decimal value used integer.decode value hast written user. package hexa; import java.util.scanner; public class hexa { public static void main(string[] args) { scanner in = new scanner(system.in); string str1; system.out.print("ingrese el hexadecimal= "); str1 = in.nextline(); system.out.println("from hex: " + integer.decode("#str1")); } } use overloaded integer.parseint method takes second parameter radix: integer.parseint(str1, 16);

browser - Prefix for CSS3 isn't required? -

i busy website using latest chrome. for no reason, started searching through code using inspect element . i scrolled down, after saw rare happening. -moz- -o- -ms- -webkit- crossed, except box-shadow itself. same happening every single css3 element, such gradient, text-shadow, transition, box-shadow. i wondering if it's chrome. put parts of code there prefix, between /* , */ . started named below browsers, using 127.0.0.1 , , gives me result wanted, without prefixes. google chrome 28.0.1500.95 -webkit- internet explorer 10.0.9200 -ms- mozilla firefox 23.0 -moz- opera 15.0.1147.153 -o- why kept telling me, need it? when browsers support it? (i mean that, these 4 prefixes catch browsers). according caniuse.com (first google result) vendor prefix support few outdated versions of mozilla , webkit-based browsers. link: http://caniuse.com/css-boxshadow

cmd - need explanation of a batch code -

can me explain below batch code doing? rem client: crm_ci_m8626aabbqnbam200030.1.5 set name=%client% /f "tokens=1 delims=_" %%a in ("%name%" ) ( set name=%%a ) if crm_ci_m8626aabbqnbam200030.1.5 in %client%, code assigns crm %name%.

How do I link Tumblr to /domain? -

i have 2 tumblr blogs. have linked 1 domain name e.g example.com. have tumblr account , link same domain name /shirts. e,g example.com/shirts. i use godaddy.com do know how this? you need create subdomain 'shirts.example.com', you've given dns control of domain on tumblr i'm sure had change name servers. may still able create subdomain in control panel though. an end-user wouldn't expect "directory" lead different site anyway. edit: redirect 'example.com/shirts' tumblr support : click “add page.” type page url after slash (/). example, if you’re redirecting twitter, type /mytwitter. if you’re redirecting facebook, use /myfacebook. change page type standard layout redirect. type or paste web address page redirect to. check box says “show link page” , give page title in field next checkbox (e.g. twitter or facebook). click “create page.”

session - PHP $_SESSION Values Don't Persist Between Requests -

Image
i have files: set.php <?php session_start(); $_session['user_name'] = "anglinb"; var_dump($_session); ?> get.php <?php session_start(); var_dump($_session); ?> i have 1 server can go set.php , go get.php , both pages show same result of vardump. the second server, hosted namecheap, not store data. $_session superglobal working fine stopped working. what have tired i have check writablity of tmp domain suggested here stackoverflow.com . information still doesn't persist between requests. know browser settings , code ok because works on server. i have tried set path different directory permissions 777. ini_set(' session.save_path','/tmpp'); i can post phpinfo page if help. here 2 cookies: set: get:

ruby - Difficult code packaging design -

this long story, let me apologize in advance.... i've built tool write college curricula using static site generator nanoc . nanoc nice ruby based package , distributed gem. i installed gem, , used "nanoc new" command create basic directory structure. within directory structure wrote custom ruby code, large number of markdown files define first course. here's course built . the code showed above, in git, corresponds result of work, nanoc + customizations. there's bundler file has run bring in additional gems well. let's call individual course "cosi235a.course" , let's call tool "nanoc-course". call author of cosi235a.course "an author" , call maintainer of "nanoc-course" "me". what seeking nice design decouple nanoc-course cosi235a.course. in other words, want separate customized nanoc based tool content of 1 course. that way if want design curriculum second course can create , still pull i

Android social network app data storage -

i'm developing app in android(social network). need save following user data on client side after login: 1-firstname,lastname,education,sex,languages , other 20 strings. 2-i need 2 arraylists of 15 size, , every node contains 3 strings(title,descrition etc) 3-encoded image string. 4-some boolean settings. i'm using php backend server , json data transfer language. please guide me how store data????

clojure - Why does blocking cause a lock -

i using following code logging part of 1 handling of request. code has been seen many times everywhere. when make multiple parallel calls, deadlock because of code. (defn log [msg & vals] (let [line (apply format msg vals)] (locking system/out (println line)))) anyone knows going wrong here. thanks summary i'd conjecture deadlock due log 's interactions other code; in particular, expected when testing @ repl, reasons demonstrate below. (meaning straight clojure repl, opposed lein repl , other nrepl-based repls etc.) the key issue involved has synchronizing on system/out , illustrates broader point it not idea synchronize on objects provided jdk or clojure themselves, may interfere existing locking protocols involving objects (which in fact case clojure's *out* , system/out , we'll see shortly). point illustrates locks not compose . the answer begins offering solution , goes details of locking protocols involved in clojure printing, l

How to make this MongoDB aggregation return key:value? -

i have aggregation: $out = $db->stats->aggregate ( array('$match' => $where), ,array( '$group' => array( "_id" => '$traffic.source', 'count'=> array('$sum' => 1) ) ) ,array( '$project' => array( "_id" => 0, 'type' => '$_id', 'count' => '$count' ) ) ); which returns array with: [{type:sourcea, count:2},{type:sourceb, count:6}...] is possible make return: [sourcea:2, sourceb:6,....] without looping array afterwords?

dev c++ - Automatic variable in C not initialized but given fixed value within loop -

i read automatic variables in c, if not initialized values, contain garbage values. however, found did not correspond understanding. consider following piece of code. #include <stdio.h> main() { int = 0; (i = 0 ; i< 10; i++) { int x; int = 500; printf("%d\t%d\n", a, x); } } output: 500 2 500 2 500 2 500 2 500 2 500 2 500 2 500 2 500 2 500 2 my question - shouldn't expecting garbage values instead of 2s? ran program on dev-c++ on windows machine. uninitialized means declared not set definite known value before used. it have value, not predictable one.in case 2 . on other system may else.

How to echo a new line which has < -

i want echo line has following: <ca> -----begin certificate----- miidyzccazsgawibagijakrtpjsivek1ma0gcsqgsib3dqebbquamiggmqswcqyd i tried echo <^<ca>^> but didn't work. you have 3 main options: echo \<ca\> — escape special characters backslash echo '<ca>' — enclose string in single quotes echo "<ca>" — enclose string in double quotes if line stored in variable, third way (double quotes) works: line="<ca>" # written 3 ways echo "$line" # old-fashioned safe way (preserves spacing if there spaces) echo $line # new-fashioned unsafe way, imnsho the 'new-fashioned' way safe in angle brackets won't interpreted i/o redirections. it's unsafe in loses spacing. recommend using double quotes always; work * . $ line="< aa bb cc >" $ echo "$line" < aa bb cc > $ * double quotes unnecessary referring contexts [[

ajax - Kendo UI: Update transport doesn't trigger after calling datasource sync -

im struggling on in hours now, cant find documentation on how implement simple ajax update on server using forms , kendo mvvvm , datasource. kendo mvvm $(function() { var apiurl = "http://a31262cd2f034ab8bcda22968021f3b8.cloudapp.net/api", meetingdatasource = new kendo.data.datasource({ transport: { read: { url: apiurl + "/meetings/4", datatype: "jsonp" }, update: { type: "put", url: apiurl + "/meetings", contenttype: "application/json; charset=utf-8", datatype: 'json', }, parametermap: function(options, operation) { return kendo.stringify(options); } }, batch: true, change: function() { },

Is data sent to file streams (i/o streams) buffered in main memory & then sent to disk? -

just out of curiosity, file streams @ hardware level. read how these abstract streams solution keep i/o devices independent programs & programmers in legacy days.. can explain data flow, exactly? i don't think there file hardware left. modern storage provides block storage. else software interpretation., including file streams.

excel - Need the last row number which contain comment -

Image
i'm trying clear entire row of cells containing comment. want last active row number contains comment. i've used lastrow = worksheets("sheet1").cells(worksheets("sheet1").rows.count, "b").end(xlup).row but returning last row number contains value.if cell has comment no value it's not giving last row number. any alternative suggestion clearing cell comments entire column welcome. thanks in advance. my code clear value below. want clear comments well. sub columnclear() dim lastrow long dim long lastrow = worksheets("sheet1").cells(worksheets("sheet1").rows.count, "b").end(xlup).row = 3 lastrow worksheets("sheet1").cells(i, 2).value = empty next end sub try this: lastrow = worksheets("sheet1").comments(worksheets("sheet1").comments.count).parent.row this last comment in whole sheet hope ok.

kml - Center display over placemarks in selected folder -

i generate tree of folders admin1 , admin2, contain placemarks. when folder selected in earth, i'd move box/altitude placemarks in admin level visible. is there way kml? looks double clicking on folder in earth want.

winforms - how to accept value in date format in textbox in C# windows form? -

i have field in windows form asks user enter birth date... how validate form accept numbers , "/"( separator symbol ) , in dd/mm/yyyy format.. day should less 31, month should less 12 , year not greater 2012 textbox not control accept datetime input. there built in control datetimepicker should used instead. problem approach if masking of textbox 1 format dd/mm/yyyy user may want enter in mm/dd/yyyy . so, quite lot of error handling. whereas need not worry such thing in case of datetimepicker . even if want go textbox. this, datetime dt; if (datetime.tryparseexact(yourtexbox.text.trim(), "yourformattoaccept", cultureinfo.invariantculture, datetimestyles.none, out dt)) { //your code if parsing successful }

Android - App crashing due to memory error -

i have app not graphic intensive (as such). has 2 fragments, both 2 gridviews inside. call level-1 activities because visible when app opened. now second gridview located inside fragment #2 has 3 items, 1 of these items opens new activity gridview inside it. call level-2 activities must accessed user. this second level gridview has 8 image items. items identical size , shape, images used them not, scaled/resized etc. images are: image 1 - 465x232, 38kb image 2 - 512x251, 41kb image 3 - 900x379, 68kb image 4 - 630x258, 35kb image 5 - 700x346, 44kb image 6 - 615x409, 24kb image 7 - 800x383, 64kb image 8 - 400x169, 26kb gridview xml <gridview android:id="@+id/essentials_gridview" android:layout_width="fill_parent" android:layout_height="match_parent" android:gravity="center" android:horizontalspacing="10dp" android:verticalspacing="10dp" android:listselector="@andro

Autocomplete in JSP files with JSTL -

being switched sublime text notice lack of jsp/jstl support. while every filetype has autocomplete see isn't supported jsp files. example: when have: <c:foreach var="kitten" items="${kittens}"> <c:set var="name" value="${kitten.name}" /> </c:foreach> it great if autocomplete 'kitt...', 'nam...' , etc... catch drift? is not working because scope jsp files 'text.html.jsp'? , not source.jsp? can it? there way support this? maybe can make plugin (any examples?)? btw: have same problem snippets in jsp files: no autocomplete popup in jsp files snippets

asp.net mvc 3 - Signout function on button click event in MVC3 in entity framework -

i'm using mvc3 razor have button signout user, use following code shared/_layout.cshtml //button <div class="button"><a href="#" id="logout" title="logout"> <div class="logout"></div>logout</a></div> <script> $("#logout").bind("click", function () { window.location.href = '@url.action("logon", "account")'; }); </script> accountcontroller.cs public actionresult logout() { formsauthentication.signout(); return redirecttoaction("logon"); } this directs me error page http://localhost:xxxx/%3c%=%20url.action(%22logout%22,%20%22account%22)%20%%3e server error in '/' application. http error 400 - bad request. version information: asp.net development server 11.0.0.0 can tell me i'm going wrong? please button click event make sign

html - Is it possible to target a <select> with a specific option selected? -

Image
say have following html: <select> <option value="0">closed</option> <option value="1">open</option> </select> i'd add border <select> depends on selected value: red border when closed selected green border when open selected is there css selector target <select> when value 0 or 1 ? this not possible purely in css, css not have understanding of selected dropdown option s. (even if did, not possible match option go parent select ). as such, javascript option here. can provide example, didn't tag question javascript don't know if option you.

java - TCP socket and Web Socket on playframework server? -

my service uses websockets communicate html5 in-browser client. client served same server normal http request. now offer same service/app out of browser, , offer on tcp sockets. the rpcs/action object using going same, serialization going same, logic same. want use tcp socket instead of websocket. i keep code under same "project folder", starting @ once when deploy playframework server (basically on start want start listening websockets, tcp sockets , http requests), , have in same package on deploy. i know that: it not necessary, since websocket can used in not-in-browser apps, consider exercise or curiosity question. playframework built on top of netty, , used netty before tcp services (nothing big , nothing prod ready though ... not expert). should work right? what thinking do: have akka actor listen new socket connections. wrap connections (ws or tcp sockets) clientconnectionmanager instance pass actors takes care of connections/rpc logic. othe

Android - Integer[] returning a number instead of String value -

i have custom adapter , inside data source: public integer[] mlist = { r.string.a, r.string.b, r.string.c, r.string.c, r.string.d, r.string.e, r.string.f, r.string.g, }; when set textview text this: mtextview.settext(mlist[position]); the value whatever string represents. if this: mtextview.settext(mlist[position] + " text"); the value 10 digit number. shows this: 2126528311 text why , how can resolve it change line mtextview.settext( getresources().getstring(mlist[position]) + " text");

Merging graphs using boost graph -

how add edge between 2 different graphs using boost graph library . have seen code merging/contracting 2 vertices, not want that. i want link end vertex of 1 graph starting vertex of graph , make 1 single graph. both graphs of same type. please help... first of all, have admit resulting graph single object. assume want of same type graph original 2 graphs g1 , g2. means have choice 1 of following: graph g = g1 + g2 or g1 += g2 (both choices in pseudo-code, of course). in case, result contain copy of second graph, not "original" object of graph g2. bgl provides function that, namely, function " copy_graph " you can following #include <boost/graph/adjacency_list.hpp> #include <boost/graph/copy.hpp> typedef boost::adjacency_list<> graph; typedef graph::vertex_descriptor vertex_t; void merging(graph & g1, vertex_t v_in_g1, const graph & g2, vertex_t u_in_g2) { typedef boost::property_map<graph, boost::vertex_

BEM and asp.net mvc -

can faced integration of asp.net mvc , bem ( http://bem.info/ )? can introduce examples or links tutorials? i cannot provide code examples, since not use asp.net. in case theoretical answer can help, here is: first of all, can use css & file system parts of bem. mean can separate css code block components , store them in individual files. blocks/ button.css footer.css header.css login.css then, can gather files css files pages @import . flatten files, use borschik ( https://github.com/bem/borschik ). btw, might interested in released borschik sever https://github.com/bem/borschik-server , dev tool. then, if ready go further, can provide javascript files individual components , store such files css files of components. blocks/ button/ button.css button.js footer/ footer.css header/ header.css login/ login.css login.js similar css, can use these pieces of javascript per-page ja

php - Change the background image of a div depending on which link is selected in the navigation -

i'd change background image of div depending on wich link selected in navigation! exemple : let's have menu item called : #nav li.menu-item-59 when link selected changes #nav li.menu-item-59.selected i'd whenever 1 of menu item selected background image of div footer change different file... i've read articles sibling operators can't seem make work , i'm not sure best way go .. can help? ! :d it looks you're using js add class of selected menu. @ same time you're adding that, add the menu item name footer. like: var menuname = $(this).attr('id'); $('.footer').addclass(menuname); then in css footer, add class end of element: .footer.menu-item-59 { // background goes here } based on fiddle below, try: $(window).scroll(function(){ for(var = 0; < sections.length; i++) if($(window).scrolltop() +5 >= sections[i].top && $(window).scrolltop() <= sections[i].bottom){ sectio

ios - EXC_BAD_ACCESS with ARC. -

i not how debug error. know happening somewhere in uiscrollview when add new data array using function arraybyaddingobjectsfromarray , try populate data scrollview. so goes this: when scroll bottom of page calls function: -(void)scrollviewdidscroll: (uiscrollview*)scrollview { float scrollviewheight = scrollview.frame.size.height; float scrollcontentsizeheight = scrollview.contentsize.height; float scrolloffset = scrollview.contentoffset.y; if (scrolloffset == 0) { // @ top } else if (scrolloffset + scrollviewheight == scrollcontentsizeheight) { [_scrollviewoutlet scrollrecttovisible:cgrectinset([scrollview bounds], 10, 10) animated:no]; // @ end startingpoint += 36; nslog(@"reached bottom of feed"); if([lastpressedbutton isequaltostring:@"top"]){ [self todaystoppressed:self]; } if([lastpressedbutton isequaltostring:@"latest"]){

statistical moments in R -

i've got data set in r of variable, repeated 10,000 times , sampled 200 times on each repeat 10,000 200 matrix, calculate statistical moments variable arbitrary number. in end numeric vector holding value of moments. i can variance , mean data set using colmean , colvar, go far. i aware of moments package in r, using all.moments command returning me moments each time course, or treating each column or row individual variable, not want. does know equivalent colmean , colvar higher order moments? , if possible cross moments? many thanks! i stole code obscure r package e1071 : theskew<- function (x) { x<-as.vector(x) sum((x-mean(x))^3)/(length(x)*sd(x)^3) } thekurt <- function (x) { x<-as.vector(x) sum((x-mean(x))^4)/(length(x)*var(x)^2) - 3 } you can fold code feeding them 1 column @ time

wordpress - To get the category from the post list page -

i category name , got array array ( [0] => stdclass object ( [term_id] => 4 [name] => cinematography [slug] => cinematography [term_group] => 0 [avhec_term_order] => 1 [term_taxonomy_id] => 4 [taxonomy] => category [description] => [parent] => 0 [count] => 11 [object_id] => 2526 [cat_id] => 4 [category_count] => 11 [category_description] => [cat_name] => cinematography [category_nicename] => cinematography [category_parent] => 0 ) ) for wrote $category = get_the_category(); print_r($category); now how can store "[name] => cinematography" in variable. i assume $category array got there, then $cinematography = $category[0]->cinematography; https://drupal.org/node/1245956

xcode - How to create a Prototype cell in a Dynamic UITableView? -

Image
this question has answer here: what “couldn't compile connection:” error mean? 2 answers i made dynamic uitableviewcell uimageview , uilabel. i linked items code, build , gave me alarm: couldn't compile connection: <ibcocoatouchoutletconnection:0x7ff657212ee0 <ibproxyobject: 0x7ff6572e5e30> => nationlabel => <ibuilabel: 0x7ff6572e2bd0>> i've never worked dynamic cells it's stupid mistake of mine, can understand reason of it. how can solve it? thank you! sounds you're trying establish outlets prototype cell view controller. mentioned in comments, isn't going work because there potentially multiple cells , can't connected same outlet. so, first thing need delete these outlet connections storyboard. once you've done that, code should compile. there have 2 options (well, i'm sure there other ways

ruby - Mongoid: Referencing Same Model More Than Once Through has_many -

i'd able reference model (a has_many relationship) more once in same model. example, given following models: class mymodel include mongoid::document field :name, type: string has_many :main_efforts, :class_name => 'effort', as: :effortable, dependent: :delete, autosave: true has_many :secondary_efforts, :class_name => 'effort', as: :effortable, dependent: :delete, autosave: true validates_presence_of :name end class effort include mongoid::document field :name, type: string belongs_to :effortable, polymorphic: true validates_presence_of :name end as can see, effort model referenced twice. originally, effort model wasn't polymorphic, seemed mongoid unable determine collection (main_efforts or secondary_efforts) effort belonged to. such, made polymorphic. after making polymorphic, however, main_efforts , secondary_efforts fields empty array. what proper way reference polymorphic model more once in same model

sql - Creating a table with a sequence of values without inserting each one manually -

i (think i) want create view or temporary table contains sequence. purpose of table provide values needed make panel data set. create sequence programmatically, using every value between 2 periods 0 , 365, gaps of 7 (say make weekly panel). here how can done "manually", inserting each of cutoff days hand. create table time_periods (day_cutoff int); insert time_periods values (7); insert time_periods values (14); insert time_periods values (28); insert time_periods values (35); insert time_periods values (42); this table used (doing full cartesian join on underling table of billing_records contains ad hoc instances of when billing made. select buyer , seller , day_cutoff , sum(case when billing_day < day_cutoff amount else 0.0 end) cumulative_spend time_periods left join billing_records on 1 = 1 group buyer, seller, day_cutoff you can use generate_series : select * generate_series(7, 42, 7); it documented here . here 1 wa

iphone - implementation of tab bar programmatically not in the rootView -

Image
i asked same question before changed way implement tab bar have view i want when push button make tab bar composed in 5 buttons can choose in first view - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { self.window = [[[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]] autorelease]; // override point customization after application launch. acceuilviewcontroller *viewcontroller =[[[acceuilviewcontroller alloc] initwithnibname:@"acceuilviewcontroller" bundle:nil]autorelease]; self.navcontroller = [[[uinavigationcontroller alloc]initwithrootviewcontroller:viewcontroller] autorelease]; self.window.rootviewcontroller = self.navcontroller; [self.window makekeyandvisible]; return yes; } create uitabbarcontroller per normal. when user touches button, push controller: yourtabcontroller *tabcon

excel - Find value from one cell, copy value from cell near to that cell and paste it to another sheet -

i have 2 sheets different values. need find value 1 cell.sheet1 in sheet2 , copy value nextcell_in_the_same_row.sheet1 nextcell_in_the_same_row.sheet2. difficult explain let @ example bellow. e.g. before first sheet: b 1 aaa 123 2 bbb 456 3 ccc 789 4 ddd 122 second sheet: b 1 aaa 2 ada 3 cca 4 ccc after first sheet: b 1 aaa 123 2 bbb 456 3 ccc 789 4 ddd 122 second sheet: b 1 aaa *need find value in first sheet , copy value b2 because aaa in a1* 2 ada *value not exist in first sheet copy nothing* 3 cca *not need copy because no value in first sheet* 4 ccc *need copy value b3* thank much! use vlookup along iferror . =iferror(vlookup(a1, sheet1!a:b, 2, 0), "") this described (well described, way!) in question. drag formula down in sheet2 till bottom. vlookup takes value of a1 in sheet 2 (no sheet reference because value in same sheet formula) , looks in column of sheet1 . it returns second value (hence why 2 ) of table

r - How to avoid nested function definitions and still use <<- operator -

suppose have these 2 functions: finner<-function() { # complicated stuff, and... i<<-i+1 } fouter<-function() { i<-0 finner() print(i) } calling fouter() produces error: error in finner() : object 'i' not found . know, 1 way of fixing re-write example into fouter<-function() { finner<-function() { i<<-i+1 } i<-0 finner() print(i) } but if don't want nest functions way? in case finner heavy , complicated function (which might want move library), , fouter ad-hoc created function defines 1 iterator. have many fouter -class functions in code, nesting them require duplicating finner inside every single little 1 iterator definition. i suspect solution has environments, don't know how it. can help? you need access environment associated fouter function--where call finner is. can parent.frame , , can , set variables get , assign : finner<-function() { assign(&q

file io - Asynchronous running of Python functions -

i have function (based on parameters) move/rename image files mapped card reader drive in windows server drive after file renamed using template , appending incrementing number loop. there 3 cards of photos sent destination folder. each card being processed 1 after other because of file sizes , traveling on network can take quite time. is there way have function receive list of mapped card drives (not more 3) , run rename function simultaneously each card. my poor attempt illustrate trying follows: def collectcards(cards): card in cards: #my goal run each instance of following function asynchronously drv =renameimages(card) def renameimages(carddrive): #perform renaming functions return count_of_renamed_images you try using multiprocessing processes ( pool ) or threads ( pool.threadpool ). in both cases, difference in import - api stays same: from multiprocessing import pool my_pool = pool(3) # `cards` list of cards. send rename r

c - array indexing method a tricky case -

#include<stdio.h> int main() { int buff[] = {1,2,3,4,5,6,9,10}; char c = (buff+1)[5]; printf("%d\n",c);//output 9 return 0; } can explain how happening , why recall: in c square braces [ ] implicitly *( ... ) . what going on in snippet of code provided not obvious pointer arithmetic. line: char c = (buff+1)[5]; ... equivalent following (by c standard): char c = *( ( buff + 1 ) + 5 ); ... points 7th element in array (6th position) , dereferences it. should output 9, not 19. remark: following note square braces, it's important see following equivalent. arr[ n ] <=> n[ arr ] ... arr array , n numerical value. more complicated example: ' '[ "]; < 0; i++; while ( 1 ); awesome (y)." ]; ... of entirely valid pointer arithmetic.

asp.net mvc 4 - Understanding what a foreach loop is looking for in the AppDomain -

i digging though mvc example downloaded few months ago , ran across foreach loop uses appdomain.currentdomain . hoping explain foreach loop searching for. foreach (var assembly in appdomain.currentdomain .getassemblies() .where(a => a.getname().name.contains("spring"))) { var configtypes = assembly .gettypes() .where(t => t.basetype != null && t.isclass && !t.isabstract && t.basetype.isgenerictype && t.basetype.getgenerictypedefinition() == typeof(entitytypeconfiguration<>) && t.basetype.getgenericarguments().any(ta => _modelinterfacetype.isassignablefrom(ta))); foreach (var type in configtypes) { var entitytype = type.basetype.getgenericarguments().single(); var entityconfig = assembly.createinstance(ty

osx - in Terminal, what is the difference between normal mode and switching to bash? -

when in terminal, greeted prompt saying: computer_name:~ directory user$ (command input) then if use command "bash" , prompt changes to: bash-3.2$ (command input) now understand when use command "python" , taken python interpreter, seems pretty same commands usual work when switch bash. explain (if anything) happening here? when type bash taken new bash instance. if press ctrl + d exit. osx uses bash default shell.

ServiceStack: Impossible to use SOAP with custom namespace when AuthFeature is enabled? -

i have need host couple soap12 messages in current ss webapi. have set of namespaces according rules , works expected, extent. can use multiple tools send soap service(s) , work. have added them service reference in visual studio project work; @ least until add authfeature. add authfeature or other native ss service, can no longer add service reference. my investigation has lead me namespace difference between datacontract(s) in servicestack.serviceinterface.auth namespace used in authservice. don't want limited authservice though, same applicable when swaggerfeature added , resources service set up. it imperative these 2 messages available in soap , client must have ability add them service reference consume them. my question: there way set datacontract namespace(s) native ss services keep namespace consistent our datacontract namespace? understand "could" compile , maintain own version of ss have ability change contractnamespace attributes of causing issues ca

mysql - Is there a fast way to do a '%phrase%' search in any DB? -

i have large dataset 5m rows. 1 of fields in dataset 'article_title', i'd search in real-time autocomplete feature i'm building on site. i've been experimenting mysql , mongodb potential db solutions. both perform when index used, example 'something%', need match titles within string, in '%something%'. both mysql , mongodb took 0.01 seconds index using forward-looking search, , 6 seconds full string search. i realize entire db needs scanned string-in-string type search common approach problem? solr , sphinx seem overkill 1 problem i'm trying avoid using them if possible. if got box 2 gb of ram , 40gb ssd (which can afford @ moment), able sub-second response time? in advance. -- update: tried fulltext index , while results fast, doesn't satisfy string-in-string search ("presiden" doesn't match "president"). i'm looking ways match string-in-string 5m row dataset. in case of mysql, can creat

html - Button Vertical Text -

html <button class="btn" id="servicos">b</button> css .btn{ line-height: normal; display:inline; position:relative; border: 0; margin:0; width:6%; height:95%; font-family:"lucida sans unicode", "lucida grande", sans-serif; padding: 0; background-color: #000000; text-align:center; font-size: 18px; vertical-align:top; } my problem since button width , height in % text inside button in centered vertically, there way text on top? enclose "b" span <button class="btn" id="servicos"><span>b</span></button> <style> .btn{ line-height: normal; color:white; display:inline; position:relative; border: 0; margin:0; width:6%; height:95%; font-family:"lucida sans unicode", "lucida grande", sans-serif; padding: 0; background-color: #000000; text-align:center; font-size: 18px; vertical-align:top; } .btn span{ position:absolute; top:0px; border:1px sol

batch file - Controlling Multiple command prompt through one main window -

does knows how control many command prompt windows through 1 . start many command windows , run multiple commands in of them through batch file. such starting adb shell logcat in one, kmsg in 1 , if kmsg stops turn red, , similar things. need able listen events other command lines , send commands many command prompt 1 after other. reply appreciated. if know how in perl work. plzz help!! updated; update notes: took note of jeb's suggestion , took advice endoro's okay, little complicated because needs batch files write sort of file , batch file getting / grabbing data said file. in order this, must produce "sender / terminal / main window" batch file; the script writing of can support 4 batch files being controlled mother batch file. @echo off :a title main terminal echo --------------------------- set /p prompt1="command 1: " set /p prompt2="command 1: " set /p prompt3="command 1: " set /p prompt4="comma

c# - Switch Case Causing Trouble In Going To A particular Function -

funwithscheduling fun = new funwithscheduling(); console.writeline("this scheduler"); console.writeline("what wish do"); console.writeline("enter 1 add, 2 edit, 3 search , 4 exit"); int choice = convert.toint32(console.readline()); switch (choice) { case 1: goto fun.add(); break; case 2: goto fun.edit(); break; case 3: goto fun.search(); break; case 4: goto fun.exit(); break; default: console.writeline("enter valid number"); return; } } i got 4 functions me following add edit search exit i want use switch case go function. possible? asked object reference , label. why don't call method without goto ? , me it's not proper way use go

android - Using an AsyncTask to download images into a ListView in an AppWidget -

i trying adapt pattern google i/o using asynctask download images network , place them listview items within appwidget. haven't found many resources on doing such thing, except this post . the problem is, poster didn't have collection view, single item. when try follow pattern, whole appwidget updated single list item every time onpostexecute() runs, not need. if remove call updateappwidget() in onpostexecute(), views not updated, i'm guessing because of inter-process communication must occur. i'm not sure go here, can help? here definition asynctask: public thumbnailasynctask(remoteviews rv, int appwidgetid, appwidgetmanager appwidgetmanager) { mtarget = rv; this.widgetid = appwidgetid; this.widgetmanager = appwidgetmanager; } @override protected bitmap doinbackground(string... params) { string url = params[0]; return getbitmapfromurl(url); } @override protected void onpostexecute(bitmap result) { mtarget.setimageviewbitmap(r.id.t

youtube api - Specifying format parameter in PHP youTubeAPI -

i using google-api-php-client search youtube. want specify format=5 filter embedable videos. $client = new google_client(); $client->setdeveloperkey($developer_key); $youtube = new google_youtubeservice($client); $searchresponse = $youtube->search->listsearch('id,snippet', array( 'q' => $searchstr, 'maxresults' => $maxresultsnum, )); foreach ($searchresponse['items'] $searchresult) { } how specify format=5 can played in iphone. documentation has no reference on how this. filter looking videosyndicated your call like $searchresponse = $youtube->search->listsearch('id,snippet', array( 'q' => $searchstr, 'maxresults' => $maxresultsnum, 'videosyndicated' => true, 'type' =>true ));