Posts

Showing posts from March, 2014

javascript - Adding Classes Based on Positive/Negative and Position -

i'm trying find way add class td based on whether it's positive or negative, not within first <tr> , not within first <td> of <tr> . i can't find on either issue through searching. know how this? you mean if <td> contains positive or negative number? if that's you're trying do, use this: $(document).ready(function() { $("tr:not(:first)").find("td:not(:first)").each(function() { if ($(this).text() > 0) $(this).addclass("positive"); else if ($(this).text() < 0) $(this).addclass("negative"); }) }); i tested on following table , worked fine: <table> <tr> <td>3</td> <td>9</td> <td>-3</td> </tr> <tr> <td>8</td> <td>-4</td> <td>9</td> </tr> <tr> <td>-7</td> <td>12</td> <td>144</td> </tr> </table>

asp.net mvc - Get through SiteMinder folder rule with MVC routing -

there siteminder rule placed in allow access "/public/*" pages unauthenticated users. in mvc folder structure there no physical folder (or area) called "public" , don̢۪t want should able add public pages freely in area. now, unauthenticated users not have access public pages (actions). need workaround through siteminder public pages. there 2 things in mind need find solution. rewrite routes prepending "/public" them (conditionally may based on authorized attribute) siteminder. once url received "/public" should routed proper area/controller/action ignoring "/public" portion of it. i still couldn̢۪t figure out way code above. if experts know how achieve above or have different thoughts please post. cheers, moosila finally question narrowed down "how can rewrite route adding "/public" after root , before area/controller/action?" i did poc achieve above of co-worker: using reflection obtain appropriate co...

C++ template param deduction is not working -

i need override connection between boost::signals2::signal , boost::function . purpose i've created following template function: template<typename t> void bind(boost::signals2::signal<t> &signal, boost::function<t> function) { // override code ... } i want make use of bind simple can be. i've read in posts on similar issues, template parameter should deduced function arguments. in case when there's no explicit parameter it's not working. boost::signals2::signal<void ()> my_signal; bind<void ()>(my_signal, boost::bind(&a::func, this)); // works bind(my_signal, boost::bind(&a::func, this)); // error: no matching function call am missing something? can there workaround avoid explicit template parameter? the second argument type not std::function<t> , bind type, compiler unable deduce t second function parameter. need tell compiler "you ok not finding type t in second function parameter". can done making...

objective c - Storing large amount of information to be generated before run-time -

i'm developing tour application storing , displaying information different sights , sculptures, , i'm investigating different options store information. all of content generated before runtime , , nothing generated @ runtime. i'm looking convenient way write/generate it , such fetching information spreadsheet. therefore considering xml , csv , sqlite , core-data , or archiving . the content stored custom subclasses of nsobject , such tour class (nsobject subclass), instance variables such nsarray of sights (nsobject subclass) view, , *tourname (nsstring). i define content in - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil method of main view controller, i'm it's not efficient way. any suggestion welcome, advantages , disadvantages. also, core-data seemed best option, seemed me data generated programmatically @ runtime. or there way generate instances of entities in core-data before run-time ? thank you. you can generat...

android - Accessing Method from Interface Throwing Conversion Error -

public class newcallinfo { public string site { get; set; } public string customername { get; set; } public string customerphone { get; set; } public string customerext { get; set; } public string customeraddress { get; set; } public string customercity { get; set; } public string customerstate { get; set; } public string customerzip { get; set; } public string servicetype { get; set; } public string priority { get; set; } public string description { get; set; } public string technician { get; set; } public string serial { get; set; } public string model { get; set; } } public interface inewcall { newcallinfo getnewcallinfo(string site); } public class handlenewcall : inewcall { private sqlitehelper helper {get;set;} public handlenewcall(context context) { helper = new sqlitehelper(context); } public newcallinfo getnewcallinfo(string site) { string whereclause = string.format("where site='{0}'", site); icursor callcursor = _helper.readabledatabase.query("newcall...

android - How can I make the transparent part of an image not show up -

in android, animating 2 images 1 small on top of larger one. small generated using photoshop , visible part surrounded checkerboard pattern (which supposed transparent). when animation runs, images appear checkerboard patters shows grey square. how can make transparent. this how imagebutton setup in layout.xml <imagebutton android:layout_gravity="top|left" android:layout_marginleft="184dp" android:layout_margintop="55dp" android:id="@+id/videothumb" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/button_power_on" /> and animation file: <?xml version="1.0" encoding="utf-8"?> <alpha xmlns:android="http://schemas.android.com/apk/res/android" android:fromalpha="0.0" android:toalpha="0.8" android:duration="5000" android:repeatmode="reverse" android:repeatcount="infinite" /...

ios - How to set header values in Restkit -

i trying set header values restkit calls. however, these not seem work. i want set content-type , accept headers application/json any idea problem is? thanks! rkobjectmanager *objectmanager = [rkobjectmanager sharedmanager]; [[objectmanager client] setvalue:@"application/json" forhttpheaderfield:@"accept"]; [[objectmanager client] setvalue:@"application/json" forhttpheaderfield:@"content-type"]; rkurl *url = [rkurl urlwithbaseurl:[objectmanager baseurl] resourcepath:@"/users/sign_in.json" queryparameters:params]; [objectmanager loadobjectsatresourcepath:[nsstring stringwithformat:@"%@?%@", [url resourcepath], [url query]] delegate:self]; i don't think it's obvious, though in documentation (and haven't tried tbh) on object manager there serializationmimetype property. there's constant json defined, code like: objectmanager.serializationmimetype = rkmimetypejson; according docs, application/json de...

objective c - youtube video embed in iphone app but giving me white empty box -

Image
i trying embed youtube video in app , using function - (void)embedyoutube:(nsstring *)urlstring frame:(cgrect)frame { nsstring *embedhtml = @"\ <html><head>\ <style type=\"text/css\">\ body {\ background-color: transparent;\ color: white;\ }\ </style>\ </head><body style=\"margin:0\">\ <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \ width=\"%0.0f\" height=\"%0.0f\"></embed>\ </body></html>"; nsstring *html = [nsstring stringwithformat:embedhtml, urlstring, frame.size.width, frame.size.height]; uiwebview *videoview = [[uiwebview alloc] initwithframe:frame]; [videoview loadhtmlstring:html baseurl:nil]; [self.view addsubview:videoview]; } also calling : [self embedyoutube:@"http://www.youtube.com/watch?v=5abkqmqiyei" frame:cgrectmake(30, 200, 260, 200)]; but when run app gives me white empty box . here question : h...

activerecord - Rails 3 - Owning and "tracking" the same object type using has_many and has_many as:trackable (polymorphic) -

in project need user able both "create/own" own objects , "track" (or "follow") objects created other users. here approach: class user < activerecord::base has_many :widgets has_many :gadgets has_many :nuggets has_many :tracks has_many :tracked_widgets, :as => :trackable, :trackable_type => "widget" has_many :tracked_gadgets, :as => :trackable, :trackable_type => "gadget" has_many :tracked_nuggets, :as => :trackable, :trackable_type => "nugget" end class track < activerecord::base belongs_to :trackable, polymorphic: true belongs_to :user end class widget < activerecord::base # gadget , nugget classes same has_many :tracks, :as => :trackable end the schema tracks table: create_table "tracks", :force => true |t| t.integer "user_id" t.integer "trackable_id" t.string "trackable_type" t.datetime "created_at" t.datetime "updated_at" e...

Adding a new key to a nested dictionary in python -

i need add key value increases 1 every item in nested dictionary. have been trying use dict['key']='value' syntax can't work nested dictionary. i'm sure it's simple. my dictionary: mydict={'a':{'result':[{'key1':'value1','key2':'value2'}, {'key1':'value3','key2':'value4'}]}} this code add key main part of dictionary: for x in range(len(mydict)): number = 1+x str(number) mydict[d'index']=number print mydict #out: {d'index':d'1',d'a'{d'result':[...]}} i want add new key , value small dictionaries inside square parentheses: {'a':{'result':[{'key1':'value1',...,'index':'number'}]}} if try adding more layers last line of for loop traceback error: traceback (most recent call last): file "c:\python27\program.py", line 34, in <module> main() file "c:\python27\program.py...