Posts

Showing posts from March, 2014

.net - Retrieving MYSQL Database structure information from Java -

i'm trying java , mysql same used .net , sql server: by using microsoft.sqlserver.management.smo can access database structure information instance ( server name, table structure, columns, datatype, description, default value) i tried find same java + mysql seems not popular any directions? thanks ed the simplest way accomplish retrying connection metadata, first open connection: connection conn = drivermanager.getconnection("jdbc:mysql://localhost:3306/db", "user","****"); databasemetadata metadata = conn.getmetadata(); then start navigating through metadata, can check available operations in databasemedata

php - MySQL query with DISTINCT keyword -

my mysql table country_phone_codes looks this id country_code area_code name ------------------------------------------------------------ 1 | 93 | 93 | afghanistan 2 | 93 | 9370 | afghanistan - mobile 3 | 93 | 9375 | afghanistan - mobile 4 | 355 | 355 | albania 5 | 355 | 35568 | albania - mobile - amc 6 | 213 | 213 | algeria 7 | 213 | 2131 | algeria - cat ------------------------------------------------------------ these few records of more 28000 records. trying formulate query provide me result this- country_code name ----------------------------- 93 | afghanistan 355 | albania 213 | algeria ----------------------------- by using select distinct(country_code) country_phone_codes order country_code limit 0,260 , able distinct country codes. how corresponding country name?

objective c - ARC restriction - Implicit conversion of 'char' to 'NSString *' is disallowed with ARC -

i'm playing mapkit , setting annotations. somewhere in code have :- #define annotation_first_type 1 unsigned char annotype = annotation_first_type annotationview = (mkpinannotationview *) [_mapview dequeuereusableannotationviewwithidentifier:annotype ]; the last line above throws error implicit conversion of 'char' 'nsstring *' disallowed arc , fair enough, need explicitly change annotype nsstring. but odd thing is; if line (3) had below instead :- annotationview = (mkpinannotationview *) [_mapview dequeuereusableannotationviewwithidentifier:**annotation_first_type**]; it compiles without error? question is, type of annotation_first_type? annotation_first_type integer. integer can implicitly converted pointer in c, if have enabled warnings compiler should have warned this. don't know why isn't compiler error, oversight. you should define annotation_first_type nsstring, e.g. #define annotation_first_type @"1"

linux - Show full list of php scripts on server -

how show full list of running php sripts on linux server? see httpd service, or pid not specific php file source, need analyze script take more memory , fixed it. thanks you have 2 options: log urls requested server , end in php scripts being executed can use php feature, allows add php script apache request sent php. enable adding root .htaccess: php_value auto_prepend_file append.php in append.php add logging feature, can insert url requested, time took generate response , max memory used. if add tab separated file, import in db table , see happening on server. more info here: http://www.electrictoolbox.com/php-automatically-append-prepend/ debug apache doing , using strace start apache strace. debug operations apache , subsequently php doing. watch out, there lot of noise in debug output. more info here: http://bobcares.com/blog/?p=103

get columns from multiple tables from multiples entities in Silverlight -

i create datagrid contains 5 columns. each column different table , each table different entity. how should in silverlight ? i'm able data 1 table , display in datagrid combining entities seems complicated. thank you. create single store procedure , take n number of columns n number of tables .

javascript - jQuery - Only Call The Hover Out Function if Cursor Isn't Entering Any Siblings -

i'm trying create effect similar navigation on site: http://rogwai.com/ . i'm close can in jsfiddle . it's working fine if hover 1 li @ time (i.e. bottom). if however, slide horizontally through each list item 'follower' returns active position or slides of end after each item that's hovered over. instead should follow mouse. looking @ code executed on hover out understandable. can't head around how make return active position or slide off end when mouse leaves menu. hopefully makes sense - should see problem straight away jsfiddle. thanks in advance. what can add mouseenter part li have it, put mouseleave part on entire ul . way, leave fire when mouse out of entire ul . http://jsfiddle.net/yzr5b/6/ $('nav.block-system-main-menu ul li:not(.follower)').mouseenter(function() { followermove($(this)); }); $('nav.block-system-main-menu ul').mouseleave(function(){ followermove($active); }); note, if using jq

bash - How to merge every two lines into one from the command line? -

i have text file following format. first line "key" , second line "value". key 4048:1736 string 3 key 0:1772 string 1 key 4192:1349 string 1 key 7329:2407 string 2 key 0:1774 string 1 i need value in same line of key. output should this... key 4048:1736 string 3 key 0:1772 string 1 key 4192:1349 string 1 key 7329:2407 string 2 key 0:1774 string 1 it better if use delimiter $ or , : key 4048:1736 string , 3 how merge 2 lines one? awk: awk 'nr%2{printf "%s ",$0;next;}1' yourfile note, there empty line @ end of output. sed: sed 'n;s/\n/ /' yourfile

c# - using web references -

so been few days learning web references within projects have came across strange problem. using simple console app did this: namespace webservices09004961 { class program { static void main(string[] args) { { convert.converttemperaturesoapclient client = new convert.converttemperaturesoapclient(); while (true) { console.write("enter temperature in celsius: "); double tempc = double.parse(console.readline()); double tempf = client.converttemp(tempc, convert.temperatureunit.degreecelsius, convert.temperatureunit.degreefahrenheit); console.writeline("that " + tempf + " degrees farenheit"); } } } } } i have added in service reference "convert" related link: http://www.webservicex.net/converttemperature.asmx?wsdl however

How to have test data on Visual Studio 11 when using WPF and data binding? -

i have tab control data template renders data based on template , data on source bound to. however, instantly makes ui development harder don't see in visual studio 11, because data comes when application running. there way add test data appears while working ui? this tutorial msdn perfect: http://msdn.microsoft.com/en-us/library/ee823176.aspx basically: create file designdata/foodata/foo.xaml content such as: <local:foo xmlns:local="clr-namespace:yourproject" someproperty="sample" anotherproperty="bar" /> note foo must class exists under namespace yourproject properties used. then select file solution explorer , set build action design data . add namespace mainwindow.xaml code: xmlns:d="http://schemas.microsoft.com/expression/blend/2008" along other namespaces have. then add top-level grid instance: d:datacontext="{d:designdata source=./designdata/foodata/foo.xaml}" now elements

asterisk - PHPAGI USING CakePHP SHELL -

i needed build asterisk based ivr application built using cakephp. i wanted use cakes' (fat) models, wouldn't have re-write business logic. i wanted create cakephp shell called asterisk dialplan. here's did. downloaded phpagi vendors/phpagi. modified phpagi.php from function agi($config=null, $optconfig=array()) to: function agi($config=null, $optconfig=array(), $stdin, $stdout) so can set stdin , stdout. around line 167 changed $this->in = defined('stdin') ? stdin : fopen('php://stdin', 'r'); $this->out = defined('stdout') ? stdout : fopen('php://stdout', 'w'); to $this->in = $stdin; $this->out = $stdout; in shell in vendors/shells added app::import('vendor', 'agi', array('phpagi/phpagi.php')); i added var $agi; //redirect output through agi conlog function err($message,$newlines = 1){ $this->agi->conlog($message);

java - Unused URI template variable - can I replace it with a wildcard? -

i have code along following lines in spring mvc webapp: @requestmapping("/{somevariable}/apath/apage.do") public void serveapage() { dostuff(); } we want "somevariable" in url, aren't interested in capturing , using value of it. there way of replacing wildcard, e.g. /*/apath/apage.do ? yes, @requestmapping accepts ant-style patterns http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/bind/annotation/requestmapping.html#params () so works: @requestmapping(value="/*/test2.do") public void getmeta5(httpservletrequest request, httpservletresponse response) throws ioexception { final printwriter writer = response.getwriter(); writer.print("requesturi:" + request.getrequesturi()); writer.flush(); } this assumes servlet-mapping in web.xml maps url path dispatcherservlet, e.g. <servlet> <servlet-name>spring</servlet-name> <servlet-class>org.spri

math - How can I calculate the factorial of a double in c++ -

i hoping there library function somewhere can this. , yes important factorial of double value (that needs work non-integer values). the c99 standard library contains gamma function, double tgamma(double) . closely related factorial, can define: #include <cmath> double factorial(double x) {return std::tgamma(x+1);} this should available in c++11 implementation, not guaranteed in c++03 implementation, might include c90 library. if implementation doesn't have it, boost.math library does.

Android Image Button Styling -

how style image button displays png icon on click/touch, png shape gets soft glowing edge? you want @ 9-patch basically create transparent png glow effect baked image, , it'll scale edges while keeping corners intact , letting place content within predefined area of image. to map images button, need selector, xml file , goes projects drawables. sample grabbed answer looks <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/red_button_pressed" /> <item android:state_focused="true" android:drawable="@drawable/red_button_focus" /> <item android:drawable="@drawable/red_button_rest" /> </selector>

c - How to tell GCC that a pointer argument is always double-word-aligned? -

in program have function simple vector addition c[0:15] = a[0:15] + b[0:15] . function prototype is: void vecadd(float * restrict a, float * restrict b, float * restrict c); on our 32-bit embedded architecture there load/store option of loading/storing double words, like: r16 = 0x4000 ; strd r0,[r16] ; stores r0 in [0x4000] , r1 in [0x4004] the gcc optimizer recognizes vector nature of loop , generates 2 branches of code - 1 case 3 arrays double word aligned (so uses double load/store instructions) , other case arrays word-aligned (where uses single load/store option). the problem address alignment check costly relative addition part , want eliminate hinting compiler a, b , c 8-aligned. there modifier add pointer declaration tell compiler? the arrays used calling function have aligned(8) attribute, not reflected in function code itself. possible add attribute function parameters? following piece of example code i've found on system, tried following solutio

c - How to use iconv for utf8 conversion? -

i want convert data in other encodings utf-8. i'm stranded following problems: executing attached code gives me: pointer being freed not allocated in iconv(). why iconv play memory? when don't free(dst) doesn't crash nothing printed. not gibberish. what's wrong? void utf8(char **dst, char **src, const char *enc) { iconv_t cd; size_t len_src, len_dst; len_src = strlen(*src); len_dst = len_src * 8; // enough ascii utf8? cd = iconv_open("utf-8", enc); *dst = (char *)calloc(len_dst+1, 1); iconv(cd, src, &len_src, dst, &len_dst); iconv_close(cd); } int main(int argc, char **argv) { char *src = "hello world"; char *dst; utf8(&dst, &src, "ascii"); printf("%s\n", dst); free(dst); return 0; } quote iconv() description @ posix.1-2008 size_t iconv(iconv_t cd, char **restrict inbuf, size_t *restrict inbytesleft, char **re

java - Adding a component to jpanel in netbeans -

i have been trying past few hours figure out how add label component window no prevail. have created new desktop application project in netbeans , comes pre-generated code. want add label not show?. unsure why because following normal panel.add(component) convention. would appreciate help!. pasted full file sourecode here http://pastebin.com/qjk6bswn . any ideas? what layout jpanel using? if it's using netbeans gui builder default of free design won't able manually add components. you'll need set layout manager. parts of gui can have free design layout, you'll need change layout of components want manually add to.

css - Passing Javascript from .js file to head of HTML file and have it read as HTML code -

i have javascript file finds out cycle of moon , picks 2 current moon images put on web page background images. got work fine images, design needs them appear in css format "background-image". when move code head (originally in body) of html file prints code text on page. the .js file says this: n="body {background-image: url('../moon/n"+moonday+".png') no-repeat right top;}" r="body {background-image: url('../moon/r"+moonday+".png') no-repeat right bottom;}" the html file says this: <script src="moon/mooncycle.js"></script> <script language="javascript" type="text/javascript">document.write(n)</script> <script language="javascript" type="text/javascript">document.write(r)</script> </head> how hmtl file read print out (which showing this... http://www.dragonfly-design.net/2012/index.html ) thank can give me!

ruby - How to tell when Rails app is activated by migration? -

i'm trying create migration app, , in app i'm using gem tries startup different service upon app startup. apparently, creating migration... rails generate migration addsomestufftotable stuff:string ...activates app, , gem tries connect startup service. appears starting app via generating migration makes service startup unable connect, keeps sleeping , trying again, never running migration. in gem, i've dealt rake, i've got far: myservice.start unless defined? rake or defined? irb this handles rake problem (like rake db:migrate, rake db:populate), how can handle creation of migration, (as far know) not rake task? you try using environment variables disabling service: myservice.start unless env['no_service'] and run command this: no_service=1 rails generate migration addsomestufftotable stuff:string however, doubt scales well, if multiple developers in app. better approach might reverse of this, start service if particular env variab

media player - Android: mediaplayer went away with unhandled events -

i need duration of audio file series of voice announcements need play app. have added audio files resources , play fine. sample code below works perfect intended purpose: return duration of audio files. here code: float getdurationofaudioresource(locationenum loc, context context){ float duration = 0; try { mediaplayer mp; mp = mediaplayer.create(context, getaudioresource(loc)); duration = mp.getduration(); mp.release(); mp = null; } catch (illegalstateexception e) {e.printstacktrace(); logerror(25, "testdescitem:fault::could not open mediaplayer object audio resource.");} return duration; } here's weird thing. code called in main activity prepares set of audio instructions given test. there no errors within activity. second activity called, long string of errors on logcat. 03-07 13:23:43.820: i/actionlogger(21435): gentest_info_test #0 created. 03-07 13:23:43.830: i/actionlogger(21435): gente

How to create basic posts/blog with nanoc and then have it in the feed? -

i started nanoc. wondering if can explain me how should create blog posts , how add them in feed? i know how create items, how create posts in blog folder? how show 5 recent posts? blog posts other items, , it’s decide how want them identified. people using “kind: article” while other people prefer stick them in content/blog/ directory. nanoc comes blogging helper. take @ #atom_feed method, can used generating atom feed. method takes :articles parameter containing list of articles (by default, take items “kind: article”). way, can create feed specific collection of items.

How can I serve an image from the blobstore to a python template in Google App Engine? -

{% result in results %} {{ result.photo }} {% endif %} this won't work, can't find info how upload photo. on admin console, can see have uploaded image blobstore, how can send webapp template? i can show description doing this. {% result in results %} {{ result.description }} {% endif %} but don't know how gae read image file image. any appreciated. everyone! i have written tutorial on topic. read , if have specific problems post here. http://verysimplescripts.blogspot.com/

php - Mongo fatal error -

i using php , mongo db... want user details using userkey unique key.. mongo query : $obj= $mongo->user; $filter = array( 'userkey'=>$value ); $exist = $obj->findone($filter); when execute query, getting error .. fatal error: maximum execution time of 30 seconds exceeded in line 5 ie $exist = $obj->findone($filter); shows error how solve problem can me plz... can mongo queries work, or 1 fails? connection database. believe "findone()" wait forever on stalled connection. recommend using "find()" instead, , giving low timeout, 100ms. may help. $cursor = $collection->find($query,$fields)->timeout(100); $record = $cursor->getnext(); obviously, want wrap in try/catch block capture timeout exception. sure use latest mongo drivers (1.2.10 or better), because earlier versions of php mongo drivers segfault on connection timeout.

How to find all occurrences of a variable in Vim? -

in vim, how find occurrences of variable in files under directory? i know vimgrep works sometimes, looks text , doesn't work if other classes have variables of same name , want variable under specific class. what should do? or should ide instead? why want use ide when have one? vim is ide configurable , usable different languages.. you use cscope build database of code. database allows searching code for: all references symbol global definitions functions called function functions calling function text string regular expression pattern a file files including file further features of cscope: curses based (text screen) an information database generated faster searches , later reference the fuzzy parser supports c, flexible enough useful c++ , java, , use generalized 'grep database' (use browse large text documents!) has command line mode inclusion in scripts or backend gui/frontend runs o

javascript - kinetic-v3.8.2.js breaks kinetic-v3.6.0.js and kinetic-image-plugin-v1.0.1.js, how to fix? -

i'm trying make kinetic canvas can add pictures source dynamically , wanted grid in background used kinetic.rect kinetic v3.8.2. images needs draggable, kinetic v.3.6.0, if set draggable when having v3.8.2 active breaks. "config undefined" according firebug. "img.kinetic.draggable not method" says firebug. is there fix this? can post small example? there have been changes kinetic api. here draggable image 3.8.2: <!doctype html> <html> <head> <script type='text/javascript' src='js/kinetic/kinetic-v3.8.2.js'></script> <script type='text/javascript'> window.onload = function () { var stage = new kinetic.stage('container', 400, 300); var layer = new kinetic.layer({ name: 'somelayer' }); var logo = new image(); logo.onload = function() { var myimage = n

c++ - Delay execution 1 second -

so trying program simple tick-based game. write in c++ on linux machine. code below illustrates i'm trying accomplish. for (unsigned int = 0; < 40; ++i) { functioncall(); sleep(1000); // wait 1 second next function call } well, doesn't work. seems sleeps 40 seconds, prints out whatever result function call. i tried creating new function called delay, , looked this: void delay(int seconds) { time_t start, current; time(&start); { time(&current); } while ((current - start) < seconds); } same result here. anybody? to reiterate on has been stated others concrete example: assuming you're using std::cout output, should call std::cout.flush(); right before sleep command. see this ms knowledgebase article.

mysql - How to create left joins without repetition of rows on the left side -

i have scenario there 2 tables (tables , b) linked in 1 many relationship. row in table a, maximum number of linked rows in b two, , these 2 rows (if exist) different each other through type column value either x or y. aid | name bid | type | aid 1 | name1 1 | x | 1 2 | name2 2 | x | 2 3 | name3 3 | y | 2 now, want have join query 2 tables in such way rows in displayed (no repetition) , 2 columns called type x , type y hold boolean / integer value show existence of types x , y each row in a. i.e, aid | name | type x | type y | 1 | name1 | x | null | 2 | name2 | x | y | 3 | name3 | null | null | my dbms mysql. thanks. you have use 2 joins: select a.*, b1.type typex, b2.type typey left join b b1 on a.aid = b1.aid , b1.type = 'x' left join b b2 on a.aid = b2.aid , b2.type = 'y'

gtk - How to load an accelerators map from a file using GTK3 in Vala? -

i'm making text editor using gtk3 in vala. have gtk.menubar in gtk.window , want use accelerators activate gtk.menuitems . want user able change key combinations, i'm loading accelerators specifications file using method gtk.accelmap.load("accels") . however, after calling method, accelerators not loaded: menu items don't have accellabels , not activated when press key combinations. here 2 files i'm working on. first file contains small version of application (to show i'm trying do) , second 1 accels file load accels specifications, , must in same directory. main.vala // compile me with: valac main.vala -o main --pkg gtk+-3.0 public class mywindow: gtk.window { public mywindow() { this.set_default_size(500, 500); var main_box = new gtk.vbox(false, 0); this.add(main_box); var accel_group = new gtk.accelgroup(); this.add_accel_group(accel_group); // load accelerators file gtk.accelmap.load("accels");

html - Adjustment of Border in CSS -

i want border of div less width of div. how implement in css? following image give more clarity: http://imageshack.us/photo/my-images/440/divkr.jpg/ this not possible plain css. you use 2 div's effect. <div class="outer"> <div class="inner"> text </div> </div>​ .outer { background-color:blue; padding:20px; width:200px; } .inner { border:solid 1px white; height:150px; color:white; } ​ http://jsfiddle.net/rreth/ http://jsfiddle.net/rreth/1/

apache - mod_rewrite mysterious subreq -

seems apache module interfering request uris suffixes ".html" it. my rewrite log: 172.16.103.1 - - [08/mar/2012:14:56:33 +0100] [www.example.org/sid#7ff723575b58][rid#7ff724b4fc58/initial] (1) pass through /folder/subfolder/ 172.16.103.1 - - [08/mar/2012:14:56:33 +0100] [www.example.org/sid#7ff723575b58][rid#7ff724b42468/subreq] (3) [perdir /srv/www/html/project/] add path info postfix: /srv/www/html/project/folder/subfolder.html -> /srv/www/html/trustedshops/folder/subfolder.html/ 172.16.103.1 - - [08/mar/2012:14:56:33 +0100] [www.example.org/sid#7ff723575b58][rid#7ff724b42468/subreq] (3) [perdir /srv/www/html/project/] strip per-dir prefix: /srv/www/html/project/folder/subfolder.html/ -> folder/subfolder.html/ this merely happens on our development servers. it's hard compare whole apache config. ideas module responsible? turn off multiviews generates subrequests ditto directoryindex list of possiblities. use ns flag on rewrite rules, or rew

facebook graph api - friends_likes permission bug? getting empty arrays -

like others have seen before, trying fetch likes of friend of gave me friends_likes permissions. details: usera gave me friends_likes permission userb friend of usera userb not have special privacy settings userb does have likes when userb gives me permission read like, am able read them, however, when indirect permission through friends_likes, cannot read likes. so what's deal? here example of full graph url including userb's id , active access token https://graph.facebook.com/likes/?ids=100003578153175&access_token=152574858188239|65ad053af5722df497d63771d4b360f9 again, getting empty array, although user have likes.

php - pagination count range of products on current page -

the pagination here works fine, addition pagination, limit per page 3 suppose total 8 items in database want display " showing 1 t0 3 item of 8" on page one, "showing 4 6 items of 8" on page 2 , on. please help $recordslimit = 3; $page = isset($_get['page']) ? intval($_get['page']): 1; $totalproducts = countproducts($selectedcategoryid); $totalpages = ceil($totalproducts / $recordslimit); $pagenumber = $recordslimit * ($page - 1); $products = getproductsbycatid($selectedcategoryid, $pagenumber, $recordslimit); <?php if($totalproducts > $recordslimit) : ?> <div class="pagination"> <span>page <?php echo $page.' of '.$totalpages; ?></span> <?php for($i=1; $i <= $totalpages; $i++) : if($i == $page) { ?> <strong><?php echo $i; ?></strong> <?php } els

c - Printing an integer -

i have user input date, e.g. 'january 10 12' signifying month, day , year. works fine if month 2 digit number, if user enters 'january 12 01' or number 0 in front of 'january 12 1' if month 01 or 'january 12 0' if month 00 instead of input. there form of formatting going wrong? #include <stdio.h> #include <string.h> #include <stdlib.h> typedef int (*compfn)(const void*, const void*); struct date { int month; int day; //the day of month (e.g. 18) int year; //the year of date }; char* months[]= { "january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"}; int getmonth(char tempmonth[]) { if(strcmp(tempmonth, months[0]) == 0) return 0; if(strcmp(tempmonth, months[1]) == 0) return 1; if(strcmp(tempmonth,

Including empty folders in tfs build -

our c# solution has couple of folders populated via post-build events (i.e. empty). the solution builds fine locally, when using tfs build agent, folders don't show in published websites folder. any suggestions on how force tfs copy folders over? this addressed here: publish empty directories web application in vs2010 web project tfs not execute afterbuild target of proj file. believe execute aftercompile target still might not want. i have used approach of including dummy files simple enough though lame. i've tried approach of including powershell script post-publish tasks works. more have adopted convention of including supplemental msbuild file ends in ".package.proj" , added additional msbuild execution activity team build template looks after files dropped drop location , executes it. provides simple hook team build workflow without getting deep changing workflow particular build. it's single additional activity wrapped in conditio

salesforce - Do calls to Schema.getGlobalDescribe() not run in system context in classes declared as without sharing? -

i have user profile disabled except api only , api enabled . user profile given access set of classes have rest services defined within them. i seeing strange behavior when calling schema.getglobaldescribe() . receive different response depending on class call method from, if of classes defined same way. here's simplified version of problem: global without sharing class webserviceclass { { system.debug(webserviceclass.fieldscontainname()); // returns true system.debug(utilityclass.fieldscontainname()); //this returns false! } global static boolean fieldscontainname() { system.debug(schema.getglobaldescribe().get('contact').getdescribe().fields.getmap().keyset().contains('name')); } } global without sharing class utilityclass { global static boolean fieldscontainname() { system.debug(schema.getglobaldescribe().get('contact').getdescribe().fields.getmap().keyset().contains('name')); } } why be? without

javascript - Reloading janrain widget -

i have janrain social login widget in place on site , processing authentication requests ajax. in situations, though there successful login social site (say, twitter), want prevent login on website. when happens, janrain widget stuck saying "loading...", though there's nothing more do. however, user able try logging in again through site (say, facebook). currently, way make happen refresh entire page. not convenient, not large burden either. still, avoid requiring this. here code - exact copy/paste of janrain provides: //initialization of widget on page load (function() { if (typeof window.janrain !== 'object') window.janrain = {}; window.janrain.settings = {}; janrain.settings.tokenurl = the_url janrain.settings.tokenaction='event'; function isready() { janrain.ready = true; }; if (document.addeventlistener) { document.addeventlistener("domcontentloaded", isready, false); } else { window.

c# - Listview with preview -

Image
i trying build email client. in list of incoming emails (list tall, narrow), want show sender, subject , date without horizontal scroll on 1 row. example, sender in top-left, date in top-right, , subject on second line. i see kind of list in outlook, , in iphone's mailbox. i googled bit see if else has built kind of list, couldn't find any. i using c# 2.0 windows, not wpf. any suggestion highly appreciated. thanks time. -rakib i recommend using better listview . there freeware variant, better listview express, available. the better listview fixes of original .net listview bugs , never need resolve drawbacks. , best thing better listview complete rewrite in 100% managed code, not listview wrapper:

dynamic - define language dynamically asp.net -

i have case have language defined admin. know how language supported web sites such http://www.codeproject.com/articles/163215/dynamic-definition-of-the-list-of-available-langua thread.currentthread.currentculture = cultureinfo.createspecificculture(language); thread.currentthread.currentuiculture = new cultureinfo(language); } but consumer wants define language doesnt need me change source code everytime wants add new language. have been searching reached nothing. give me idea how that? you can build own resourceexpressionbuilder stores key/value/language information in database table. can provide interface in administration add languages , update values based on database table. expression builder allow use same syntax localization built in resource files. not fast , easy solution though. takes time implement this. alternatively can teach customer create resource files , deploy them on server. should not require compilation.

list - What does locals()['_[1]'] mean in Python? -

i saw 1 liner code claimed remove duplicates sequence : u = [x x in seq if x not in locals()['_[1]']] i tried code in ipython (with python 2.7), gave keyerror: '_[1]' does ['_[1]'] mean special in python? locals()['_[1]'] way access reference list comprehension (or generator) current result inside list comprehension. it quite evil, can produce funny results: >> [list(locals()['_[1]']) x in range(3)] [[], [[]], [[], [[]]]] see more details here: the-secret-name-of-list-comprehensions .

silverlight 4.0 - Facebook c# sdk, silverlight4, login example please -

what upload photo fb user's wall. have photo in memory byte[] array. posting not of problem, getting user log in first having difficulty. documentation sdk in web context missing whole pages, , has 'todo' through pages have content. there sl4 sample, ide (vwde), not support unit-test folders. searching though unit tests hand, still not find 1 logging user in. have facebook app already, no problem there. there few gotchas have turned up: silverlight in-browser not support control. cassini web-server not supported sdk. if post example particular scenario, or link sample, using recent version of sdk, extremely grateful. thank prabir. pointers on image upload? code to-date. returns facebookoautherror(#1)unexpectedexception. var fb = new facebookclient(_accesstoken); writeablebitmap wb = new writeablebitmap(this.picprofile, null); string filename = wb.savetopng(); byte[] data = converttobytearray(wb); fb.postcomple

xml - How to solve error:Server Error in '/WebUI/Editors/2011Extensions' Application in Tridion? -

i trying add ribbon tool bar button in sdl tridion 2011 sp1 using custom editor configured in iis. need open pop-up aspx page when user clicks on ribbon toolbar button. clicking button returns: server error in '/webui/editors/2011extensions' application. configuration error description: error occurred during processing of configuration file required service request. please review specific error details below , modify configuration file appropriately. parser error message: error use section registered allowdefinition='machinetoapplication' beyond application level. error can caused virtual directory not being configured application in iis. source error: line 14: <compilation debug="true" targetframework="4.0" /> line 15: line 16: <membership> line 17: <providers> line 18: <clear /> enter code here source file: d:\sampleprojects_tridion\rtfextensions\popups\web.config

xcode - IOS: ad hoc provisioning -

i have problem: invalid profile: distribution build entitlements must have get-task-allow set false i know must set <key>get-task-allow</key> <true/> in entitlements.plist in xcode 4.3 don't find file, can do? you need add entitlements file project. you can find detailed explanation @ http://support.testflightapp.com/kb/common-questions/i-get-an-unable-to-download-error-when-installing-my-application . scroll down 'missing entitlements'.

osx - Creating a static library of static libraries in XCode -

i have need create static library of it's own code , contain number of other static libraries have written. so have main project a.xcodeproj depends on b.xcodeproj in turn depends on c, d, e etc. my company has requirement distribute static library simple app, , there 1 library sent out, not multitude of libc.a libd.a etc. so create a_static.xcodeproj has simple application api calls , links libb.a everytime try libb.a contains symbols b.xcodeproj, can not contain libc.a libd.a etc. is there easy way in xcode i'm missing? thanks it sounds need use frameworks. allows bundle multiple libraries , files 1 bundle other parties can include. i'm in same boat work. i've used guide on github our frameworks , running. worked great me. ios framework

symfony - Bind and save a form with a collection field using an array / Doctrine2 -

i have 2 entities room.php /** * @orm\table(name="room") * @orm\entity(repositoryclass="ahsio\stackbundle\repository\roomrepository") */ class room { /** * @orm\id * @orm\column(type="integer") * @orm\generatedvalue(strategy="auto") */ protected $id; // ... /** * @orm\onetomany(targetentity="ahsio\stackbundle\entity\workstation", mappedby="room", cascade={"persist", "remove"}, orphanremoval=true) */ protected $workstations; and workstation.php /** * @orm\table(name="workstation") * @orm\entity(repositoryclass="ahsio\stackbundle\repository\workstation") */ class workstation { /** * @orm\id * @orm\column(type="integer") * @orm\generatedvalue(strategy="auto") */ private $id; /** * @orm\manytoone(targetentity="ahsio\stackbundle\entity\room")

regex - remove part of string from each line -

i have text file, each line single string of format /home/usr1/284.txt the whole file like /home/usr1/284.txt /home/usr1/361.txt what want remove /home/usr1/ , keep file name, e.g., 284.txt how using linux/unix command? you use perl, so: perl -pe 's,.*/,,' file.txt

c++ - Copying an object for temporary use from the target of a constant-pointer parameter -

i'm looking copy object pointed pointer-to-const (as argument) within function temporary, stack-allocated copy, can manipulate , various checks on. how go doing this, without cheating way of const_cast? bool f(const foo* foo) { (create temporary copy of foo) (manipulate temporary copy of foo test validity) (output bool) } if function does, why not pass value?

javascript - Jquery this.height not working properly -

i setting height of tr dynamically using jquery. code run on document.ready . debugged code , saw height set coming proper ( 493 ) when assign it, tr , still showing 3193 while when see $(this)[0].style.height , shows 493px . confused how can different. code - $(document).ready(function () { var heighttoset = $(window).height(); $('#tr1').height(heighttoset); }); note elements in table big , due this, there no scrollbar. this refers document element in code. want set height of body element or descendant of body element. look @ console jsfiddle, you'll see this in event handler: http://jsfiddle.net/qwk6x/ update you can change css of td elements in table not show overflow. setting height it's being ignored because content of element makes lager set height: css -- td { display : block; overflow : hidden; white-space : nowrap; }​ js -- $(function () { $('#tr1').children().height($(window).height(

database - Oracle SQL Developer - Unable to run queries using varchar field as identifier -

i'm new using oracle sql developer , using oracle db (have used mysql before) i'm trying like: select * content_definition content_id = "hhhh233"; where content_id is: varchar2(1000 byte) but getting: ora-00904: "hhhh233": invalid identifier 00904. 00000 - "%s: invalid identifier" *cause: *action: error @ line: 1 column: 52 i'm not understanding why isn't working used queries time mysql. have been searching on nothing seems specific use case. appreciate if can set me in right direction on this. thanks you need use single quotes character data; double quotes signify identifiers , aliases: select * content_definition content_id = 'hhhh233';

Access local variable in function from outside function (PHP) -

is there way achieve following in php, or not allowed? (see commented line below) function outside() { $variable = 'some value'; inside(); } function inside() { // possible access $variable here without passing argument? } its not possible. if $variable global variable have access global keyword. in function. can not access it. it can achieved setting global variable by $globals array though. again, utilizing global context. function outside() { $globals['variable'] = 'some value'; inside(); } function inside() { global $variable; echo $variable; }

android - Upload Image from inbuilt Gallery -

as don't have sd card. want upload image server selecting image built -in gallery. can me on how place image in in-built gallery can select there. any appricated. you can go inbuilt gallery following code: button btnbrowse = (button)findviewbyid(r.id.btn_browse); btnbrowse.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { intent intent = new intent(); intent.settype("image/*"); intent.setaction(intent.action_get_content); startactivityforresult(intent.createchooser(intent, "select picture"), select_picture); } }); now onactivityresult should this. public void onactivityresult(int requestcode, int resultcode, intent data) { if (resultcode == result_ok) { if (requestcode == select_picture) { uri selectedimageuri = data.getdata(); selectedimagepath = getpath(selectedimageuri); edittext imagebrowse = (edittext)findview

CSS layout on HTML5 -

Image
i developing 1 web application in html5 , js. , using ' canvas ' tags in it. structure them on screen like: i have achieved using such css tags as: margin-right, margin-left, top, position . problem when use these css tags, more or less adapting whole layout 1 screen only, unfortunately aim support screen possible. maybe there professionals in layouting particular problem. p.s. when window size changed, canvases should not resized i have created demo. i believe this want. html: <div id="wrapper"> <div id="col1"> <div class="canvas">canvas-left-1 <div class="innercanvas">canvas-left-1-1</div> </div> <div class="canvas">canvas-left-2 <div class="innercanvas">canvas-left-2-1</div> </div> </div> <div id="col2">canvas 0</div> <div id=&q

node.js - How do I share javascript on the server as well the client? -

lot of time end repeating code on server client. example have registration form; validations required field, email address regex same on both server , client. ideally want write code in 1 place , not repeat. if you're using express.js , take @ express-expose module. seems you're looking for: expose objects, functions, modules , more client-side js

php - RegEx find "../" or "./" -

i trying regex tell me if path contains ./ or ../ . check user doesn't beyond area. if input contains period before forward slash wont accepted. e.g. /user/selected/path/ - ok ./user/selected/path/ - failed ../user/selected/path/ - failed the forward slash replaced directory_seperator works unix , windows paths. use this if (preg_match('#\.(\.)?/#', $path, $match)) echo "error"; if need check ../ or ./ in beginning must use this if (preg_match('#^\.(\.)?/#', $path, $match)) echo "error";

Bounding box and collision detection code snippets for Adobe flash professional Cs5.5 -

i creating basic game in flash professional cs5.5 , wanted know if had code snippets bounding box character, , collision detection code snippet. the game consists of player moving out way avoid cars , other obstacles while getting scored how long run. ours 3d, c# ape physics entire engine here take @ convex hull , environment we used bounding volume hierarchy a simple method of optimisation put sphere around every object. when testing 2 objects collision, check if centers of objects within radius range. if bounding spheres don't collide no more work needs done.

Utility started from python code doesn't write in file -

i have 2 utilities written in c++, tcp/ip server , client have used years. server opens designated file , waits client connect. after connection has been established server starts send file's content. client receives , saves in file. now, want write python script start both application , wait them finish. after script other work. written windows. first script in python. , first problem can see both applications have started , connected each other. can see because 2 dos windows appears , show messages inform me connection. however, don't see file, has created client. wrong. code simple , follows. import subprocess p = subprocess.popen('c:\myprojects\exes\feedsender_exe\feedsender.exe c:\myprojects\exes\feedsender_exe\feedsender.ini') print "start1" p1 = subprocess.popen('c:\myprojects\exes\feedreaderfileprocessor\feadreaderi41.exe c:\myprojects\exes\feedreaderfileprocessor\config.ini') print "start2" line in p.stdout.readlines():

vb.net - asp.net vb - update database field value automatically when another value is added elsewhere -

i have 2 tables: holidayrequests & holidayentitlement within holiday requests have 1 field: days when staff member adds holiday request stored number in holiday requests table in days field (there multiple requests different days) within holidayentitlement table have 3 fields: entitlement taken remaining when staff member adds holiday request want update both taken , remaining like... taken = (sum)days staffid = staffid remaining = entitlement - taken i've got no idea how go doing this. idea similar of stock management... can point me in right direction can started you can implement business logic that: in database triggers (see other answers) in vb code linq2sql using partial methods: example http://msdn.microsoft.com/en-us/library/bb546176.aspx partial class customer private sub onaddresschanged() ' insert business logic here. end sub end class

c# - Cascading delete in Entity Framework -

Image
so have 2 tables, invoices , invoiceitems. when delete invoice, i'd related invoiceitems deleted well. i updated relationship in sql server cascading delete when delete invoice. entity framework didn't recognize change, however, i've read need manually update edmx cascading delete. well in design view of edmx, clicked on relationship between 2 tables, , checked properties try , set cascading delete as can see, there 2 ondelete properties: end1 ondelete , end2 ondelete which 1 need set cascade? if end1 principal of relationship (i.e invoice has invoice items) makes sense cascade deletes.

java - Wrapping primitives for CXF -

i need send list of primitives on web service, example parameters run stored procedure. in java have list. doesn't work cxf. ended doing list simpledataitem attached code. idea, or there better aproaches? i'm executing function this: resultset executestoredproc(string procname, object... args) throws sqlexception; right simpledataitem looks this: public class simpledataitem { private string s; private long l; private integer i; private bigdecimal d; private boolean b; private long t; private byte[] ba; public simpledataitem() { } public simpledataitem(object o) { dosetobject(o); } public void dosetobject(object o) { if (o==null) { return; } if (o instanceof string ) { s=(string)o; return; } if (o instanceof long ) { l=(long)o; return; } if (o instanceof integer ) { i=(inte

monotouch.dialog - Has anyone used MT.D MultilineEntryElement? -

i'm using recent 1 created alxandr (feb/2012). i'm trying add section using same technique adding entryelement. multilineentryelement adds section receiving cell not expand past it's default size. mlee overwrite section below. default full screen width , 10 lines long. best way this? thanks you! matt to deal problem, set rootelement's unevenrows property true, this: var r = new rootelement ("foo") { ... } r.unevenrows = true;

mysql - what's the common schema for allowing multiple "types" of data that is of the same parent -

what's standard way of storing ``subtypes'' if in relational databases mysql? as example, think of single user's facebook feed. contains "entries", these entries can vary in type , needs stored. status might require varchar(255) example, while picture might want blob , note might need text . completely separate tables make necessary make seemingly needlessly complex queries of recent entries of type. seems awkward, inefficient , not stable have lot of columns in 1 can not null. i understand must common question cannot find similar, please feel free tell me duplicate , i'll happily close question. i think call subtypes hierarchy. entries abstract entities , concrete subentities status , picture , whatever . user can have many entries "mapped" somehow 1 of subentities. you can take @ question see how transform hierarchy tables: what best database schema support values appropriate specific rows?

iphone - Custom border of uitextfield -

i need make login form facebook app ( http://pttrns.com/logins#/detail/cf098fbe9dc609472c0c80d257db7ee2 ). didn't find default decision. suppose must make border of uitextfield . ideas on how accomplish this? set borderstyle of text view uitextborderstylenone , can place them on top of whatever want. in facebook's case, looks they're on top of table view, put image behind them.

How do I change my category? (Windows Phone 7) -

i developing windows phone 7 application. noticed genre tag in wmappmanifest.xml, unable useful it. how can categorize application game? , if it's possible add category in games section. <?xml version="1.0" encoding="utf-8" ?> <deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment" appplatformversion="7.1"> <app xmlns="" productid="" title="" runtimetype="" version="" genre="how can use this?" author="" description="" publisher=""> have @ this: http://msdn.microsoft.com/en-us/library/ff769509(v=vs.92).aspx#bkmk_application

x86 - Assembly - How 0x80 with ecx=esp work? -

i have next code: doit: mov eax, 4 ; write system call push dword, 0x44434241 mov ebx, 1 mov ecx, esp mov edx, 4 int 0x80 add esp, 4 ret as check, it's print "abcd", why? understood it, on stack have next picture: low --- 0x41 0x42 0x43 0x44 -- esp, i.e esp point 0x44. when call 0x80. should print "dcba". missed? your stack picture wrong. because x86 little-endian architecture, esp equal address of least-significant byte in pushed value, or 0x41 . from intel's priceless architecture developer's manual : when item pushed onto stack, processor decrements esp register, writes item @ new top of stack.

GWT Application in Tomcat with endless sessions -

i have gwt application running in tomcat 6. problem scenario following: people using application , example user b clicks through application. now restart of application if not open start page of gwt application, whole web app going crash user b continues working in application. for sufficient if can set session timeout, means user being redirected start page after 30min (if not in application). restart happening @ 0300 maintenance reasons. therefore wondering, if can set session timeouts in tomcat gwt applications? in web.xml timeout set 30min think not working gwt application. the gwt part of application client side, doesn't control sessions. behavior want (of timing out after 30 minutes of inactivity) create servlet filter on every request looks @ last request time in session, if has expired creates new unauthenticated session, if not expired updates session next timeout (or time+30 minutes). in servlet code check authenticated session , if isn't vali

ruby - CentOS + Rails + nginx + Unicorn + MySQL + RVM(?) howto? -

can point me recent guide on how setup centos + rails + nginx + unicorn + mysql + rvm(?) ? or provide instructions here? i'm not sure if use rvm on production server, idea? rvm, ruby , rails straightforward setup in centos. install requirements: sudo yum install git patch pcre pcre-devel openssl openssl-devel curl curl-devel libxslt-devel libxml2-devel sqlite-devel nginx install rvm: bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) reload profile: source ~/.bash_profile run rvm requirements , install of listed dependencies: rvm requirements update rvm (just in case): rvm head && rvm reload install latest version of ruby: rvm install 1.9.3 setup rvm environment: rvm use 1.9.3@projectname --create --default update gems latest version: gem update --system install rails: gem install rails install unicorn: gem install unicorn you should check out defunkt github re

Is it possible to access variables defined in assembly from C? -

can read or write variable defined in assembly file in c file? couldn't figure out on own. example c file looks follows: int num = 33; and produces assembly code: .file "test.c" .globl _num .data .align 4 _num: .long 33 as started learn assembly heard speed reason why have pick assembly adn lower file size , stuff... i using mingw(32 bit) gnu assembly on windows7 yes, linker combines .s files , makes single object file. c files first become assembly files. each assembly file have import list, , export list. export list contains variables have .global directive. import list contains variables start extern in c file. if assembly file contains this: .file "test.c" .globl _num .data .align 4 all need in order use num, create extern variable this extern int num and you'll able read or modify it.

python - Serving django Admin files with Apache and mod_wsgi -

i'm having trouble getting apache serve admin media django (using ver. 1.1). admin_media_prefix set default: admin_media_prefix = '/media/' and i've modified apache setup: alias /media/ /usr/lib/pymodules/python2.6/django/contrib/admin/media/ <directory /usr/lib/pymodules/python2.6/django/contrib/admin/media/> allowoverride none options none order allow,deny allow </directory> i'm not entirely sure what's going on here , why isn't working. i've seen lot of questions asked, can not determine why i'm still having problem. edit: apache logs [sun mar 11 20:14:18 2012] [notice] graceful restart requested, doing restart [sun mar 11 20:14:18 2012] [error] exception keyerror: keyerror(-1220142448,) in <module 'threading' '/usr/lib/python2.6/threading.pyc'> ignored [sun mar 11 20:14:18 2012] [error] exception keyerror: keyerror(-1220142448,) in <module 'threading' '/usr/lib

.net - "Switching" different cultures in C# code -

i writing own timespan readablestring implementation. need support different languages. a functional class implemented static class 2 static public methods, both called convert, 1 receives timespan value parameter, whereas second 1 allows provide cultureinfo in order specify, desired readable string language. my question idea use basic switch(desiredculture.threeletterisolanguagename) , return different string.format results. is approach, given simple task trying solve? using threeletteriso anyhow more reliable , wide-spread 2 letter codes languages? it seems me don't want localize timespan , want localize whole application. there several ways how (for example, there weird, overcomplicated way specific wpf ). but preferred way use resource files. can have 1 culture-neutral resource file (e.g. text.resx ) , 1 resource each culture want support (e.g. text.de.resx german). if there no resource set culture, culture-neutral 1 used. visual studio has editor reso

java - Allowing thread unsafety in arrays -

i have java application performing realtime image processing, image data stored in large int arrays. updates parts of image array happening multiple threads (this visualisation of high volume stream of incoming events). readers need take copies of parts of image array display and/or further processing. because of need high throughput, want avoid expensive synchronisation handle concurrent access. in addition, occasional small visual errors can tolerated, e.g. if reader copies section of image has been partially updated given incoming event. want relax thread safety ensure maximum throughput. is approach going work? gotchas should aware of? presumably proposing partition array , allow single thread access each partition. reasonable approach without issue. in fact fork/join framework , may applicable trying acheive. e.g. @ javadocs java.util.concurrent.recursiveaction shows example of partitioning array sort it. in nutshell array partitioned until partition size

passing metadata from one activity to the next in an android listview -

i understand there's set of methods used pass data 1 activity next using, how model within activity list view? example: have json object use populate listview. each list item has id. want pass id next activity on click. how know listview's item id? wasn't sure how attach arbitrary metadata listview item , grab , pass along. public class stufflistactivity extends listactivity { private myapplication application = null; /** * called when activity first created. * * @param savedinstancestate saved instance state */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); application = ((application) getapplication()); requestor req = new requestor(); application.log(listtype.tostring()); arraylist<string> list = req.getstuff(application.getid(), listtype); adapter = new arrayadapter<string>(this, r.layout.list, r.id.st