Posts

Showing posts from August, 2011

c# - Saving user color settings of a clicked Button in WPF -

Image
i have little problem saving properties of buttons. buttons small , variety of colors. when press 1 button, specified colors changing... , want save them next start up. textbox values can save them ...i can't. code: public mainwindow() { initializecomponent(); //bluecolor.raiseevent(new routedeventargs(button.clickevent)); //this.property = properties.settings.default.usercolor; } private void bluecolor_click(object sender, routedeventargs e) { var bc = new brushconverter(); main.background = (brush)bc.convertfrom("#ff007ce4"); startbutton.foreground = (brush)bc.convertfrom("#ff007ce4"); closebutton.foreground = (brush)bc.convertfrom("#ff007ce4"); properties.settings.default.usercolor = true; properties.settings.default.save(); } private void purplecolor_click(object sender, routedeventargs e) { var bc = new brushconverter(); main.background = (brush)bc.convertfrom("#ff8701b9"); star

Why the for loop in javascript doesn't work as expected -

this question has answer here: javascript closure inside loops – simple practical example 31 answers <html> <head> <style> div{ border: 1px solid black; width: 50px; height: 50px; } </style> <script> window.onload = function(){ var divv = document.getelementsbytagname("div"); for(i=0; i<divv.length; i++){ divv[i].onclick = function(){ alert(i); } } } </script> </head> <body> <div></div> <div></div> <div></div> </body> </html> this code. want show user index of div clicking everytime click div, every time click different div, alert same value 3 try : function myclickhandler(i) { alert(i); } window.onload = function(){ var divs = document.getelementsbytagname("div"); for(var = 0; < divs.length;

Processing two unassociated Rails models' forms in one controller action -

i'm creating rails app take in input 2 models , respective forms, , log website mechanize , hundreds of tasks there. the first form consists of user's login information (the username , password, using model user ), , second 1 long list of term names , respective definitions (using model term , uploaded form excel doc). i have no need associate these 2 models (unlike in similar questions, seem deal nested models). once mechanize task completes, destroy both models' objects database. the 2 pieces of app (logging in website; , uploading terms , using them interact website) both work in separate scripts. my question is: how can take in both models' information on 1 webpage , coordinate controller(s) accordingly? in situation, can create both objects in 1 controller? (if not, that's fine, long there's alternative; i'm game whatever work.) i'm posting of code below. i'm happy answer questions may have. please keep in mind pretty new @ rails,

css - How do I change the alignment of my search box? -

how can change position of search box right-top , align it? html <form class="form-wrapper cf"> <input type="text" placeholder="search here..." required> <button type="submit">go</button> </form> css .cf:before, .cf:after{ content:""; display:table; } .cf:after{ clear:both; } .cf{ zoom:1; } /* form wrapper styling */ .form-wrapper { width: 450px; padding: 15px; margin: 600px auto 50px auto; background: #444; background: rgba(0,0,0,.2); border-radius: 10px; box-shadow: 0 1px 1px rgba(0,0,0,.4) inset, 0 1px 0 rgba(255,255,255,.2); } /* form text input */ .form-wrapper input { width: 330px; height: 20px; padding: 10px 5px; float: left; font: bold 15px 'lucida sans', 'trebuchet ms', 'tahoma'; border: 0; background: #eee; border-radius: 3px 0 0 3px; } .form-wrapper input:focus { o

TeamCity won't create its schema in SQL Server -

i've installed new teamcity instance , moved internal storage database (sql server). followed instructions @ http://confluence.jetbrains.com/display/tcd7/setting+up+an+external+database , know i've done database part correctly wouldn't connect , had go , turn on tcp/ip connections sql server. from documentation assumed team city create , maintain it's own database schema, though it's user dbo database remains blank - no tables, views or other objects have been created. when try connect in browser "database empty or doesn't exist", , viewing logs shows me "schema contains no tables". i've restarted service , connected again each time. is there install script missing? how teamcity install it's schema? when doing this, need migrate initial structure on sql server. see here

How to get the hadoop home environment variable? -

how can hadoop_home & java_home environment variable through unix terminal ? i know java_home variable there in hadoop-env.sh how can through terminal? you can define in global way setting in .bashrc file or can set in local hadoop-env.sh script in hadoop folder example. if global can check by: echo $hadoop_home if script option, can verify variable importing current context , checking again: . /usr/hadoop/bin/hadoop-env.sh echo $hadoop_home

Firefox Addon Downloads.jsm -

i'm trying use downloads.jsm lib of firefox (it's new in firefox 23) in jetpack addin. var {cu} = require("chrome"); //works fine const {downloads} = cu.import("resource://gre/modules/downloads.jsm"); //works fine but executing either of these functions has no effect: download = downloads.createdownload({source: "http://cdn.sstatic.net", target: "/tmp/kaki.html"}); //download object has no function "start" downloads.simpledownload("http://cdn.sstatic.net","/tmp/kaki.html"); documentation: https://developer.mozilla.org/en-us/docs/mozilla/javascript_code_modules/downloads.jsm https://developer.mozilla.org/en-us/docs/mozilla/javascript_code_modules/downloads.jsm/download do have idea, how use these functions? haven't found examples on web the api functions return promise , not actual download object. in short, following should work: const {downloads} = cu.import("resource://

c++ - Reading data from a file with wrong count. What's best practice for reading in data? -

i have 4 sets of text files each containing different words. noun.txt has 7 words article.txt has 5 words verb.txt has 6 words , preposition.txt has 5 words in code below, inside second loop, array of counts keeps track of how many words i've read in , file. example. count[0] should 5 worlds is, count[1] has 8 words should 7. went check text file , didn't make mistake, has 7 words. problem how ifstream behaving ? i've been told eof() not practice. what's best practice in industry in terms of reading in data accurately ? in other words there better can use besides !infile.eof() ? #include <cstdlib> #include <iostream> #include <fstream> #include <cctype> #include <array> // std::array using namespace std; const int max_words = 100; class cwords{ public: std::array<string,4> partsofspeech; }; int main() { cwords elements[max_words]; int count[4] = {0,0,0,0}; ifstream infile; string file[4] =

android - Passing String Array to another class using Intents -

actually have 2 activities namely mainactivity , listview . want pass string array "arr" mainactivity listview .. , activity listview show list of elements of "arr" note: data in arr supplied database created me , , works fine . there issue retrieving of arr in activity listview mainactivity package com.vivekmishra1991.database; import android.content.context; import android.content.intent; import android.database.cursor; import android.os.bundle; import android.app.activity; import android.view.menu; import android.view.view; import android.widget.arrayadapter; import android.widget.button; import android.widget.listview; import android.widget.textview; public class mainactivity extends activity { public int i; public string arr[] = new string[100]; private databasehelper databasehelper; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main);

javascript - Dynamic Watermark in PDF -

i need add dynamic watermark pdf document using javscript. e.g: when customer not accept terms , conditions of particular document (which flag database), need have watermark "denied" (say) on pdf. watermark should 45 degrees rotated. please help. in advance.

Android Volley API (Google IO 2013) Log does not show anything for socket timeout scenario? -

this might bug volley itself. have verbose logging set true. run 1 volley request goes on http , logs ok. add request queue times out , volley not log anything. catch volley timeout error nothing written log. nothing http request @ all. how possible volley skip logging , yet return volley timout exception? edit: might did not have volley logs on device in question. test again , update later.

actionscript 3 - Flash AS3 FileReference.save() not working on Android AIR -

i have following code save movieclip png image: download_btn.addeventlistener(touchevent.touch_end, function(){ if(currentimage == andy_thumb){ savepicture(movieclip(parent).andy, 'andy'); } if(currentimage == tilly_thumb){ savepicture(movieclip(parent).tilly, 'tilly'); } if(currentimage == trunk_thumb){ savepicture(movieclip(parent).trunk, 'trunk'); } }); function savepicture(mc:movieclip, charname:string):void { var bmd:bitmapdata = new bitmapdata( mc.width, mc.height ); var bounds:rectangle = mc.getbounds(mc); bmd.draw(mc, new matrix(1,0,0,1,-bounds.left, -bounds.top)); var file:filereference = new filereference(); file = new filereference(); file.save(pngencoder.encode(bmd), charname+'.png'); } this works fine when debug on computer. when using tablet, download dialogue box opens, when click "ok" after specifying file location download to, doesn't sav

Google Maps Android API V2 problems -

Image
i'm trying put working example of google maps android api v2. have found 4 tutorials describe how (dj-android, vogella, 2 tutorials official docs) , none of them work. have found dozen posts, one, many other developers, same problem: "binary xml file line #x error inflating class". on stackoverflow, none of dozen posts have single accepted answer. know of no working examples of api anywhere on internet. the contents of project pasted below. think have has been recommended various posts but, many others, i'm getting inflation run time error. this actual project taken vogella tutorial wouldn't compile. applied fixes other posts of same problem. can tell me how make work? know of working example anywhere? thanks, gary manifest file... <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.mapdemo" android:versioncode

Increment / decrement numeric jQuery -

i found code joss crowcroft's solution , maybe similar question jquery-animate-decimal-number-increment-decrement ts have made example on jsfiddle example jquery({somevalue: 0}).animate({somevalue: 110}, { duration: 1000, easing:'swing', // can step: function() { // called on every step // update element's text rounded-up value: $('#el').text(math.ceil(this.somevalue) + "%"); }}); but question different, when change end somevalue 110 big numbers 1000000 or millions. end of animate numbers won't exact end somevalue anymore, might end @ 999876 or etc below 1000000. how can make end animated numbers endvalue? you can provide done function called when animation ends, orbling suggested: $({numbervalue: currentnumber}).animate({numbervalue: 1000000}, { duration: 8000, easing: 'linear', step: function () { $('#dynamic-number').text(math.ceil(this.numbervalue)); }, done: function (

jquery - FadeIn fadeOut images with a wrapper div -

jsfiddle this code works fine without wrapper div $('div').click(function () { but when use wrapper div $('.wrapper').click(function () { the other 2 images fadein , fadeout when don't want them to. want them "toggle" when set "second" images. so, black empty circle should fade red circle when blue circle clicked. this old functionality worked fine. jsfiddle i can't same functionality work wrapper div applied. try using $('.wrapper div').click(function () { demo here

Android List Below Toggle Buttons -

i have list intended below toggle buttons. list grabs data server , parses them. xml follows: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <togglebutton android:id="@+id/toggle_button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:textoff="apps" android:texton="apps" /> <togglebutton android:id="@+id/toggle_button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_torightof="@id/toggle_button1" android:layout_weight="

c++ - Non blocking thread synchronization -

i have dialog box button, , other controls. when button pressed worker thread spawned. for easier discussion, let thread function lengthy job. each time button clicked, new thread should spawn , stuff. dialog box should not blocked while worker threads job, since user should able minimize it, click on other controls , on. on wikipedia, have found term lock-free algorithm, refers non blocking thread synchronization. this why interested in non blocking thread synchronization. believe ensure behavior need. i new multithreading, did find articles/answered questions here, , have read documentation on microsoft it. most of these use following algorithms: 1. main thread declares volatile variable ( int or bool ) , passes worker thread. worker thread checks variable in loop, , if not set indicate termination, continues work. when needs terminated, parent thread sets variable. 2. there vast documentation on microsoft's website synchronization. there, have found m

java - Filler not updating properly -

Image
so when open document, see: here first , first part of second page (the rest of empty) of document. except content in green rectangle (which managed box layout), 100% equal. after visible elements (magenta stuff, first jtextarea (bigger others) doesn't matter regarding problem), both have box.filler added them, push content top of page. so when open document item 38. should high others, reason isn't. i did't call repaint , validate on both jscrollpane , it's viewport conatins both pages right after opening of document. also, when add or remove element anywhere in document, number 38 comes it's senses , resizes it's proper height. did call sam repaints , validates when happens have @ opening of document. chageshape() method called on filler same sizes had trick, seems dirty solution... but why doesn't right away? edit: after more testing, have discovered filler has been bad bad boy here. it's hard me understand why 1 on first page up

regex - PHP preg_grep not working? -

$filenamematchregex = ^a-[0-9]*_b-[0-9]*_c-.*(_d-on)?_((19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01]))-[0-9]*\.csv$ $filenames = array ( [0] => index.html [1] => a-34234234_b-3271_c-123_d-on_2013-08-12-10.csv [2] => a-52342345_b-3271_c-123_d-on_2013-08-12-11.csv [3] => a-8764453_b-3271_c-123_d-on_2013-08-12-12.csv [4] => a-7654334_b-3271_c-1234_d-on_2013-08-12-4.csv [5] => a-3435_b-3271_c-23re_d-on_2013-08-12-5.csv [6] => a-909876_b-3271_c-wef2r2_d-on_2013-08-12-6.csv [7] => a-345456_b-3271_c-23rwef_d-on_2013-08-12-7.csv [8] => a-98765_b-3271_c-23ref_d-on_2013-08-12-8.csv [9] => a-098765_b-3271_c-wef2r_d-on_2013-08-12-9.csv ) $matchingfilenames = preg_grep ("/".$filenamematchregex."/", $filenames); this works here...i match on 1-9: regex tester its working fine me $filenames = explode(',', "index.html,a-34234234_b-3271_c-123_d-on_2013-08-1

iphone - implement prototype cell when I click a button in another view Controller -

my program has 1 view controller , tableview controller. intend upgrade tableview cell current time everytime click button in viewcontroller. viewcontroller.m @interface viewcontroller () @property(nonatomic,strong) brain* brain; @property(nonatomic,readonly)timetablecontroller* tablecontrol; @end - (void)viewdidload { [super viewdidload]; _brain=[[brain alloc] init]; _tablecontrol=[[timetablecontroller alloc] init]; } - (ibaction)actiontime:(id)sender { [self.tablecontrol.entrytime addobject:[self.brain currenttime]]; } timetablecontroller.h @property (strong, nonatomic) iboutlet uitableview *timetable; @property(nonatomic,strong) nsmutablearray* entrytime; timetablecontroller.m - (void)viewdidload { [super viewdidload]; _entrytime=[[nsmutablearray alloc] init]; _timetable=[[uitableview alloc] init]; #pragma mark - table view data source - (nsinteger)numberofsectionsintableview:(uitableview *)tableview { if(!_entrytime) return 0; else

objective c - XCode bit array: selectedSegmentIndex to decimal -

so have 3 selectedsegmentindex. let's call them s1, s2, s3. they in order going left right, each index of 2 (0 , 1). convert chosen index each segment , convert them integer. example: s1.selectedsegmentindex = 0; s2.selectedsegmentindex = 1; s3.selectedsegmentindex = 1; this represents 011 in binary or 3 in decimal. going selectedsegmentindex decimal easy because add them up: s1.selectedsegmentindex*4 + s2.selectedsegmentindex*2 + s3.selectedsegmentindex, yields 3. part i'm having trouble going integer , fill out these 3 selectedsegmentindex. want take stab @ this? thanks! use >> desired bit position 0, , use & turn off other bits. s1.selectedsegmentindex = (bits >> 2) & 1; s2.selectedsegmentindex = (bits >> 1) & 1; s3.selectedsegmentindex = (bits >> 0) & 1;

jquery - Remove html if width is less than 767px -

currently, have modal pop-up (shadowbox) "feedback" form our site. fine modal on desktop browsers, want open new "page" on mobile browser (less 767px) , away modal complications on mobile devices. is there jquery solution remove 'rel="shadowbox"' element link code opens new browser window? example: desktop version <a href="site.com" target="_blank" rel="shadowbox">link</a> 767px or less version <a href="site.com" target="_blank">link</a> so far have script: <script> $( "a" ) .contents() .filter(function(){ return this.nodetype !== 1; }) .remove( "rel="shadowbox"" ); </script> i cannot figure out how first detect width apply "if, then". help appreciated! i, admittedly, not work js as need to. http://jsfiddle.net/hcxwe/ if($(window).width() < 768){ console.log('kill sha

Django sum a field based on foreign key -

so here models: class puzzles(models.model): user = models.foreignkey(user) puzzle = models.charfield(max_length=200) class scores(models.model): user = models.foreignkey(user) puzzle = models.foreignkey(puzzles) score = models.integerfield(default=0) so user have multiple scores. leaderboard page want output users top overall score(added of different scores). i'm lost on python code this. any appreciated, thanks! the easiest way annotation. from django.db.models import sum best = user.objects.annotate(total_score=sum('scores__score')).order_by('-total_score')[0:10] the documentation has example that's pretty on point.

java - Android Killing PhoneGap application -

i'm quite new android world , have been developing android application phonegap (jquery) communicates background service (java) reports gps location every 10 secs. memory consumption around 30mb, not much, have perceived android, reason, kills application after while, because needs more memory. so, there way of avoiding that? if not, how can detect when application being killed? if app getting killed os due normal usage memory pressure, there no way avoid os designed backgrounded apps. you have find way recover gracefully webapp starting if newly launched. as alternative can convert app native app. while same thing happening native app, happening quicker of ui elements native ui elements (buttons, text fields, etc.) while in webapp injecting html , javascript webview , depending on webkit engine render everything. should go native route, documentation , tutorials available @ android developer site available.

Example of what SQLAlchemy can do, and Django ORM cannot -

i've been doing lot of research lately using pyramid sqlalchemy versus keeping current application in django. entire debate, i'm not here discuss that. what want know is, why sqlalchemy universally considered better django orm? every, if not every, comparison i've found between 2 favors sqlalchemy. assume performance big one, structure of sqlalchemy lets translate sql more smoothly. but, i've heard harder tasks, django orm impossible use. want scope out how huge of issue can be. i've been reading 1 of reasons switch sqlalchemy when django orm no longer suiting needs. so, in short, provide query (doesn't have actual sql syntax) sqlalchemy can do, django orm cannot possibly without adding in additional raw sql? update : i've been noticing question getting quite attention since first asked, i'd throw in 2 cents. in end ended using sqlalchemy , must i'm happy decision. i'm revisiting question provide additional feature of sqlal

python - Getting the integer index of a Pandas DataFrame row fulfilling a condition? -

i have following dataframe: b c b 2 1 2 3 5 4 5 6 as can see, column b used index. want ordinal number of row fulfilling ('b' == 5) , in case 1 . the column being tested can either index column (as b in case) or regular column, e.g. may want find index of row fulfilling ('c' == 6) . you use np.where this: import pandas pd import numpy np df = pd.dataframe(np.arange(1,7).reshape(2,3), columns = list('abc'), index=pd.series([2,5], name='b')) print(df) # b c # b # 2 1 2 3 # 5 4 5 6 print(np.where(df.index==5)[0]) # [1] print(np.where(df['c']==6)[0]) # [1] the value returned array since there more 1 row particular index or value in column.

Set custom width height image drawable in Android button -

this want do: customize image size because it's little big. i creating android application , in button, have image , text. want customize size of image fit on screen. however, have difficulty manipulating image. if adjust width , height, of button's. wanted adjust image size. possible? here's code snippet of button: <button android:id="@+id/marketbtn" style="?android:attr/buttonbarbuttonstyle" android:layout_width="0dp" android:layout_height="match_parent" android:layout_gravity="bottom" android:layout_weight="1" android:background="@drawable/unselected_button" android:drawabletop="@drawable/market_icon_0" android:gravity="center" android:paddingbottom="5dp" android:paddingleft="1dp" android:paddingright="1dp" android:paddingtop="5dp" android:text="@string/task_bar_lbl_mark

java - Unable to load library 'libtesseract302': The specified module could not be found -

all - trying use tess4j in java project. have followed following steps - copied jar files /dist , /lib external jar files while creating project. copied /tessdata , libtesseract302.dll project root , in src folder of project. below code(tess4j example code in sf) - import java.io.file; import net.sourceforge.tess4j.*; public class readingimage { public static void main(string[] args) { file imagefile = new file("c:\\documents , settings\\t9saur\\my documents\\downloads\\tess4j-1.1-src\\tess4j\\eurotext.tif"); tesseract instance = tesseract.getinstance(); try { string result = instance.doocr(imagefile); system.out.println(result); } catch (tesseractexception e) { system.err.println(e.getmessage()); } } } yet code giving error. per other post on same topic, checked jvm version (32 bit) , eclipse version(32 bit). please let me know, went wrong. if using eclipse launch, ne

jquery - javascript form cannot dislay -

i have js looks below whereby i'm trying build form several tabs, , under each tab add labels, fields, radiogroups , likes. i'm still @ beginning encountering problems; tabs show fine on occasions after 'contact no.' label, can't see items falling directly below can see address tabs. can show me m getting wrong!! want 'contact no.' label act heading mobile, home, pager , email text fields. this.buildform = function(){ this.myform = new ext.form.formpanel({ layout:'column', border: false, labelwidth: labelwidth, anchor: "100%", items:[{ columnwidth: 1, xtype:'tabpanel', activetab: 0, height:420, enabletabscroll: true, deferredrender: false, bodystyle:'padding:10px', items: [ { title:

java - jTable wrong Rownumber after navigate with up / down Keys -

to selected row in jtable, used mouseevent ( mouseclicked ). works fine , give me correct rownumber after clicking table. to navigate trough jtable, added new listener ( keypressed ). if press key, rownumber not been increased. if press key again, rowcount updated, rowcount previously. private void jtable1keypressed(java.awt.event.keyevent evt) { if(evt.getkeycode() == evt.vk_up){ system.out.println("key up" + jtable1.getselectedrow()); } if(evt.getkeycode() == evt.vk_down){ system.out.println("key down" + jtable1.getselectedrow()); } } this simple code. if click first row of table , press down key, output "key down0". second row selected , output should "key down1". to selected row in jtable, used mouseevent (mouseclicked). works fine , give me correct rownumber after clicking table. to navigate trough jtable, added new listener (keypressed). if press key, rownumber not been incre

pChart Bar Charts set color depending on threshold -

good day i'm new pcharts, works great! i'm trying create bar chart 2 thresholds , display different bar colors. setting thresholds done , works well. set standard palette set color , bars exceed specified second threshold should different color. data consists of times file imported in theory, if possible, bars exceeding 2nd limit should red or pink or whatever. possible? if so, start fiddling? have tried overidecolors if statement seems not work well. info helpful. thanks ok, here code. know there might better or cleaner ways of doing works: /*palette per bar*/ $thold = strtotime("09:30:00"); foreach ($lastdate $over) { if ($over < $thold) { $color = array("r"=>0,"g"=>204,"b"=>204); $palette[] = $color; } else { $color2 = array("r"=>224,"g"=>46,"b"=>117); $palette[] = $color2; } } hope helps

objective c - cocos2d collision detection BOOL Flag -

i trying head round collision detection, here game details: have character can move freely around screen , fire bullets enemies generated off screen , ‘hero’ can shoot them (when bullets , enemies created stored in arrays , removed @ collision) if enemy makes contact hero nothing happens, life removed on contact , believe done via collision detection. using (cgrectintersectsrect([hero boundingbox], [enemy boundingbox])) but not collisions detected , 3 detected. believe caused multiple collisions detected objects pass through each other. have tried use bool flag don’t believe doing correctly, code: .h bool collision; .m -(void)update:(cctime)deltatime { if (collision == no) { if (cgrectintersectsrect([hero boundingbox], [enemy boundingbox])) { cclog(@”collision detected!!!!!!!!!!!!!!!!”); collision = yes; } } } is best way deal collision detection , if how implement bool flag? you set boolean on yes when collide

ios - shouldAutorotate is not locking the screen orientation -

i ma trying lock screen orientation landscape orientation when image still visible, when image hidden, unlock orientations (targeting ios 6): -(bool)shouldautorotate{ if (self.splashimageview.hidden == no) { return uiinterfaceorientationmaskportrait;//gets called when image visible }else{ return uiinterfaceorientationmaskall;//gets called when image hidden } } - (void)willrotatetointerfaceorientation:(uiinterfaceorientation)tointerfaceorientation duration:(nstimeinterval)duration { [self shouldautorotate]; } as may notice, shouldautorotate called screen supporting landscape orientation when image still visible, there missing? p.s: please note trying work on tabbar view controller (a uiviewcontroller subclass). in appdelegate have 2 methods.but have setting in project settings -> go summary tab , see if orientation set landscape or all.just try set those.

clojure - How to simplify those tow macro when runtime type depend? -

guys, @ code first: (defmacro map-remove- [v w] `(dosync (ref-set ~v (dissoc @~v (keyword ~w))))) (defmacro set-remove- [v w] `(dosync (ref-set ~v (disj @~v ~w)))) (defmacro clean- [v] `(dosync (ref-set ~v (empty @~v)))) they work fine , want write more general macro combine "map-remove-" , "set-remove-" in one. according c/java experience chose "case" case can't use in macro defination cause "the test-constants not evaluated. must compile-time literals", following code won't work: (defmacro [x] (case (type x) ;;;;;;;;;;; never work!directly reach default clause ....)) anybody has suggestion? appreciate. you can use functions map? , set? test whether value map or set respectively. i'm not sure have enough perspective on you're trying here though - i've substituted macro instead of function, because can't see necessity macro in sample you've given. ;; create functi

java ee - WAR - JSPs and resources inside jar library? -

i'm creating java ee web application , need design in modular way. idea create core .war package , in case of need add modules it's .jar libraries. question is: can put example html, jsp, css etc. inside jar bundled .war , how can access them .war? for example if customer needs discussion forum, i'd add .jar module including required jsps, css , on , make accessible like http://my-web.com/forum/index.jsp thanks this seems plugin mechanism application server. may want check out apache felix or other osgi implementations , embed them in application server. can later add osgi bundles plugins system.

sorting - How to sort datemonthyear by reverse chronological order using Python -

i have folder named 29jun2011,12aug2013,31jan2013,08aug1985. have sort out reverse chronological order using python script. , have store latest 1 in variable , print it. import datetime dt date_strs = [ "29jun2011", "08aug1985", "12aug2013", ] my_format = "%d%b%y" datetime_objs = [] date_str in date_strs: my_datetime = dt.datetime.strptime(date_str, my_format) datetime_objs.append(my_datetime) print datetime_objs datetime_objs.sort(reverse=true) print datetime_objs print datetime_objs[0].strftime("%b %d, %y") --output:-- [datetime.datetime(2011, 6, 29, 0, 0), datetime.datetime(1985, 8, 8, 0, 0), datetime.datetime(2013, 8, 12, 0, 0)] [datetime.datetime(2013, 8, 12, 0, 0), datetime.datetime(2011, 6, 29, 0, 0), datetime.datetime(1985, 8, 8, 0, 0)] august 12, 2013

php - Display authenticated users on non-secure (anonymous) routes -

i use php , silex build web app , implemented basic authentication via securityserviceprovider this: $app->register(new silex\provider\securityserviceprovider(), array( 'security.firewalls' => array( 'private' => array( 'remember_me' => array( 'key' => $config['secret_key'], 'lifetime' => $config['remember_me_duration'], ), 'pattern' => '^/admin', 'form' => array('login_path' => '/login', 'check_path' => '/admin/login_check'), 'logout' => array('logout_path' => '/admin/logout'), 'users' => $app->share(function () use ($app) { // ... }), ), 'public' => array( 'pattern' => '^/$', 'ano

c# - Datetime value getting reset in wcf service on using as a web reference and not with using as a service reference -

i have wcf service operation follow: public void setnotifications(list<announcementdatacontract> announcements) { foreach(announcementdatacontract item in announcements) { ent.insertannouncements(item.anc_text, item.anc_date); } } when add wcf service webreference in mvc application , calls method follow: myservice.service1 proxy = new myservice.service1(); collection<myservice.announcementdatacontract> dc = new collection<myservice.announcementdatacontract>(); myservice.announcementdatacontract dc1 = new myservice.announcementdatacontract(); dc1.anc_date = system.datetime.now; dc1.anc_text = "announcement1"; dc.add(dc1); proxy.setnotifications(dc.toarray()); the value in each item "announcements" @ service operation reset , min datetime value not 1 have sent mvc application on calli

ios - Passing property to another view -

i have problem prepareforsegue method. need pass nsstring 1 view is: 2013-08-13 12:13:45.765 dailyphotos[12551:907] -[archiveviewcontroller textlabel]: unrecognized selector sent instance 0x1e5592f0 2013-08-13 12:13:45.775 dailyphotos[12551:907] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[archiveviewcontroller textlabel]: unrecognized selector sent instance 0x1e5592f0' *** first throw call stack: (0x328852a3 0x3a52a97f 0x32888e07 0x32887531 0x327def68 0x813dd 0x34a1ade9 0x8174d 0x3474f28d 0x347d1f81 0x33193277 0x3285a5df 0x3285a291 0x32858f01 0x327cbebd 0x327cbd49 0x3638f2eb 0x346e1301 0x78fb9 0x3a961b20) libc++abi.dylib: terminate called throwing exception here prepareforsegue implementation: - (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { // checking segue perform if ([[segue identifier] isequaltostring:@"projectdetailssegue"]) { albumviewcontroller *destinationview =

jax rs - Jax-rs with Jersey : different Json stream. Why ? -

i have 2 test machines, 1 (lets call workstation a ) java 1.6 , netbeans 7.2, other (workstation b ) java 1.7 , netbeans 7.3. check jersey libraries , release numbers different. created simple web service using netbeans wizard "restful webservices database" on workstation a , produces json this: {"somename":[{"id":"2","nome":"1 maggio"}, ..., {"id":"6","nome":"25 dicembre"}]} as can see json object single name value pair value array of objects. doing same operations on workstation b get: [{"id":"2","nome":"1 maggio"}, ..., {"id":"6","nome":"25 dicembre"}] this simple json array, not json object workstation a . may inadvertently put different in web service configuration on 2 machines, have no idea check. i suspect different result depends on different version of jersey , java sdk. can confi

java - Retrieve value from CDATA -

i using java(jaxb) , want retrieve data cdata <![cdata[need help]]> desired output need can body me out. tried several solutions. thanks!! try this @xmlaccessortype(xmlaccesstype.field) public class test0 { string e1; public static void main(string[] args) throws exception { string xml = "<root><e1><![cdata[need help]]></e1></root>"; test0 t = jaxb.unmarshal(new stringreader(xml), test0.class); system.out.println(t.e1); } } output need