Posts

Showing posts from February, 2014

Can I add admin links with dynamic JavaScript from my controller in CodeIgniter 2? -

i want cache of controllers’ output, of pages need have links can add , edit info. if set “js” controller , routed “global.js” “global” method of “js” controller, couldn’t use php dynamically add javascript “global.js” if i’m logged in admin? there better way cache pages if visitor not admin? i want show add/edit/delete links on page, if i'm logged in admin. want cache page. codeigniter's caching doesn't support conditional caching, needed workaround insert links dynamically. i'm using php dynamically write javascript can use jquery insert links. 1) set in /config/routes.php: $route['js/global.js'] = 'js/global_scripts'; // function can't called "global" since it's php keyword 2) have function in js controller: public function global_scripts() { $this->output->set_header("content-type: application/x-javascript") $this->load->view('js/global'); // see below } // global_scripts

facebook - How do you load third party package in Codeigniter? -

this elementary question. i downloaded facebook php sdk , stored in "third_party" folder within codeigniter. hoping should go. how load such php sdk? thanks i ended sticking in in ci's libraries directory , adding libraries autoload in config/autoload.php autoload.php: $autoload['libraries'] = array('facebook'); then, made small change facebook implementation (constructor of facebook class) , added keys app's config file: public function __construct() { $ci =& get_instance(); $this->setappid($ci->config->item('fb_appid')); $this->setapisecret($ci->config->item('fb_secret')); $this->setcookiesupport($ci->config->item('fb_cookie')); $this->setbasedomain($ci->config->item('fb_domain')); $this->setfileuploadsupport($ci->config->item('fb_upload')); } ...and presto - have access facebook's api in models , controller

String variables in python function? -

i'm writing script in python, not able use multiple stings in cases check directory, file creation etc, i'm using user input : drive = raw_input('enter drive name make backup ') if not os.path.exists('/media/%s/backup' %drive): os.mkdir('/media/%s/backup' %drive) the above code working, tarfile below giving error........ ./backup4.py enter drive name make backup pendrive traceback (most recent call last): file "./backup4.py", line 17, in <module> tarfile = tarfile.open("/media/%s/backup/%s.tar.bz2" %drive %datevar, 'w:bz2') typeerror: not enough arguments format string tarfile = tarfile.open("/media/%s/backup/%s.tar.bz2" %drive %datevar, 'w:bz2') what changes should make above tarfile.open?? your string formatting incorrect. need pass tuple of variables equal amount of substitutions in string. tarfile = tarfile.open("/media/%s/backup/%s.tar.bz2" % (drive,

scala - Method return type covariance -

how can define method returns list[+anyref]? tried: def a[t <: anyref](): list[t] = list[anyref]() but reason not compile. edit : according wong should use def a[t <: anyref](): list[t] = list[t]() but there way able return subtype of anyref, example def a[t <: anyref](): list[t] = if (value) list[t]() else list[option[string]]() here option[string] descendant of anyref, compiler not accept it so main question if can declare method covariant return type list[+anyref] let's make couple observations , experiment few ways of letting compiler decide on return type: 1) notice statement if (value) list[t]() else list[option[string]]() returns 2 different specific types if statement must return same type , else clauses. when statement returns value, compiler need infer general type 2 clauses bring in consistent constraint. 2) notice type variable t dependent on exact type pass in when call a() , example a[scala.io.source]() . in method decla

php - How to access a constant from within a class method -

i'm migrating php application procedural oop. use debug constant activate errors , warnings output (in fact, have thee, every 1 makes output more verbose. can't find way access constants within method. constants defined before autoload in separate file. in utility file have define('debug', true); and inside given method tried if(!defined('debug')) define('debug', false); but end debug=false. doing wrong? i'm total noob oop, gentle please :-) clarification every class has own file. in given script, first thing include utility file. utility file 1 defines debug , has _autoload function. script_file.php includes utility_file.php defines debug has _autoload function according this , should access debug (no prepending $) in code directly. including or requiring utility file in same file has function you're talking about? don't think oop problem

java - The composite pattern/entity system and traditional OOP -

Image
i'm working on small game written in java (but question language-agnostic). since wanted explore various design patterns, got hung on composite pattern /entity system (which read here , here ) alternative typical deep hierarchical inheritance. now, after writing several thousand lines of code, i'm bit confused. think understand pattern , enjoy using it. think it's cool , starbucks-ish, feels benefit provides short-lived , (what irks me most) heavily dependent on granularity. here's picture second article above: i love way objects (game entities, or whatever want call them) have minimal set of components , inferred idea write code looks like: baseentity alien = new baseentity(); baseentity player = new baseentity(); alien.addcomponent(new position(), new movement(), new render(), new script(), new target()); player.addcomponent(new position(), new movement(), new render(), new script(), new physics()); .. nice... in reality, code ends looking like basee

powershell - Pscx.IO.PscxPathInfo -

i trying create shortcut using new-shortcut pscx. putting in paths i'm getting pscxpathinfo error ( string cannot converted pscxpathinfo). tried $dest = "...path" - , used "get-item $dest" - nothing helps. can show me example how use new-shortcut? kind regards franz-georg this known bug think oisin has fixed in daily bits e.g. works me: new-shortcut c:\users\keith\desktop\reflector.lnk c:\bin\reflector.exe we need official release out here shortly. fixed quite few bugs since original pscx 2.0 release.

python - Trouble in regular expression -

matching g in 'reference: g. ' using regular expression i tried using error still occur refresidue = re.compiler(r'(s/reference: \ //n)') any other suggestions i'm quite new in this. appreciated. 'reference: g. ' reference can either a,c,g or t i'm sorry confusion - have output prints out characters (a,c,g,t) instead of reference: . this code refresidue = re.compiler(r'(s/reference: \ //n)') a_matchref = refresidue.search(row[2]) if a_matchref not none: a_matchref = a_matchref.group(1) you're mixing regex syntax javascript (or other regex flavor) , python; , regex quite strange. also, re.compile() compiles regex, doesn't match anything. assuming want match single alphanumeric character after text reference: , try following: refresidue = re.search(r"reference:\s*(\w)", your_text_to_be_matched).group(1)

windows - Avoid hourglass after calling CreateProcess -

in win32 app embed ffplay.exe video preview. works great each time start preview cursor becomes "busy", i.e. arrow+hourglass. want avoid that. set startf_forceofffeedback flag in dwflags member of startup_info struct pass createprocess() .

request - JSF Page Navigation Options -

i have question regarding jsf navigation, if want simple page navigation need use redirect method defined in faces-config.xml? for instance have page 1 , user clicks rows in datatable value, navigates page 2 , process , come page 1. i have read in thread here . redirect happens recreate request scope bean. could 1 provide insight this? other options available page page navigation. i using jsf 1.1 appreciate help. regards depends on data wish pass between pages: if data complicated , interconnected ("a wizard scenario") - use faces-config.xml, let pass complex objects between pages; if data can presented simple strings (like "a detail page product_id = 145"), use plain links (like /product.jsf?product_id=145) , inject beans request params using faces-config.xml , managed properties (like: #{param.product_id}). since stuck on using jsf 1.1 (i suspect balusc hard pressed it) - must strive simplicity everywhere else.

Android -How to run services in background when certain criteria meets how to display the notification -

how can run services in background of battery manager android application? how display or receive notification when battery low or when criteria met? for example, alarm, when current time equals alarm time alarm rings. you have 3 options: you create long running service. spawns off thread checks things mentioned periodically. wouldn't advise tho, these services tend killed on long run os. also, you'd have use wake locks prevent system put cpu on idle when phone goes idle after minutes of inactivity - stopping service. check out available system events can register broadcast receivers. if find suitable ones (i think there's 1 indicating low battery levels), write receivers them. use timing service register intents fired off on regular intervals. these intents start service (a short running one) thing.

android - connecting my application to wamp server -

i new android. want display localhost (wampserver) page on click of button. i have tried using httppost method not displaying blank mess. if give wrong addres throwing error message. all appriciated use 10.0.2.2 instead of localhost in urls you're directing towards wamp check this out.

android - How to play a custom sound after the countdown timer ends? -

i trying implement following functionality in application the user selects music file in 1 input field , time duration ( seconds ) in other. after user presses ok, count down timer starts , runs till entered time duration expires , chosen music file should start playing. can please advise me on best way implementing other using alarm manager? final timer timer = new timer(); final timertask task = new timertask() { @override public void run() { mediaplayer mp = new mediaplayer(); mp.setdatasource(path_to_file); mp.prepare(); mp.start(); } }; timer.schedule(task, delay);

multithreading - Process forking, child processes etc. [Java] -

i need implement vector clocks in small programming exercise , decided use java it. question not related actual algorithm of manipulating vector clocks of processes, how initialize other java applications or child processes relatively easy java program? my initial plan following: have "main program", decides how many clients/children start , these children/clients should communicate each other , update corresponding vector clocks accordingly. number of clients started depends on number of lines in input file given "main program". elegant way start these client processes? should each take 2 files , integer parameters. files tell (send or advance clock) , integer tells line in configuration file client should pick port number used. in java, concept of creating concurrent tasks based on threads rather processes . start new process , must typically invoke java multiple times or use processbuilder interface. concurrency in java designed threads, that

asp.net mvc - FluentValidation on number issue -

i using fluentvalidation in asp.net mvc 3 application. i have maxnumberteammembers property in view model such: /// <summary> /// gets or sets maximum number of team members. /// </summary> public int maxnumberteammembers { get; set; } i want know if following ruleset possible: on front end view, if textbox empty want "maxnumberteammembers required" message displayed if number entered less 1 want message display "maxnumberteammembers should greater or equal 1". what ruleset above like? i have following not work on greaterthan part if enter 0: rulefor(x => x.maxnumberteammembers) .notempty() .withmessage("max. number of team members required") .greaterthan(0) .withmessage("max. number of team members must greater 0"); update 2011-02-14: rulefor(x => x.minnumbercharacterscitation) .notnull() .withmessage("min. number of characters citation required") .greaterthanorequ

need to display char in xslt -

hi using xslt 1.0. have char code foa7 has displayed corresponding character. input <w:sym w:font="wingdings" w:char="f0a7"/> my xslt template <xsl:template match="w:sym"> <xsl:variable name="char" select="@w:char"/> <span font-family="{@w:fonts}"> <xsl:value-of select="concat('&#x',$char,';')"/> </span> </xsl:template> it showing error error: 'a decimal representation must follow "&#" in character reference.' please me in fixing this..thanks in advance... this isn't possible in (reasonable) xslt. can work around it. your solution concat invalid: xslt not fancy string-concatenator, transforms conceptual tree . encoded character such &#xf0a7; single character - if somehow include letters & # x f 0 a 7 ; xslt processor required include these letters in xml data

scripting - How to send data to php script, which already running? -

i need send data php script listening socket in cycle , receive data it. can make without white/read file between scripts? update: there 2 php scripts; 1 script listening e.g. telnet, secondary script must send data first script write data socket. yes - that's pretty definition of socket for . what's problem?

.net - What is powershell good for? -

i'm competent c# programmer, , newbie powershell. wonder, it's for? more of programmer's tool or admin's? please share experience. when easier write script using .net assemblies c# tool? real, production tasks use for? upd: maybe question should "what it's compared c# not batch ". writing c# tool typically need set visual studio project (or project in ide, or if doing "manually", need @ least build script call c# compiler). if specific task seems overhead, , need simple one-file-source-and-program-is-all-in-one solution, powershell script may better alternative. edit: making answer cw, can add here reasons why may prefer powershell script agains c# solution: you don't have visual studio (or other c# ide) installed on machine, or not used @ (like lot of sysadmins) the program small don't need debugger, simple console outputs it you not want maintain more 1 file you don't want separate configuration parameters

java negator operator -

hi i'm trying use negator operator in java try , change negative amount inputted user same number positive. tips on how appreciated. thanks you looking math.abs . in case desperately bored: absolute value . cheers

redirect - Redirection url using urllib in Python 3 -

i need know final url when following redirections using urllib in python 3. let's i've code : opener = urllib.request.build_opener() request = urllib.request.request(url) u = opener.open(request) if urls redirects website, how can know new website url ? i've found nothing useful in documentation. thanks ! you can use u.geturl() to url redirected (or original 1 if no redirect happened).

Glassfish v2.1.1 and java-web-start -

i've started job uses glassfish 2.1.1 app server , noticed there's java-web-start directory under domain1 folder. in folder there empty directories correspond 1:1 ear (and other files) files deployed under ....\domain1\applications\j2ee-apps. what purpose of java-web-start folder , why have empty directories in it? new glassfish. tia glassfish allows user launch local client can access application inside glassfish directly. launching happens java webstart. see http://java.sun.com/developer/technicalarticles/j2ee/jws-glassfish/ introduction.

WPF: instances of usercontrol share dependency properties -

i made usercontrol , works great, when put 2 instances of control 1 window, last of them works. tried find solution , realized, dependency properties shared, dont know how work. here dependency property: public double animatingverticaloffset { { return (double)getvalue(animatingverticaloffsetproperty); } set { setvalue(animatingverticaloffsetproperty, value); } } public static readonly dependencyproperty animatingverticaloffsetproperty; static listchooser() { listchooser.animatingverticaloffsetproperty = dependencyproperty.register("animatingverticaloffset", typeof(double), typeof(listchooser), new uipropertymetadata(onanimationverticaloffsetchanged)); } the dependency property must static no ties 1 single instance. , applies callbacks (onanimationverticaloffsetchanged in case) - these must static methods (don't worry, object instance passed via parameter, have type casting ensure ob

java - Iterate through items in a list with richfaces in javascript -

is there way, in richfaces preferably, access java collection object , loop through items in java-script function? i know richfaces datatables can access property , create rows based on each item in list, can't figure out how replicate same functionality in java-script method. the reason this, need build array of object literals, each object corresponding item in list. you can use jstl core library iterate through list: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <c:foreach var="item" items="${bean.items}"> alert(${item.somefield); </c:foreach>

IronPython Memory Leak When Calling Function With More Than 13 Parameters -

i'm using ironpython 2.6.2 .net 4.0 scripting platform within c#/wpf application. scripts can include own function definitions, class definitions, etc. i'm not restricting can written. a memory leak appeared in scripting piece after script change. after commenting out more , more code, determined defining , calling function more 13 parameters causes memory leak. if call function 14 parameters ironpython leak. here sample code on timer running every 100ms: _timer.enabled = false; try { var engine = python.createengine(); engine.execute("def somefunc(parami, paramii, paramiii, paramiv, paramv, paramvi, paramvii, paramviii, paramix, paramx, paramxi, paramxii, paramxiii, paramxiv):\r\n\tpass\r\nsomefunc(1,2,3,4,5,6,7,8,9,10,11,12,13,14)"); //engine.execute("def somefunc(parami, paramii, paramiii, paramiv, paramv, paramvi, paramvii, paramviii, paramix, paramx, paramxi, paramxii, paramxiii):\r\n\tpass\r\nsomefunc(1,2,3,4,5,6,7,8,9,10,11,12,1

mod rewrite - What does this this HTTP Authorization RewriteRule do? -

i have rewrite recursion error somewhere on website google bot caused, can't find url caused because loglevel low. raised has not happened again far. rewriterule .* - [e=http_authorization:%{http:authorization}] all rewriterules fine me , have [l] flag, except one. i can't quite understand it. open source shop system magento. as far can tell nothing sets environment variable e. isn't stupid way of doing that? shouldn't use setenv if goal? this line setting environment variable value of user authentication string - setting variable rather constant value. far know, setenv , setenvif allow set environment variable predetermined constant. the variable being set http_authorization, not e. guess part of user authentication process.

c# - Why use Convert.ToInt32 over casting? -

this question has answer here: when use cast or convert 9 answers a question cropped @ work today how convert object specific type (an int ), said cast it: int = (int)object; a colleague said use convert.toint32() . int = convert.toint32(object) what's difference between convert.toint32() , direct object cast? not every object can cast directly int . example, following not compile: string s = "1"; int = (int)s; because string not implicitly convertible int . however, legal: string s = "1"; int = convert.toint32(s); as side note, both casting , convert can throw exceptions if input object cannot converted. however, int.tryparse not throw if fails; rather, returns false (but takes in string, have .tostring() input object before using it): object s = "1"; int i; if(int.tryparse(s.tostring(), out i)) {

image - accessing pictures in my exe of wpf app from codebehind -

im accessing image in xaml , setting picturebox with source="/socialshock-wpf-client;component/images/blue-bar-replication.png" how in codebehind? public static bitmapimage getimagefromresource(string name) { var res = new bitmapimage(); res.begininit(); res.streamsource = assembly.getexecutingassembly().getmanifestresourcestream("socialshock-wpf-client.images." + name); res.endinit(); return res; } invoke method image name, "blue-bar-replication.png" in case. image build action should set embededresource.

embed non web application in jetty -

how can configure jetty6 start non web application (not servlet)? java app rabbitmq consumer listening ampq messages on tcp. have jetty init() call main entry point. there better way this? why not provide trivial servlet provides init() method , invoke application within there ? i.e. wrap within servlet wrapper next nothing. it doesn't have respond gets / posts etc. although you'd find useful , report application status via simple html page.

video - jpeg and h264 formats -

what difference between h264 , jpeg? h.264 format encoding video. jpeg format encoding still pictures. implementations different well. h.264 specification (pdf) jpeg specification (pdf)

parsing - Visiting nodes in a syntax tree with Python ast module -

i'm playing python ast (abstract syntax tree). i wrote following , visited nodes of ast. import ast class py2neko(ast.nodevisitor): def generic_visit(self, node): print type(node).__name__ ast.nodevisitor.generic_visit(self, node) def visit_name(self, node): print 'name :', node.id def visit_num(self, node): print 'num :', node.__dict__['n'] def visit_str(self, node): print "str :", node.s if __name__ == '__main__': node = ast.parse("a = 1 + 2") print ast.dump(node) v = py2neko() v.visit(node) then added methods py2neko class def visit_print(self, node): print "print :" def visit_assign(self, node): print "assign :" def visit_expr(self, node): print "expr :" but when encounters "print" statement or assignement or expression seems stops , isn't

c# - How to remove duplicate items from a queue within a time frame? -

i remove duplicate entries queue in efficient way. queue has custom class datetime , fullpath , few other things private queue<mycustomclass> sharedqueue; the datetime in class timestamp when inserted queue. logic use following: remove duplicates queue if fullpath identical within 4 second window (i.e. if added queue within 4 seconds of duplicate fullpath). have events want watch few duplicates still arrive , ok. i using c# 2.0 , filesystemwatcher class , worker queue. there bunch of ways this: trim queue each time item added it, or when working on queue skip processing of current duplicate item. or should use 'global private' variable dictionary< string, datetime> ? can search it? or local copy of queue ? perhaps best limit local queue 100 items in case of many file events? though in case 'should be' relatively few files monitor in folder... things change... thanks help. :edit: feb 10 8:54 est: decided implement simple solution far ca

Magento - Change customer tax class id dynamically to affect existing order -

is possible dynamically update customer_tax_class_id attribute of oder being processed - guest customers. i have tried setting via checkout/session model not update. the goal reset tax amount based upon condition 0. using tax_class_id have rule of 0 tax. you should before order submitted, user pays correct amount first time (and has no surprises). there reason cannot determine tax_class in advance?

c# - Unable to find DLL when website runs in IIS -

when run website locally using vs, works. i calling function inside dll using p/invoke. dll in c++ , works. when deploy website on iis, error message unable load dll 'solvingprobelm.dll': specified module not found. (exception hresult: 0x8007007e) the dll resides inside bin folder. app pool classic , .net 2.0 any suggestions appreciated. regards i had faced similar problem once. copy solvingprobelm.dll c:\windows\system32 . hopefully, work! had worked in situation. native dlls , .net dlls searched differently. iis searches native dlls in c:\windows\system32 folder also. copying dlls there solves problems!

c - What type is the reference to an array variable? -

i have following code: /* * pointer function reads codesegment */ typedef bool (*brcs)(void *, uint32, uint64 *, uint64 *, const char **, const char **); brcs get_prog_id; /* * 'get_prog_id' loaded dynamic library */ uint64 start_o; uint64 length_o; char prog_id[256]; char err[256]; get_prog_id(null, 0, &start_o, &length_o, &prog_id, &err); when run compiler, following warnings: passing argument 5 of get_prog_id incompatible pointer type passing argument 6 of get_prog_id incompatible pointer type so, it's complaining don't have char ** last 2 arguments. i'm confused. understanding variable representing array of types equivalent pointer type . such, applying & operator give pointer pointer type . what missing here? there 2 problems here: (1) the type of &prog_id not char * , it's char (*)[256] ; i.e. pointer-to-char-array-of-length-256. (2) even if char ** (e.g. char *prog_id = malloc(25

android - How to do an inter-type injection on classes that have methods with a certain annotation? -

to give context: using aspectj android projects, , i've written @background annotation apply methods cannot block main ui thread. annotation being intercepted pointcut , around advice takes care of running code in background thread , dealing network errors , user notification. what next automatically provide reload button on menu activities have such background methods has done overriding method following signature: public boolean oncreateoptionsmenu(menu menu); activities don't background stuff don't need have menu, , thus, don't override method. so, there way make aspectj override method in classes have (at least) method particular annotation ? or there more elegant solution ? thanks, carlos. take @ hasmethod type pattern (you can see bug report usages). should able add marker interface types have method(s) required signature , introduce oncreateoptionsmenu it.

apache - HTTP authentication versus cookies -

it seems cookie based authentication clear choice today web services require login credentials. but if you're developing web service clients not browsers, client software (such mobile app) accesses resources via http, use http authentication or cookie authentication? http auth: web server handles authentication, easier change web app platform if needed automatically applied non-code resources (e.g. jpg, xml, etc) (side q: there way cookie-based auth?) harder integrate database-stored credentials server auth (.htaccess/.htpasswd) cookie auth: fine grained access controls (a code resource can respond differently based on credentials) control on expiration of session (via cookie expirations) full control on user login experience what other considerations leaving out? other pros/cons? some helpful discussion here with http authentication, code resource can respond differently based on user made request. name of user passed code via http header. wi

php - Mysql date created (not to update when record updated) -

i'm doing mysql table , have 1 column has current timestamp on update. great because can see when uploads something. dont want column change when edit upload. best stick 1 column named "date created" , have no on update or go 2 columns "date created & "date modified" - if whats best practice column attributes, , php update statements? i have separate "createdate" , "lastmodifieddate". as setting it, nice if set default value createdate column now() , mysql doesn't allow that . so, easiest option use insert trigger it: create trigger tbl_insert before insert on `tbl` each row set new.createdate = now(), new.lastmodifieddate = now(); eta: you can use timestamp field default value of current_timestamp , on update current_timestamp constraint lastmodifieddate well. unfortunately can't have 2 such timestamp columns on same table, trigger necessary handle createdate column.

xaml - WPF application pages settings properties on outer window -

i'm building application in wpf. interface structured microsoft's zune software . there menu @ top; each menu item correspond page, , each page have submenu , whatever controls needs. however, want menu, submenu, , background color declared on window, have colors of elements specified each page. what's best way have each page specify properties window contains it? create different resource dictionary each page colors/styles page. @ top of each page, reference appropriate resource dictionary.

asp.net - Enable/disable button template of gridview -

how enable delete button if user have modify data in gridview <edititemtemplate> <div class='actions'> <asp:button id="btnupdate" runat="server" text=" update " tooltip="update row" commandname="update" />&nbsp;&nbsp;&nbsp;&nbsp; <asp:button id="btncancel" runat="server" text=" cancel " tooltip="cancel row" causesvalidation="false" commandname="cancel" /> </div> </edititemtemplate> please use code. in source file <asp:commandfield showeditbutton="true" showcancelbutton="true" headertext="edit / delete" itemstyle-width="8%" showdeletebutton="true" itemstyle-horizontalalign="left" headerstyle-horizontalalign="left" /> in cs file protected void gvstatmeasures_rowediting(objec

iphone - Video capture using AVFoundation does not capture any audio -

i'm using following code capture movie file. unfortunately not capture audio. need route microphone session additional input? read somewhere each session can have 1 input? not sure how go this. // create session session = [[avcapturesession alloc] init]; session.sessionpreset = avcapturesessionpresetmedium; input = [avcapturedeviceinput deviceinputwithdevice:[self backfacingcamera] error:nil]; audioinput = [avcapturedeviceinput deviceinputwithdevice:[self backfacingcamera] error:nil]; if(!input){ nslog(@"couldn't create input!"); } output= [[avcapturemoviefileoutput alloc] init] ; [session addinput:input]; [session addoutput:output]; [session startrunning]; you need add audioinput input session. also, current code shows audioinput pointing camera. needs point audio device. like: nsarray *devices = [avcapturedevice deviceswithmediatype:avmediatypeaudio]; [[avcapturedeviceinput alloc] initwithdevice:[devices objectatindex:0] error:nil];

iphone - UDP communication with some interface (using UDP Echo sample code, problem with main.m) -

i´ve downloaded udpecho sample code apple make simple udp "connection" device.. i´m able make "connection" setting ip , port of device on main.m provided. analyzing console i´m getting positive response device i´m sending main.m. my problem main.m doesn´t load .xib. have tried modify , put uiapplicationmain (argc,argv,nil,nil) , stuff, in case got default .xib (with prjctviewcontroller ) load don´t response on console. in case there no udp connection @ all. how can use udpecho sample set simple udp "connection" user interface? simple user being able enter ip , port , getting response device shown in screen. communication not problem, i´m getting responses in console, whole problem setting simple interface while using sample code. don´t know how can "override" main.m load .xib while maintaining connection. i´ve tried pass functions main.m prjctviewcontroller doesn´t seem solve problem. if has example show me or ideas enlighten me i´ll t

Android: IPhonish Tabs but displayed at the top -

i iphonish tab can't figure out how make display @ top instead of @ bottom. http://bakhtiyor.com/2009/10/iphonish-tabs/ thanks. <?xml version="1.0" encoding="utf-8"?> <tabhost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"> <linearlayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <radiogroup android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:checkedbutton="@+id/first" android:id="@+id/states"> <radiobutton android:id="@+id/first" android:background="@drawable/button_radio" android:width="80dip" andr

java - Proguard issues with jar files, how to find the missing jar? -

when try export apk proguard lot of errors (over 400) similar to: warning: org.codehaus.jackson.jaxrs.jsonmappingexceptionmapper: can't find superclass or interface javax.ws.rs.ext.exceptionmapper and org.codehaus.jackson.xc.datahandlerjsondeserializer$1: can't find superclass or interface javax.activation.datasource i using jackson json library , , errors seem related that. researching error found following proguards faq : if there unresolved references classes or interfaces, forgot specify essential library. proper processing, libraries referenced code must specified, including java run-time library. specifying libraries, use -libraryjars option. searching around on found lot of unanswered questions related this, general sense jar file using (in case jackon json) relying on more libraries , need added proguard's config file how. however, can't figure out how determine jars needed , are. warnings mention lot of different packages such javax.ws.

asp.net mvc 3 - Refresh partialview in _Layouts.cshtml -

i have following partial view: <span>login status</span> @{ if (viewbag.userid > 0) { @html.actionlink("log out", "logout", "home", null); } else { @html.actionlink("log in", "login", "home", null); } } it's pretend login status area. now, idea have appear in master page mvc site, appears on pages. here's how i'm rendering in _layout.cshtml file: <div id="login"> @{ html.renderpartial("loginstatus"); } </div> what i'd have is, when user clicks either "log in" or "log out" links, action performed (to log user in/out) , partial view refreshed - the rest of page left alone. at moment, when click of links, site navigates "home/login" or "home/logout". don't want render view, i'd refresh partial view, regardless of page i'm on. what suggested way this? cheers. ja

php - Wordpress: problem in loop -

so have following code: <?php query_posts("order=asc&cat=4"); ?> <?php if(have_posts()): while(have_posts()): the_post(); ?> <?php if(get_post_custom_values("show") != null): ?> <?php $categories = get_cat_id(get_the_title()); $url = get_category_link($categories); ?> <li class="thumb"> <a href=""><?php the_post_thumbnail(array(215,200)); ?></a> <h2><a href=""><?php the_title(); ?></a></h2> </li> <?php endif; ?> <?php endwhile; endif; ?> </ul> this code works, when have & - in title $categories = get_cat_id(get_the_title()); .. get_cat_id won't work, know work around? try get_category_by_slug instead. fetching id name of category messy, duplicates , characters, you've discovered.

ruby on rails 3 - jquery-ujs ajax events are not handled -

i'm trying implement ajaxy signup rails 3. i'm using jquery-ujs , remote form. access signup form $.get request, , displayed correctly. signup form remote: form_for @user, :remote => true, :html => {"data-type" => "html"} |f| in application.js, if ajax request getting form successful, i'm trying bind handler ajax events unobtrusive javascript: var load_remote_form = function(evt) { var href = $(this).attr('href'); // load form template $.get(href, {}, function(data) { $('body').append(data); $('form[data-remote]').bind("ajax:beforesend", function(e) { console.log("caught beforesend!"); }); }); evt.preventdefault(); }; $(document).ready(function() { $('a#signup').click(load_remote_form); }); chrome's development tools show event " ajax:beforesend " binded, never handled (i have nothing in javascript cons

Representing IPv4/IPv6 addresses in Oracle -

in oracle, appropriate data type or technique representing network addresses, addresses may ipv4 or ipv6? background: i'm converting table recording network activity, built using postgresql inet data type hold both v4 , v6 addresses in same table. no row contains both v4 , v6 addresses, however. (that is, record either machine's v4 stack, or machine's v6 stack.) in oracle, appropriate data type or technique representing network addresses, addresses may ipv4 or ipv6 there 2 approaches : storing only. storing conventional representation for storing only. ipv4 address should integer (32bits enough). ip v6, 128 bits, integer (which similar number(38)) do. of course, that's storing. approach takes view representation matter application. if 1 take opposite strategy, of storing conventional representation, 1 needs make sure ip v4 , ipv6 addresses have 1 conventional (string) representation. it's well-known ipv4. ipv6, there s

powershell - Convertto-HTML outputting pre/post content showing up as System.String[] instead of actual content -

i trying use powershell output table pre/post content , email it, pre/post content showing in email "system.string[]." rest of content seems fine, , if output html string console, looks fine. function send-smtpmail($to, $from, $subject, $smtpserver, $body) { $mailer = new-object net.mail.smtpclient($smtpserver) $msg = new-object net.mail.mailmessage($from,$to,$subject,$body) $msg.isbodyhtml = $true $mailer.send($msg) } $content = get-process | select processname,id $headerstring = "<table><caption> foo. </caption>" $footerstring = "</table>" $myreport = $content | convertto-html -fragment -precontent $headerstring -postcontent $footerstring send-smtpmail "my email" "from email" "my report title" "my smtp server" $myreport shows in email as: system.string[] processname id ... ... system.string[] doing out-file , invoke-item has same results sending emai

Python / Django Queries - Append Raw SQL To Model Object -

i want add raw sql django model object. query in sql perform without writing entire thing. raw sql is: select * elements order if(elements.order=0, 99999, elements.order) asc basically, order elements order field if order value '0' ordered last. i have tried using extra() or appending raw() without great success... want able this: elements.objects.all().extra("order if(order=0, 99999, order)") ## or elements.objects.all().raw("order if(order=0, 99999, order)") any clue??? don't that. do this. results = list( element.objects.filter(whatever).exclude( order__isnull=true ).order_by( order ) ) results.extend( element.objects.filter(whatever).filter( order__isnull=false ) ) that avoid overly complex sql. try this. it's fast. may faster sql. def by_order( item ): return item.order if item.order not none else 2**32 results = list( element.objects.filter(whatever).all() ) results.sort( key=by_order )

c# - Entity Framework Code First CTP5 : How to define non primitive types -

i'm testing ctp5 entity framwork code first, , i've run problem i've got class has property of type uri (system.uri), looks it's unable automatically identify how store that, error like problem in mapping fragments starting @ line 23:no mapping specified properties webpage.uri in set webpage how can tell model map uri varchar, example, url of uri?? the actual poco model has bind primitive types. can use complex type binding such as: [complextype()] public class urihelper { public string stringrepresentation {get;set;} public uri actualuri() { return new uri(stringrepresentation); } } and in actual object reference complex type uri reference if absolutely need to. mapping reference property actual value string. final option create custom mapping uri string , vice versa ef engine use. however, not advise this. actual database property of type varchar or nvarchar, not uri. ef doesn't know uri is.

github - Using git for plugin development -

similar questions have already been asked , although they're not i'm trying do. at first thought needed git submodule, set superproject , sub tree merge i'm not sure if of these fit. i have project (eva), , i'm writing extensions it optional . if pull down copy eva github, wouldn't contain optional plugins fetch them separately , use them. the optional extensions reside in same directory structure eva. simple far ... eva | --- system/ --- events/ | --- core_events --- tests/ | --- core_tests extension | --- events/ | --- [extension a] --- tests/ | --- [extension tests] i wanted add tests extensions tonight, , @ present have them in separate directory outside of local eva git repo. in order run these tests need these extension live in same directory eva, events rely on core system run. eva | --- system/ --- events/ | --- core_events --- [extension a] --- [extension b] --- tests/ | --- core_tests

ruby on rails - setting activerecord attribute based on virtual attributes -

i have attribute called dimensions want set based on width , height , , depth attributes. for example, want shippingprofile.find(1).width = 4 , , have save dimensions {:width => 4, :height => 0, :depth => 0}` is possible? class shippingprofile < activerecord::base after_initialize :set_default_dimensions serialize :dimensions, hash attr_accessor :width, :height, :depth attr_accessible :width, :height, :depth, :dimensions private def set_default_dimensions self.dimensions ||= {:width => 0, :height => 0, :depth => 0} end end very so, need use callback set value of self.dimensions: class shippingprofile < activerecord::base after_initialize :set_default_dimensions after_validation :set_dimensions serialize :dimensions, hash attr_accessor :width, :height, :depth attr_accessible :width, :height, :depth, :dimensions private def set_default_dimensions self.dimensions ||= {:width => 0, :height

iphone - how can i set part of the view appear at its child view -

on child view, set backgroundcolor picture have transparent part. [viewdown setbackgroundcolor:[[uicolor alloc] initwithpatternimage:[uiimage imagenamed:@"background_down.png"]]]; the transparent part don't have parent view's background, black color instead. how can this. thanks. set opaque property no . viewdown.opaque = no;

java - How to Track Changes with jexcelapi or Apache HSSF -

i writing ms excel file java , set "track changes" flag can see people make modifications later. how can set flag in either jexcelapi or apache hssf? i don't think jexcelapi supports feature. viable set excel workbook option set, , use existing file template, instead of creating new workbook scratch?

jquery - JavaScript Function Queue -

i have ton of functions need run in succession, not before other has completed. need way queue these functions run after previous function completed. ideas? function1(); function2(); function3(); function4(); function5(); you use this: var functionqueue = (function(){ var queue = []; var add = function(fnc){ queue.push(fnc); }; var gonext = function(){ var fnc = queue.shift(); fnc(); }; return { add:add, gonext:gonext }; }()); and use this: var fnc1 = function(){ window.settimeout(function(){ alert("1 done"); functionqueue.gonext(); }, 1000); }; var fnc2 = function(){ window.settimeout(function(){ alert("2 done"); functionqueue.gonext(); }, 5000); }; var fnc3 = function(){ window.settimeout(function(){ alert("3 done"); functionqueue.gonext(); }, 2000); }; functionqueue.add(fnc1); functionqueue.a

php - Why it always say: Undefined index: User -

it says same error defined user variable. used can print user name of user , other details of user logged in restricted page. code when logging in: <?php require_once('../connections/intranet.php'); ?> <?php if (!function_exists("getsqlvaluestring")) { function getsqlvaluestring($thevalue, $thetype, $thedefinedvalue = "", $thenotdefinedvalue = "") { .... } mysql_select_db($database_intranet, $intranet); $query_recordset1 = "select * useraccounts"; $recordset1 = mysql_query($query_recordset1, $intranet) or die(mysql_error()); $row_recordset1 = mysql_fetch_assoc($recordset1); $totalrows_recordset1 = mysql_num_rows($recordset1); ?><?php // *** validate request login site. if (!isset($_session)) { session_start(); } $loginformaction = $_server['php_self']; if (isset($_get['accesscheck'])) { $_session['prevurl'] = $_get['accesscheck']; } if (isset($_post['user'])) { $

iphone - How can I use a UITextfield to call "when clicked" a UITableview -

textfield call when clicked uitableview, return calling textfield value of string value of cell selected in uitableview? sorry have searched , googled , still can't seem find guidance. iphone app only, can't utilise popovers is possible? when select row table insert 1 more row(cell) in table(next selected cell) having uitextfield part of context! this method call on selection of cell - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {} you can remove cell once text entries finished!, add event on uitextfield. events name-uicontroleventeditingdidend || uicontroleventeditingdidendonexit

java - Transaction Issue -

i'm using java , mysql database. i'm running multiple instances of application. i'm selecting 1 record database , @ same time after fetching, i'm updating status "in process" no other instances can access record. but happens instances running fast that, when 1 instance accessing 1 record, other instance accessing same record before update done "in process" first instance. should update takes place before other instance can access it? have used conn.settransactionisolation(conn.transaction_read_committed) in code, not helping. thanks in advance. you need select update type of statement. http://dev.mysql.com/doc/refman/5.0/en/innodb-locking-reads.html

php - versioning of the content -

i developing php/mysql package add/edit questionnaire.. want pakage save versions of edits of questions , rollback previous version. can suggest such package..? the propelorm has versionable behavior that. behavior versionable . although might suggest try approach problem differently.

java - How to communicate between mobile with PC? -

i developing program used communicate between mobile , pc. don't have idea how start? to need write 2 separate pieces of software: 1) server 2) client i suggest install server on pc , client on phone. the client establish tcp connection server , able send messages reliably. upon receiving messages client (phone) server (pc) act accordingly. you can refer java documentation find 2 simple samples creating tcp servers , clients , these should helpful. example link

image - Huffman code tables -

i didn't understand huffman tables of jpeg contain, explain me? thanks huffman encoding variable-length data compression method. works assigning frequent values in input stream encodings smallest bit lengths. for example, input seems every eel eeks elegantly. may encode letter e binary 1 , other letters various other longer codes, starting 0 . way, resultant bit stream smaller if every letter fixed size. way of example, let's examine quantities of each character , construct tree puts common ones @ top. letter count ------ ----- e 10 <spc> 4 l 3 sy 2 smvrkgant. 1 <eof> 1 the end of file marker eof there since have have multiple of 8 bits in file. it's stop padding @ end being treated real character. __________#__________ ________________/______________ \ ________/________ ____\____ e __/__ __\__