Posts

Showing posts from August, 2012

PHP - set all empty or null in an array, to 0, without a foreach loop -

i'm working large array. we're displaying fields of data in array table. fields in array null because user hasn't accumulated in field. however, wanted 0 when have such result. our solution display value along intval() intval(@$users[$user_id]['loggedin_time']) which fine, ugly , inelegant. there way, without foreach loop, set values of '' in array 0? yes, array_map : $input = array(...); $output = array_map(function($item) { return $item ?: 0; }, $input); the above example uses facilities of php >= 5.3 (inline anonymous function declaration , short form of ternary operator), can same in php version (only perhaps more verbosely). you should think bit conditional inside callback function; 1 'm using here replace values evaluate false booleans zeroes (this include empty string, includes e.g. null values -- might want tweak condition, depending on needs). update: php < 5.3 version it's either this: function callback(...

c - Mac OS X: Extending a shared library by adding a function -

i extend shared c library (dylib) on mac os x adding function. let's call function const char *get_string(void) . here approach: i created new shared library containing get_string(void) function , liked against library wanted extend. library wrapper speak. far good. next step link application against new extended library problem extended library export symbol _get_string not symbols of original library. that's why linking against "extended" library (instead of original library) produces lot of unresolved symbol warnings/error. is there way export symbols of original library (there lot) or there better approach solve problem. want extend existing library. btw have access original library's source can't recompile it. thanks in advance! how option ld: -reexport-lx same -lx specifies symbols in library x should available clients linking library being created. done separate -sub_library option. ...

Android Google weather data application source code giving error -

i've downloaded android app source code following link . i'm getting following error when i've imported project workplace. [2011-06-30 21:52:49 - com.android.ide.eclipse.adt.internal.project.androidmanifesthelper] unable read c:\android-sdk-windows\androidmanifest.xml: java.io.filenotfoundexception: c:\android-sdk-windows\androidmanifest.xml (the system cannot find file specified) [2011-06-30 21:52:49 - com.android.ide.eclipse.adt.internal.project.androidmanifesthelper] unable read c:\android-sdk-windows\androidmanifest.xml: java.io.filenotfoundexception: c:\android-sdk-windows\androidmanifest.xml (the system cannot find file specified) please 1 can me on this? instructions on how import project: download zip file. export zip file workspace. once have folder, open eclipse. at top: file -> new -> android project under contents click create project existing source under browse , navigate , click on folder called weathe...

Removing table lines and table space between cells in css -

i have site: http://redditlist.com/dir/1026 , i'm stuck on trying remove spacing between cells more this: http://redditlist.com . table#mytable{ border-collapse:collapse; }

asp.net mvc 3 - MVC3 Razor: Is it Possible to Render a Legacy ASCX? -

with razor view engine in mvc3, is possible render legacy ascx? i expecting able like: @html.renderpartial("footer.ascx") yes. try instead: @html.partial("footer") or @{ html.renderpartial("footer"); }

performance - Optimizing MySql query -

Image
i know if there way optimize query : select jdc_organizations_activities.*, jdc_organizations.orgname, concat(jos_hpj_users.firstname, ' ', jos_hpj_users.lastname) namecontact jdc_organizations_activities left join jdc_organizations on jdc_organizations_activities.organizationid =jdc_organizations.id left join jos_hpj_users on jdc_organizations_activities.contact = jos_hpj_users.userid jdc_organizations_activities.status 'proposed' order jdc_organizations_activities.creationdate desc limit 0 , 100 ; now when see query log : query_time: 2 lock_time: 0 rows_sent: 100 rows_examined: **1028330** query profile : 2) should put indexes on tables having in mind there lot of inserts , updates on tables . from tizag tutorials : indexes can enable on mysql tables increase performance,cbut have downsides. when create new index mysql builds separate block of information needs updated every time there changes made tab...

sql server - Convert text into db object and field identifier -

given select statement lists tables , columns, how convert table , column names identifiers can used in seperate select statement? in other words, if have string @table = 'person' , @column = 'name', want this: select datalength(max(t.@column)) longest, datalength(min(t.@column)) shortest @table t; of course not accomplish want. want know length of longest , shortest string stored in column. if wanted information single column, there no need use these stringified-variables. want every (varchar) column across database. life short create every sql statement accomplish this. why want parametric mechanism specifying table , column. how fix achieve goal? of course going wrong. perhaps should address each column index, , convert column name when output needed. thoughts? declare @sql varchar(999) declare @col varchar(50) declare @table varchar(50) set @col = <colname> set @table = <tablename> set @sql = ' select datale...

vb.net - ASP.Net Session variables - struggling with the Cache -

i'm using session variables store , pass data across several pages of asp.net application. behavior bit unpredictable though. i'm setting session variable post page_load follows protected sub page_loadcomplete(byval sender object, byval e system.eventargs) handles me.loadcomplete if (session.item("scholarshipid") = nothing) session.add("scholarshipid", "summer2011") end if ok far good, on normal page load. if user completes form action, hits next page, , decides oh no, needed change field xyz, , clicks back, corrects data, submits, session variable showing null. why cached session behave way? i'm not destroying/clearing variable, unless fail understand scope of session variables. try if (isnothing(session("scholarship"))) session("scholarship") = "summer2011" end if

javascript - Find out if HTC phone enters a mobile app -

i know code redirect blackberries; if ((/blackberry/i.test(navigator.useragent))) { //send mobile page (blackberries) window.location = ("../default.aspx"); } but use replace blackberry htc phones? i looked here there seems different ones every phone. there single call use? edit c# way detect work too. along lines of this: if (request.headers["user-agent"] != null && (request.browser["ismobiledevice"] == "true"){ if(request.browser ["blackberry"] == "true") { if(int.parse(request.browser.version) < 4.5) { //this how blackberry version right? } } else if(request.useragent.toupper().contains("htc")) { } } to find if phone htc server side this: if(request.useragent.toupper()...

Pick multiple dates one by one with Jquery/Datepicker -

i have form , on form have datepicker. when clicks select dates field datepicker pops , shows multiple months. there person click individual dates, each click date selected gets appended form field comma seperated. im looking jquery solution, right im looking at: http://jqueryui.com/demos/datepicker/#multiple-calendars the problem when select date datepicker closes date selected shows in form field. want datepicker continue show while select multiple dates , dates selected stay highlighted, click done when done selecting dates. can point me how can accomplish or there pre-existing jquery code that? try out plugin (demo near bottom of page): http://multidatespickr.sourceforge.net/

Html Agility Pack/C#: how to create/replace tags? -

the task simple, couldn't find answer. removing tags (nodes) easy node.remove()... how replace them? there's replacechild() method, requires create new tag. how set contents of tag? innerhtml , outerhtml read properties. see code snippet: public string replacetextboxbylabel(string htmlcontent) { htmldocument doc = new htmldocument(); doc.loadhtml(htmlcontent); foreach(htmlnode tb in doc.documentnode.selectnodes("//input[@type='text']")) { string value = tb.attributes.contains("value") ? tb.attributes["value"].value : "&nbsp;"; htmlnode lbl = doc.createelement("span"); lbl.innerhtml = value; tb.parentnode.replacechild(lbl, tb); } return doc.documentnode.outerhtml; }

Pass php object to different script in magento -

i have php script that's called in xml show on product page tab. i need able to retrieve attributes of current product shown in script well. example: <?php echo $_product->getsku() ?> does 1 have idea how pass object, or retrieve current products id/attributes? thanks much you can use json_encode($object) output json , json_decode($text) put object later. there other way, depending wanna do. more specific?

Cocoa Framework for copying media to iTunes? -

is there cocoa framework of perhaps way programatically copy movies itunes, itunes recognises them? found answer: add movie itunes using scripting bridge

Google Maps for ASP.NET c# -

is there google maps api c# use in asp.net application? i've seen posts , resources javascript api , wondering if there c# version.... thanks i use 1 asp.net site: googlemap it seems work pretty well edit: here couple more have not used subgurim googlemaps shabdar - has tutorial it

javascript - Correct way to refer to class/instance rather than object literal property? -

i have object 'foo', object literal property, shown below. inside property, i'd refer object 'foo' rather object literal itself. can done hacks, ie, referring object variable name? or there better way? example below - should print 'woo' on success. class foo myfunc: => console.log('woo') testthing: { 'foo':'bar' 'baz':'boo' 'bop': => @myfunc() } window.foo = new foo foo.testthing.bop() class foo constructor: -> @testthing = 'foo':'bar' 'baz':'boo' 'bop': => @myfunc() myfunc: => console.log('woo') declaring testthing in constructor allows @myfunc bound 'instance' rather 'class'. you use 'bop': @myfunc instead of 'bop': => @myfunc() pass along arguments :)

android - LayoutInflater doesn't seem to be linked with id in layout -

i lost layoutinflater . trying link items in code items located in remote layout. have tried 3 different versions of inflater creation. none of them work. however, version seems used. here snippet of inflater garble: setcontentview(r.layout.browse); layoutinflater li = (layoutinflater) this.getsystemservice(context.layout_inflater_service); final imagebutton editbrowsebutton = (imagebutton) li.inflate(r.layout.row, null).findviewbyid(r.id.imagebutton1); editbrowsebutton.setalpha(50); this feels kinda missing something. need return something? .setalpha has no meaning. put in test inlater. obviously, doesn't change transparency. , if add onclicklistner, doesn't work. however, don't exception. activity starts fine. here relevant xml code row.xml: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linearlayout1" android:orientation="h...

c++ - initalizer problem with plugins. a test -

i had longer more complicated question , have code http://www.ideone.com/veovp however i'll simplify it. there wrong code below , there better way below? i worried line std::list<plugin*>& plugins , how set while keeping reference. i'll let guys pick code apart. #include <list> #include <string> class plugin{ public: static std::list<plugin*>*plugins; std::string name; plugin(const std::string&n) : name(n) { static std::list<plugin*> plugins; this->plugins=&plugins; plugins.push_back(this); } }; //main.cpp #include "plugin.h" class plugin1 : public plugin{ public: plugin1():plugin("1"){} }; static plugin1 plugin; std::list<plugin*>* plugin::plugins; std::list<plugin*>& plugins = *plugin::plugins; //global name plz int main(){ for(auto c=plugins.cbegin(); c!=plugins.cend(); ++c) { printf("%s\n", (*c)->name.c_str()); ...

actionscript 3 - Flex 4 remove selected item from spark DropDownList -

my stakeholder has request remove selected item dropdownlist control(s) in application. example drop down [item1, item2, item3, item4] if item2 selected items in drop down [item1, item3, item4] any thoughts on if possible , if how implement appreciated. thanks in advance. using flash builder 4 flex 4.0 sdk as long dropdown list uses arraycollection data provider, can specify filter function remove current selected entry: <s:application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" creationcomplete="oncreationcomplete()"> <fx:script> <![cdata[ [bindable] private var _yourac:arraycollection = new arraycollection(['item 1', 'item 2', 'item 3']); private function oncreationcomplete():void { _yourac.fi...

android - How to create custom title bar with back button and title? -

i want make slick gui application. how go creating cusom title bar button? , there tools make custom buttons in android? or make gui? there books talk heavely android gui's? i want make slick gui application. that's nice. but how go creating cusom title bar button? no sensible android developer puts "a button" on screen, since os provides button user. be careful when doing custom title bars right now. android title bar morphing honeycomb "action bar" android 3.x, , there decent chance ice cream sandwich give phones "action bar" well. while can style action bar , lots of slick things it, has structure should adhered to, android applications can have consistent , feel. if make phone apps dependent on radically different sort of "custom title bar", may ux complaints users. that being said, find easiest way "custom title bar" rid of existing title bar (e.g., android:theme="@android:style/theme.not...

c++ - WinAPI window doesn't appear -

and can't figure out why. code: #include <windows.h> #include <commctrl.h> #include <cstdio> #include <stdarg.h> #include <string> #include <cmath> #include <vector> #include "resources.hpp" using std::string; using std::vector; struct undostruct{ /* add later */}; char buffer[2048]; hwnd statusbar; hinstance hinst; vector<undostruct> undo; void show_error(const char* format,...){ va_list args; va_start(args,format); vsprintf(buffer,format,args); va_end(args); messagebox(null,buffer,"error",mb_ok);} hwnd create_tooltip(hwnd parent,char* tip,unsigned uid,unsigned extraflags=0){ hwnd tt=createwindowex(ws_ex_topmost,tooltips_class,null,ws_popup|tts_noprefix|tts_alwaystip,0,0,0,0,parent,null,null,null); setwindowpos(tt,hwnd_topmost,0,0,0,0,swp_nomove|swp_nosize|swp_noactivate); toolinfo ti; ti.cbsize=sizeof(toolinfo); ti.uflags=ttf_subclass|extraflags; ti.hwnd=...

add image and description on facebook with sharekit -

Image
i using sharekit share text on facebook, want add picture near text in photo : any idea how this? , there other suitable library sharekit ? thanks. add og:image meta tag head html block. http://developers.facebook.com/docs/reference/plugins/like/

ios - XCode Organizer Device Console Length -

i have device used in field errors occurred. want able read console logs on device determine error. unfortunately appears xcode organizer show smaller portion of log file because log messages several weeks ago not appearing. there other way access full contents of log or extend buffer size in xcode? do backups contain console logs? not sure. can find them in itunes->preferences->devices you can write messages log file , print directly that, there long let them (buyer beware).

c# - Parsing Mac XML PList into something readable -

i trying pull data xml plist ( apple system profiler ) files, , read memory database, , want turn human-readable. the problem format seems difficult read in consistent manner. have gone on few solutions already, haven't found solution yet found satisfying. end having hard code lot of values, , end having many if-else/switch statements . the format looks this. <plist> <key>_system</key> <array> <dict> <key>_cpu_type</key> <string>intel core duo</string> </dict> </array> </plist> example file here . after have read (or during reading), make use of internal dictionary use determine type of information is. example, if key cpu_type save information accordingly. a few examples have tried ( simplified ) pull information. xmltextreader reader = new xmltextreader("c:\\test.spx"); reader.xmlresolver = null; reader.readstartelement("plist"...

c++ - boost::thread undefined reference -

i installed boost libraries , trying use multi - threading. copied example boost library example. getting error: undefined reference boost::thread::join() here code, #include <boost/thread.hpp> #include <boost/thread/xtime.hpp> #include <iostream> struct thread_alarm { thread_alarm(int secs) : m_secs(secs) { } void operator()() { boost::xtime xt; boost::xtime_get(&xt, boost::time_utc); xt.sec += m_secs; boost::thread::sleep(xt); std::cout << "alarm sounded..." << std::endl; } int m_secs; }; int main(int argc, char* argv[]) { int secs = 5; std::cout << "setting alarm 5 seconds..." << std::endl; thread_alarm alarm(secs); boost::thread thrd(alarm); thrd.join(); } which compiler? try if gcc $ g++ -o ./app.out ./source.cpp -lboost_thread if running on windows, perhaps have make sure pthread have installed, , have tell...

system calls - What's the design principle of syscall? -

how linux determine functionality should classified syscall while others can directly implemented in user space? a system call performed when processing must occur in kernel - meaning requires escalated privileges or access kernel-private resources. typically if can kept in userspace, it's done there. there performance reasons when things moved kernel processing, , therefore require system call perform. facet transition between userspace , kernelspace relatively expensive.

bash - Running monit as a restricted user and making it watch a process that needs root privileges -

i have specific script written in ruby needs root privileges. of other processes don't need , easy setup in monit. not one. the server needs listen @ 386, , port available root. won't details of why, because 1) i'm not low-level kind of guy, 2) worked fine far when using sudo. the monit configuration file simple , looks this: set logfile syslog facility log_daemon # default facility log_user set mailserver smtp.sendgrid.net username "blah", password "blah" timeout 20 seconds set alert blah@bleh.com set logfile /home/deploy/monit.log check process ldapserver pidfile /var/pids/ldap_server.pid start program = "/usr/local/bin/ruby /var/lib/ldap_server.rb" stop program = "/bin/sh" note: i've put /bin/sh in stop program because there's not stop program process. if put this: start program = "/usr/local/bin/ruby /var/lib/ldap_server.rb" it fails start. no hints. start prog...

performance - Making a C code run faster -

i have written piece of code used counting frequency of numbers between 0 , 255. unsigned char arr[4096]; //aligned 64 bytes, filled random characters short counter[256]; //aligned 32 bytes register int i; for(i = 0; < 4096; i++) ++counter[arr[i]]; it taking lot of time execute; random access counter array expensive. does have ideas use either make accesses sequential or other approach use? what makes think random access counter array expensive? have profiled? try valgrind, has cache profiling tool called "cachegrind". profiling lets know if code slow or if think slow because ought be. this simple piece of code , before optimizing important know whether memory bound or if not memory bound (w.r.t. data, not histogram table). can't answer off top of head. try comparing simple algorithm sums entire input: if both run @ same speed, algorithm memory bound , done. my best guess main issue slow down this: registers ...

asp.net mvc 3 - How to update a model that contains a list of IMyInterface in MVC3 -

i have model so: return new myviewmodel() { name = "my view model", modules = new irequireconfig[] { new fundraisingmodule() { name = "fundraising module", generalmessage = "thanks fundraising" }, new donationmodule() { name = "donation module", mindonationamount = 50 } } }; the irequireconfig interface exposes dataeditor string property view uses pass @html.editorfor so: @foreach (var module in model.modules) { <div> @html.editorfor(i => module, @module.dataeditor, @module.dataeditor) //the second @module.dataeditor used prefix editor fields </div> } when post controller tryupdatemodel leaves modules property null. pretty expected s...

java - How can I parse UTC date/time (String) into something more readable? -

i have string of date , time this: 2011-04-15t20:08:18z . don't know date/time formats, think, , correct me if i'm wrong, that's utc format. my question: what's easiest way parse more normal format, in java? what have iso-8601 date format means can use simpledateformat dateformat m_iso8601local = new simpledateformat("yyyy-mm-dd't'hh:mm:ss'z'"); and can use simpledateformat.parse() . also, here blog post examples might help. update: read comments below before using solution.

osx - Are there APIs or other methods to communicate with Mac OS X and iOS(iPhone and iPad)? -

i want know whether there apis or other methods communicate mac os x , ios. have googled problem , found no results. moreover, said there no official support it. appreciated:) you can use network protocol bonjour zmodem communicate between ios device , mac. http is, of course, 1 popular choice. bonus, options work equally talk devices running windows , unix-y operating systems.

c# - Automapper to create object from XML -

if have following class: class spuser { public int id { get; set; } public string name { get; set; } public string loginname { get; set; } public string email { get; set; } public bool issiteadmin { get; set; } public bool issiteauditor { get; set; } public bool isdomaingroup { get; set; } public list<spgroup> groups { get; set; } } and using sharepoint web services, return xml attribute each property on class, such as: <users> <user name="name" description="desc" ..... /> </users> is there way use automapper map xml fragment spuser class instance? blog has been deleted - here's bing archive of post @dannydouglass simplify using xml data automapper , linq-to-xml i ran scenario @ work required manually consuming several soap web services, i’m sure can imagine rather monotonous. co-worker (seth carney) , tried few different approaches, settled on solution simplified consumpti...

c# - Object reference not set to an instance of an object in dynamic Linq-to-Sql where clause -

well using dynamic linq extension library iqueryable type of collection. collection of iqueryable. , apply cluase on when enumberate throws exception of null reference. please @ below stack trace. iqueryable<t> returndata = source.where(advancesearchparameter.advancesearchtext, advancesearchparameter.advancesearchvalue); where extension method come dynamic extention library. here source object of type iqueryable<t> , getting error when returndata gets executed(enumerate). have tried setting visual studio break when exception thrown? go debug > exceptions... , check bow under "thrown" next "common language runtime exceptions". hopefully break somewhere can see null.

Joomla virtuemart theme modification -

i presently working on joomla website having ecommerce functionality. beginner in joomla. need modify virtuemart theme according own css , html. how possible? simply head your_joomla_directory/components/com_virtuemart/themes/your_theme_folder/theme.css theme.css edits virutemart elements only, may have edit main template css file full desired effect.

iphone - setting a default value for slider when app loads -

Image
in iphone app i'm using slider adjusting volume , working fine. i'm not able set default value slider when app loads. have seen when slider touched value gets changed.but need default value when app loads. code given below - (ibaction)sliderchanged:(id)sender { slider = (uislider *) sender; slider.minimumvalue = 0.5; slider.maximumvalue = 2.2; progressasint = slider.value ; } how can solve issue. please help.thanks in advance. there 2 ways change default value of slider. using interface builder. see attached picture , value of current property. using code you need write 1 line in viewwillappear delegate method. -(void)viewwillappear:(bool)animated{ slider.value = 1.0; } hope help.

What's the best way to store "spreadsheet data" in MySQL -

i'm looking store spreadsheet type data in mysql database. grid, x/y coordinates, , each cell can have various different properties it. the grids can of different sizes, , i'd system fast , flexible, though sort of caching isn't out of question if necessary. finally, requirement of project use mysql, , restriction against document style storage solutions(anything nosql really). i'm curious if has sort of standard solution i'm not seeing. i'd avoid big table along lines of column1_data1 column1_data2 column1_data3 etc etc many columns can safely account for. sounds job entity-attribute-value model

visual studio 2008 - CUDA not working in 64 bit windows 7 -

Image
i have cuda toolkit 4.0 installed in 64 bit windows 7. try building cuda code, #include<iostream> #include"cuda_runtime.h" #include"cuda.h" __global__ void kernel(){ } int main(){ kernel<<<1,1>>>(); int c = 0; cudagetdevicecount(&c); cudadeviceprop prop; cudagetdeviceproperties(&prop, 0); std::cout<<"the name is"<<prop.name; std::cout<<"hello world!"<<c<<std::endl; system("pause"); return 0; } but operation fails. below build log: build log rebuild started: project: god, configuration: debug|win32 command lines creating temporary file "c:\users\t-sudhk\documents\visual studio 2008\projects\god\god\debug\bat0000482007500.bat" contents [ @echo off echo "c:\program files\nvidia gpu computing toolkit\cuda\v4.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" -gencode=arch=compute_20,code=\"sm_20,compute_...

android - Periodic Message in Thread -

i have activity (myactivity) , thread (mythread) , both handler allow me send message between ui thread , mycustomthread. call periodically (10sec) alive message of mythread thread myactivity. how can achieve ? myactivity : public void onresume() { super.onresume(); this.thread = new mythread(activityhandler); this.threadhandler = this.thread.gethandler(); threadmessage = this.threadhandler.obtainmessage(); threadmessage.what = auth; this.threadhandler.sendmessage(threadmessage); } mythread : @override public void run() { looper.prepare(); this.threadhandler = inithandler(); this.message = this.activityhandler.obtainmessage(); this.message.what = connected; activityhandler.sendmessage(this.message); looper.loop(); } private handler inithandler() { return new handler() { public void handlemessage(message msg) { switch(msg.wha...

internet explorer - What's the most efficient and reliable method to test CSS design in multiple legacy browsers? -

i'd interested hear professional developers think this, particularly frontend developers. how go testing designs in multiple browsers? use virtual machines, each different version of internet explorer installed? setup/workflow? so, what's efficient , reliable way test design in several legacy web browsers? thank you. i use spoon virtualization . removed ie service aftyer microsoft told them it's still service testing other browsers/versions. for ie tend use microsoft provided ie vms . if need virtualization product virtualbox pretty , free. i've discovered browserling similar spoon virtualization , has support multiple ie versions.

Abraham Williams Twitter oAuth PHP Callback Issue -

i building app using abraham william's twitteroauth package. app working fine, except running 1 problem. about 25% of users try install app cannot so. verify application on twitter page , click "sign in" (on twitter's website). when referred callback.php page, gives them blank page. cannot figure out wrong, because works users. ideas? here callback.php code: <?php require_once("config_db.php"); session_start(); // include class & create require_once("consumer-keys.php"); require_once("twitteroauth/twitteroauth/twitteroauth.php"); // user has selected deny access if(!empty($_get["denied"])) { // re-direct or display cancelled view/template // we're echoing out message echo "no deal! <a href='login.php'>try again?</a>"; die(); } // user has selected allow access given token if($_get["oauth_token"] == $_session["oauth_token"]) { // use generated req...

r - How to bind function arguments -

how partially bind/apply arguments function in r? this how far got, realized approach doesn't work... bind <- function(fun,...) { argnames <- names(formals(fun)) bindedargs <- list(...) bindednames <- names(bindedargs) function(argnames[!argnames %in% bindedargs]) { #todo } } thanks! have tried looking @ roxygen's curry function? > library(roxygen) > curry function (fun, ...) { .orig = list(...) function(...) do.call(fun, c(.orig, list(...))) } <environment: namespace:roxygen> example usage: > aplusb <- function(a,b) { + + 2*b + } > oneplusb <- curry(aplusb,1) > oneplusb(2) [1] 5 edit: curry concisely defined accept named or unnamed arguments, partial application of fun arguments way of formal() assignment requires more sophisticated matching emulate same functionality. instance: > bind <- function(fun,...) + { + argnames <- names(formals(fun)) + boundargs <- list(...

tabactivity - Four classes in one tabber in Android? -

i want uitabbarcontroller in iphone, have 4 classes , want work them in 1 tabber as click first tab, first class should show click second tab, second class should show click third tab, third class should show click fouth tab, fourth class should show what best , easy way manipulate such conditions, new android developement , first app if not clear question, may ask again ... the android dev site has example you're looking for. http://developer.android.com/resources/tutorials/views/hello-tabwidget.html there code examples. you'll need make tab layout xml file, edit main.xml , in java code, each tab you'll have this intent = new intent().setclass(this, albumsactivity.class); spec = tabhost.newtabspec("albums").setindicator("albums", res.getdrawable(r.drawable.ic_tab_albums)) .setcontent(intent); tabhost.addtab(spec);

asp.net mvc 3 - Mvc3 - Best practice to deal with data which are required for (almost) all requests? -

i creating application in mvc3 , wondering how deal database data required application requests, of them depends on session, of them depends on url pattern data in database. like know best practice what in applications , consider best practice load common data viewbag on controller constructor. for every project, have defaultcontroller abstract class extends controller. so, every controller in project must inherit defaultcontroller, instead of controller. in class' constructor, load data common whole project, so: // defaultcontroller.cs public abstract class defaultcontroller : controller { protected irepository repo { get; private set; } protected defaultcontroller(irepository repo) { repo = repo; viewbag.currentuser = getloggedinuser(); } protected user getloggedinuser() { // logic retrieving data here } } // homecontroller.cs public class homecontroller : defaultcontroller { public homecontroller(irep...

ios - Is it possible speed up the drop of annotation in MKMapView? -

i have 30 annotations in map , want speed dropping animation. is possible speed drop of annotation in mkmapview or drop of them @ once? you'll need implement own drop animation in didaddannotationviews delegate method. should set animatesdrop no avoid possible double animation. - (void)mapview:(mkmapview *)mapview didaddannotationviews:(nsarray *)annotationviews { nstimeinterval delayinterval = 0; (mkannotationview *annview in annotationviews) { cgrect endframe = annview.frame; annview.frame = cgrectoffset(endframe, 0, -500); [uiview animatewithduration:0.125 delay:delayinterval options:uiviewanimationoptionallowuserinteraction animations:^{ annview.frame = endframe; } completion:null]; delayinterval += 0.0625; } } this drops annotations @ rate specify. to drop them @ once, hard-code delay param...