Posts

Showing posts from June, 2011

Perl array splicing syntax -

why third print fail? my @a = (0,1,2,3); print @a[-@a..-2]; # works print @a[0..2]; # works print @a[0..-2]; # prints nothing it's not clear me meaning of -@a used in @a[-@a..-2] statement. special syntax? special syntax provide (if @ all) in addition $#a instance? sort of sugar (which curious shorter single character) symbol array used in subindex means "length of array"? the 3rd print prints nothing because, according perldoc perlop : if left value greater right value returns empty list. see perldoc b::deparse : $ perl -mo=deparse code.pl my(@a) = (0, 1, 2, 3); print @a[-@a .. -2]; print @a[0..2]; print @a[()]; i believe print @a[-@a..-2]; "works" because @a[-4 .. -2] . according perldoc perldata : a negative subscript retrieves value end. so, 3 @ index -1, 2 @ index -2, 1 @ index -3 , 0 @ index -4.

Android keyhash for facebook -

i trying hashkey in-order connect phonegap android app facebook following below steps .. 1) download openssl from: http://code.google.com/p/openssl-for-windows/downloads/list 2) make openssl folder in c drive 3) extract zip files openssl folder 4) copy file debug.keystore .android folder in case (c:\users\system.android) , paste jdk bin folder in case (c:\program files\java\jdk1.6.0_05\bin) 5) open command prompt , give path of jdk bin folder in case (c:\program files\java\jdk1.6.0_05\bin). 6) copy code , hit enter keytool -exportcert -alias androiddebugkey -keystore debug.keystore > c:\openssl\bin\debug.txt 7) need enter password, password = android. 8) see in openssl bin folder file name of debug.txt 9) either can restart command prompt or work existing command prompt 10) comes c drive , give path of openssl bin folder 11) copy following code , paste openssl sha1 -binary debug.txt > debug_sha.txt 12) debug_sha.txt in openssl bin folder 13) again co

repeater - How can I access the attributes of a <span> element inside of an asp.net RepeaterItem? -

i'm trying alter css class of span positioned within asp.net repeateritem . span element has other tags inside of (radio button). the markup similar this: <asp:repeater> <itemtemplate> <span class="spanclass" runat="server"> <label> <asp:radiobutton id="rbid"> </asp:radiobutton> </label> </span> </itemtemplate> </asp:repeater> i'm able edit radio button using following: rb = (radiobutton)(repeateritem.findcontrol("rbid"); rb.checked = true; //this works however, when using similar piece of code grab span , fails innerhtml exception because span not literal control: span = (generichtmlcontrol)(repeateritem.findcontrol("spanid"); span.attributes.add("class", "classtoadd"); //this fails the reading i've done says case because span not literal contro

java - Search JPA entities that contain Lists using fields in those Lists -

let's have entity named foo . foo entity contains list of bar entities. bar entity has name . we persist number of foo records. now, present user jsp page search foo records. 1 input field give them bar name. way inflate list<foo> matches user's requested bar name? i believe jpql handle without problem. select f foo f join f.bar b b.name = :name

javascript - How can I toggle a class inside a button on click? -

what's proper way toggle couple classes on click in jquery? 1) html before click: <button class="btn"><i class="icon-sign-blank"></i> click me!</button> 2) html after click: <button class="btn btn-success"><i class="icon-check"></i> clicked!</button> 3) html after click: (same beginning) <button class="btn"><i class="icon-sign-blank"></i> click me!</button> current jquery: $('btn').on('click',function(e) { $('btn > i').removeclass('icon-sign-blank').addclass('icon-check'); $('btn').addclass('btn-success'); }); but works once, not again. what's proper way handle both directions? you can - should - use toggleclass manage ! $('btn').on('click',function(e) { $('btn > i').toggleclass('icon-sign-blank icon-check');

c++ - error C2079: 'stackNameSpace::StackNode<T>::value' uses undefined class -

the interface of stack.h #include "stdafx.h" //use linkedlist implement stack //which different using array implement stack #ifndef stack_h #define stack_h using namespace std; namespace stacknamespace { template<class t> struct stacknode { t value; t min_value; //current local min value stacknode* next; }; typedef stacknode<class t>* stacknodeptr; template<class t> class stack { private: stacknodeptr top; public: stack(); stack(const stack& a_stack); ~stack(); bool empty() const; t pop(); void push(t the_value); t getmin(); }; } //end of namespace #endif the implementation of stack.h #include "stdafx.h" //use linkedlist implement stack //which different using array implement stack #ifndef stack_cpp #define stack_cpp #include <iostream> #include <cstdlib> #include "stack.h" using namespace std; namespace stacknamespace { template<class t> stack<t>::stack

iphone - Kobold2d and Cocos Builder: setting start scene -

in kobold2d functions in cocos2d in appdelegate in config.lua file. , brings me problem cause initialize cocos builder first scene in cocos2d replace line (in app delegate) [director runwithscene: [introlayer scene]]; with [director runwithscene: [ccbreader scenewithnodegraphfromfile:@"mainmenuscene.ccbi"]]; but hidden away in kobold2d - replaced firstsceneclassname = "helloworldlayer" in config.lua file. anyone knows bugfree way around this? you can still use runwithscene, put in appdelegate's initializationcomplete method. take precedence on loading scene specified in config.lua.

Java Binary search not working -

i have insertion search in main , there call binarysearch method search number within array has been sorted. try compile errors here main insertion sort. public class test5 { public static void main(string[] args) { // original order or numbers system.out.println("original order of numbers:"); int nums[] = {26, 45, 56, 12, 78, 74, 39, 22, 5, 90, 87, 32, 28, 11, 93, 62, 79, 53, 22, 51}; for(int x = 0; x < nums.length; x++){ system.out.print(nums[x] + " "); } // local variables int unsortedvalue; // first unsorted value int scan; // used scan array int swapcount = 0; // other loop steps index variable through // each subscript in array, starting @ 1. // because element 0 considered sorted. for(int index = 1; index < nums.length; index++) { // first element outside sorted subset // nums[index]. store value of elementt // in unsortedvalue. unsortedvalue = nums[index]; // start scan @ subscript of first element // proper posi

search - Emacs Searchin Number of Results -

this question has answer here: “1 of n” result emacs search 4 answers when doing search in emacs ( c-s , incremental search), may useful see number of results. i'm trying find way cannot seem find any. have suggestions? you can run count-matches number of matches. incremental search incremental, searches incrementally.

java - Using Jsoup to POST login data -

i'm trying log website: http://deeproute.com this code. connection.response res = null; connection homeconnection = null; document homepage = null; map<string, string> logincookies = null; try { res = jsoup.connect("http://www.deeproute.com/") .data("cookieexists", "false") .data("name", user) .data("password", pswd).method(method.post) .execute(); } catch (ioexception e) { e.printstacktrace(); } if (res != null) { logincookies = res.cookies(); try { homepage = jsoup.connect("http://www.deeproute.com") .cookies(logincookies).get(); } catch (ioexception e) { e.printstackt

scala - Idiomatic sbt custom incremental work criteria -

i'd have compile task depend on task mytask expensive should run if custom metric has changed since last time run. let's have function mycriterion : state => string returns canonical representation of custom criterion. ideally, compile depend on mytask onlyif mycriterion changed or along lines. see bunch of stuff around tracked.inputchanged , filesinfo.* seems relevant, can't find indication of how use them. behind scenes, i'd mytask run mycriterion , check against cached version on disk if it's present, , if match, nothing @ all. if don't match, i'd run logic of mytask , write current output of mycriterion cache don't perform task unnecessarily next time around (since produce same output each time). compile should happen regardless of whether mytask turns nop or not. i think i've figured out how use tracked , it's worth: if write tracked.inputchanged(somepath) { case (changed, state: string) => if (changed) ... } ,

r - Find the largest product in a dataframe -

i have dataframe , need find largest product in data frame in same direction(up, down, left, right, or diagonally). the dataframe follows: structure(list(v1 = c(8l, 49l, 81l, 52l, 22l, 24l, 32l, 67l, 24l, 21l, 78l, 16l, 86l, 19l, 4l, 88l, 4l, 20l, 20l, 1l), v2 = c(2l, 49l, 49l, 70l, 31l, 47l, 98l, 26l, 55l, 36l, 17l, 39l, 56l, 80l, 52l, 36l, 42l, 69l, 73l, 70l), v3 = c(22l, 99l, 31l, 95l, 16l, 32l, 81l, 20l, 58l, 23l, 53l, 5l, 0l, 81l, 8l, 68l, 16l, 36l, 35l, 54l), v4 = c(97l, 40l, 73l, 23l, 71l, 60l, 28l, 68l, 5l, 9l, 28l, 42l, 48l, 68l, 83l, 87l, 73l, 41l, 29l, 71l), v5 = c(38l, 17l, 55l, 4l, 51l, 99l, 64l, 2l, 66l, 75l, 22l, 96l, 35l, 5l, 97l, 57l, 38l, 72l, 78l, 83l), v6 = c(15l, 81l, 79l, 60l, 67l, 3l, 23l, 62l, 73l, 0l, 75l, 35l, 71l, 94l, 35l, 62l, 25l, 30l, 31l, 51l), v7 = c(0l, 18l, 14l, 11l, 63l, 45l, 67l, 12l, 99l, 76l, 31l, 31l, 89l, 47l, 99l, 20l, 39l, 23l, 90l, 54l), v8 = c(40l, 57l, 29l, 42l, 89l, 2l, 10l, 20l, 26l, 44l, 67l, 47l, 7l, 69l, 16l, 72l,

python - How Pony (ORM) does its tricks? -

pony orm nice trick of converting generator expression sql. example: >>> select(p p in person if p.name.startswith('paul')) .order_by(person.name)[:2] select "p"."id", "p"."name", "p"."age" "person" "p" "p"."name" "paul%" order "p"."name" limit 2 [person[3], person[1]] >>> i know python has wonderful introspection , metaprogramming builtin, how library able translate generator expression without preprocessing? looks magic. [update] blender wrote: here file you're after. seems reconstruct generator using introspection wizardry. i'm not sure if supports 100% of python's syntax, pretty cool. – blender i thinking exploring feature generator expression protocol, looking file, , seeing ast module involved... no, not inspecting program source on fly, they? mind-blowing... @brenbarn: if try cal

html - Background Image Scaling -

i'm having problem, pretty i'm trying make background image stay anchored , remain same size , position not matter how larger users resolution. what have now: #navigator { background-image: url('banner.png'); background-repeat:no-repeat; background-position:top-center; } thanks in advance! you want learn meta viewport options. 1 use time target-densitydpi , android specific. <meta name="viewport" content="target-densitydpi=device-dpi" />

javascript - How can I get the sum of all table rows with a certain class in jQuery? -

how can sum values of table rows countme class in jquery? html: <div id="sum">$0</div> <table> <tr> <th>id</th> <th>value</th> </tr> <tr class="countme"> <td>1</td> <td class="v">$10</td> </tr> <tr> <td>2</td> <td class="v">$20</td> </tr> <tr class="countme"> <td>3</td> <td class="v">$10</td> </tr> <tr> <td>4</td> <td class="v">$30</td> </tr> </table> i need #sum $20 . how can that? you can this: var sum = 0; $('tr.countme td.v').each(function() { sum += parsefloat($(this).text().slice(1)); }); $('#sum').text(sum);

jquery - How to Keep Cookie Value after page refresh -

i'm creating demo panel users change layout of wordpress theme when arrive @ demo site. user changes value via select drop-down box, , cookie set @ time. i'm having trouble showing actions want implement after page refreshed. cookie saving it's value, after page refresh css actions not stay in place. i'm not jquery appreciated. here's code: $('#montage-demo-panel select.body-style-layout').change(function () { // apply cookie $.cookie('body-style-layout', $(this).val(), { path: '/' }); var value = $(this).val(); if (value == 'fixed') { var wrapper = $('#wrapper'); var header = $('#header'); var masthead = $('#masthead'); var branding = $('#branding'); wrapper.removeattr('style'); header.removeattr('style

objective c - Method Swizzling isEqualToString -

i'm running odd behavior when trying method swizzle isequaltostring: on nsstring class. here code in question: #import <foundation/foundation.h> #import <objc/objc-runtime.h> @interface nsstring (swizzlestring) - (bool) custom_isequaltostring:(nsstring *)astring; - (nsrange)custom_rangeofstring:(nsstring *)astring; @end @implementation nsstring (swizzlestring) - (bool) custom_isequaltostring:(nsstring *)astring; { nslog(@"inside custom_isequaltostring method definition"); return [self custom_isequaltostring:astring]; } - (nsrange)custom_rangeofstring:(nsstring *)astring; { nslog(@"inside custom_rangeofstring method definition"); return [self custom_rangeofstring:astring]; } @end int main(int argc, const char * argv[]) { method m1, m2; m1 = class_getinstancemethod([nsstring class], @selector(isequaltostring:)); m2 = class_getinstancemethod([nsstring class], @selector(custom_isequaltostring:)); method_ex

regex - Matching content between tags from RSS and inserting each match into an array - perl -

i'm not sure how else word want, i'll use examples have , want. i have: my $rss = ("<item><title>this test title</title></item> <item><title>this test title</title></item>"); @items = ($rss =~ /<item>[\s.*]<\/item>/g); and i'd end this: @items[0]: <title>this title</title> @items[1]: <title>this title</title> i'd regex allow new lines when replace test string real rss still work. i'm sure there plenty i'm doing wrong, hours of searching has made me no closer want be. the solution, provided lecturer: my @items = ($rss =~ m{<item>(.*?)</item>}gs);

Time taken in connecting while audio streaming in android? -

i using simple audio streaming in android app this: try { mediaplayer media = new mediaplayer(); media.setaudiostreamtype(audiomanager.use_default_stream_type); media.setdatasource("http://indiespectrum.com:9000"); media.prepare(); media.start(); } catch(exception e) { //getting exception } where using 4 different url .when start radio streaming takes while start playing.sometimes takes 5-6 sec , around 40-45 sec start playing radio. want know if can speed these time taken .as of these uses shoutcast there anyway speed connection or depends on kind of bitrate or something.please help? one way speed things lot leveraging uimain thread , doing audiostreaming using asynctask , wich enables proper , easy use of ui thread. class allows perform background operations , publish results on ui thread without having manipulate threads and/or handlers.

return false not working in jquery require field validation -

i have dropdownlist (.color) validate jquery.default value of dropdown vÆlg .and want validate in anchor tag click (.viewmore).my code this $(".viewmore").on('click',function(event){ requiredvalidation($(this).parents('.box01').find(".color")); }); function requiredvalidation(ddl) { ddl = $(ddl); var isvalid = true; if (jquery.trim(ddl.val()) == 'vÆlg' ) { isvalid = false; ddl.addclass("error"); } else { ddl.removeclass("error"); } alert(isvalid) return isvalid; } at last alert message getting value false correctly.but still page redirect given url of anchor tag.can 1 tell me whats going wrong? try this return requiredvalidation($(this).parents('.box01').find(".color"));

Firefox aborting some ajax request -

i using firefox 20.0.1 version. firefox shows status aborted request. if refresh again not show aborted status. my code: for (index in personscorecollection.collection) { // scores(2nd, 3rd, 4th , 5th scores) $.when( variableset(collectionobject, index), endorsementrankforeachperson(index), usabilityscore(index), userconnection(index), usersearch(index) ).done(); } inside function calling ajax request. my ajax request code var xdr; if (window.xdomainrequest) // check whether browser supports xdr. { xdr = new xdomainrequest(); // create new xdr object. if (xdr) { xdr.open("post", urlsearch); xdr.timeout = 3000;//set timeout time 3 second. xdr.onload = function () { try{ //success method } catch (err) { //error method } }; xd

iphone - Adding UIPinchGestureRecognizer on a UIImageview which is subview of UIScrollview's -

i using 1 uiscrollview , uiimageview subview of uiscrollview, , want use uipinchgesturerecognizer on uiimageview, not working. it's simple, can use : yourimageview = [[uiimageview alloc] initwithimage:yourimage]; [yourscrollview addsubview:yourimageview]; uitapgesturerecognizer *singletap = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(handlesingletap:)]; [yourimageview addgesturerecognizer:singletap]; [sibgletap release]; goodluck.

performance - simple PHP script with sleep function not working, Browser prompt to download .php file -

Image
when execute following php file (after time) browser ask download file <?php ini_set("max_execution_time", 0); set_time_limit(0); for($i=0;$i<10;$i++){ echo time(); echo "<br>"; $sec=rand(15,30); sleep($sec); } ?> in browser nothing echo prompt download php file (if file take approximate 2 or more minute execute problem occurred) thanks in advance. if server decides throw php source code instead of running it, server setup messed up. not sure how got messed because screenshot hints using xampp. in case, try reinstalling xampp.

How to receive the post data from the android using php -

i want simple web service in php , receiving request android app , processing , response device . want receive , respond android this part of android code list<namevaluepair> arg = new arraylist<namevaluepair>(); arg.add(new basicnamevaluepair("info", "on")); httprequest.sharedinstance().dohttprequest("http://www.xxxx.com/xxx.php", arg); //jsonobject jsonobj = new jsonobject(httprequest.sharedinstance().responsestring); string responsestr=httprequest.sharedinstance().responsestring; log.v("response", ""+responsestr); when prints simple "hello" in php file , can response in android, not receiving request ,i have printed $_post['info'] in php file , value empty . how can receive info parameter in php posted android app . my php code in file http://www.xxxx.com/xxx.php echo $_post['info']; thanks , raj

xcode - Using FaceBook SDK why do I get 'NSInvalidArgumentException', reason: '-[__NSDictionaryM length]: unrecognized selector sent to instance -

this code gives error...why ? 'nsinvalidargumentexception', reason: '-[__nsdictionarym length]: unrecognized selector sent instance nsmutabledictionary *info = [nsmutabledictionary dictionarywithobjectsandkeys:longitude,@"longitude",latitude,@"latitude",nil]; nsmutabledictionary *params = [nsmutabledictionary dictionarywithobjectsandkeys: info, @"venue", nil]; nsstring *graphpath = [nsstring stringwithformat:@"/%@", (id_of_event)]; fbrequest *updateevent = [fbrequest requestwithgraphpath:graphpath parameters:params httpmethod:post]; [updateevent startwithcompletionhandler: ^(fbrequestconnection *connection, nsdictionary* result, nserror *error) { i trying set venue longitude , latitude, no matter try keep getting run time error. missing ? thought "venue" dictionary under main event , has valid keys

ios - Calculator divide by zero -

i created simple calculator. works great; however, if divide zero, show error message. know how alert popups, don't know how implement comes when divide zero. here snipped of calculator code: - (ibaction)buttonoperationpressed:(id)sender { if (currentoperation == 0) result = currentnumber; else { switch (currentoperation) { case 1: result = result + currentnumber; break; case 2: result = result - currentnumber; break; case 3: result = result * currentnumber; break; case 4: result = result / currentnumber; break; case 5: currentoperation = 0; break; default: break; } } currentnumber = 0; calcdisplay.text = [nsstring stringwithformat:@"%g",result]; if ([sender tag] == 0) result = 0;

c# - Best Practices for mapping one object to another -

my question is, best way can map 1 object in maintainable manner. cannot change way dto object getting setup more normalized need create way map our implementation of object. here example code show need happen: class program { static void main(string[] args) { var dto = new dto(); dto.items = new object[] { 1.00m, true, "three" }; dto.itemsnames = new[] { "one", "two", "three" }; var model = getmodel(dto); console.writeline("one: {0}", model.one); console.writeline("two: {0}", model.two); console.writeline("three: {0}", model.three); console.readline(); } private static model getmodel(dto dto) { var result = new model(); result.one = convert.todecimal(dto.items[array.indexof(dto.itemsnames, "one")]); result.two = convert.toboolean(dto.items[array.indexof(dto.itemsnames, "

prestashop how change some variable? -

i downloaded prestashop yesterday , want make changes. footer.tpl <div id="right_column" class="column grid_2 omega"> {$hook_right_column} </div> is possible change $hook_right_column ?

java - nullpointer exception when querying database -

i trying query database hibernate project public class feedinputparamsdaoimpl implements ifeedinputparamsdao { @autowired private sessionfactory sessionfactory; public void setsessionfactory(sessionfactory sessionfactory) { this.sessionfactory = sessionfactory; } private int batch_size = 50; public session getsession() { /*null pointer exception*/session session = sessionfactory.opensession(); return session; } @override public list<feedinputparams> getallfeedinputparamslist (int feedkey) { string querystring = "from feedinputparams feedinputparams feedinputparams.feedkey > ?"; session session = getsession(); query query = session.createquery(querystring); query.setparameter(0, feedkey); list<feedinputparams> feedinputparamslist = query.list(); return feedinputparamslist; } } and getallfeedinputparamslist (int feedkey) called method public void readfile() throws exception { feedinputparamsda

Customize quick action dialog for android -

Image
i'm developing application in have show quick action dialog on click of button. here example how want implement. till not figure out how make custom quick action dialog. have tried using activity , i'm near have achieve. here have done till now. on click of button i'm passing intent activity: if (v.getid() == r.id.points) { toast.maketext(mainactivity.this, "clicked on points", toast.length_short).show(); intent = new intent(mainactivity.this, pointsactionmenu.class); startactivity(i); } and have used styles.xml make activity transparent. styles.xml <style name="theme.transparent" parent="android:theme"> <item name="android:windowistranslucent">true</item> <item name="android:windowbackground">@android:color/transparent</item> <item name="android:windowcontentoverlay">@null</item> <item name=&

sql - UNION Query Error -

i have following 2 tables(dept , emp): dept deptno,dname,loc emp empno, ename,job,mgr,hiredate,sal,comm,deptno i'm executing following query: "use union display department numbers , names , employee numbers , names. choose appropriate column headings , sort name in ascending order." here query: select deptno, dname dept order dname asc union select empno,ename emp order ename asc; i'm wondering why i'm getting following error: union * error @ line 4: ora-00933: sql command not ended. could please tell me what's wrong here? thanks try this select deptno id, dname name dept union select empno id,ename name emp order name asc edit to display 4 columns check below query using join select e.empno ,e.ename ,d.deptno , d.dname dept d inner join emp e on e.deptno = d.deptno order e.ename asc

html - Output in a form format that can be submitted after reading from a text file -

i have following text file: $string = '1 important feature of spiral model is: requirement analysis. risk management. quality management. configuration management 2 worst type of coupling is: data coupling. control coupling. stamp coupling. content coupling 3 1 of fault base testing techniques is: unit testing. beta testing. stress testing. mutation testing 4 fault simulation testing technique is: mutation testing. stress testing. black box testing. white box testing 5 rs known as: specification of white box testing. stress testing. integrated testing. black box testing 6 name: collins. achieng. ogwethi. kamanda'; the following codes read text file , output in form format pull down menu select multiple question. how i'm trying go it, <html> <head> <title>read</title> </head> <body> <b><u> questions , answers quiz</u></b> <br /><br /> <?php $openfile = fopen("questionandanswers.

java - Why i need to use Base64 in this encryption -

i see encryption in java.in generate secret key have keygenerator keygen = keygenerator.getinstance("des"); key secretkey = keygen.generatekey(); byte[] keybytes = secretkey.getencoded() key secretkey = keygen.generatekey(); byte[] key = secretkey.getencoded(); byte[] encodedkey=base64.encodebase64(key ); string keytext = new string(encodedkey); my question why need of using base64.encodebase64(key) . problem if use directly string keytext = new string(key); i confusing.please me.thanks in advance... not every sequence of bytes represents valid string : you need know character encoding in order interpret sequence of bytes string . since java's char 16-bit, random sequence of bytes can end representing string invalid code points in it. using base-64 encoding fixes problem ensuring elements valid characters [a-za-z0-9+/] range.

javascript - How can I access the canvas element without an id? -

using casperjs, i'm trying testing on canvas, grabbing , using canvas.todataurl(); . however, canvas not have id, code looks this: <div id= 'derp' ...> <canvas ...> </canvas> </div> can still canvas using var canvas = document.getelementbyid(????); or there better way of grabbing canvas? you can use css selectors: document.queryselector('#derp canvas')

When using inheritance throw exception java.lang.NoSuchFieldError: __odbTracker on NetBeans 7.3 Jboss 7.1.1 ObjectDB 2.5.1 -

when using inheritance throw exception java.lang.nosuchfielderror: __odbtracker on netbeans 7.3 + objectdb 2.5.1 + jboss 7.1.1, works fine on netbeans 7.3 + objectdb 2.5.1 + glassfish 3.1 @entity public class person extends abstractobject { private static final long serialversionuid = 1l; @manytoone @index private city city; @onetomany(mappedby = "owner") private list<city> cities; private string name; public string getname() { return name; } public void setname(string name) { this.name = name; } public city getcity() { return city; } public void setcity(city city) { this.city = city; } public list<city> getcitys() { return cities; } public void setcitys(list<city> citys) { this.cities = citys; } } @entity public class city extends abstractobject { private static final long serialversionuid = 33l; @onetomany(map

c++ - C# Equivalent for PtrToStringChars(String s) function present in vcclr.h -

i have native c++ function wish import c# project file. the file vcclr.h , present in visual studio 9.0/vc/include folder. function ptrtostringchars(string s) is there equivalent c# function can use in place of native c++ function? also, if wish import function need specify name of dll contains file. how name of dll? i can see c++ file containing function , there can see folder location (absolute , relative path). you don't need method: string str = "hello".substring(0, 2); // force not inline string // same if inlined gchandle h = gchandle.alloc(str, gchandletype.pinned); intptr ptr = h.addrofpinnedobject(); // address // ch h // unchecked necessary (technically optional because it's default) // because marshal.readint16 reads signed int16, while char more similar // unsigned int16 char ch = unchecked((char)marshal.readint16(ptr)); or little unsafe code (see fixed statement ): fixed (char* ptr2 = str)

c++ - Installing visualizer for boost::posix_time::ptime in Visual Studio Express 2012 -

when debugging application boost::posix_time::ptime instances in it, normal debugger not helpful, shows time value in ticks. when outputting same object std::cout , console shows time in readable format. now know of existance of debug visualizers, can format values readable format in debugger. there handy installer tool includes debug visualizer boost::posix_time @ msdn . however, when trying install tool, error message "this extention not installable on installed products.". maybe because using express version of visual studio 2012, don't think so, support other tools , extentions. boost provide the files install debug visualizer, there no regarding how install them. visual studio mentions how install .dll files visualizer in it, while files provided boost .txt , .hpp files. so, still don't know how install visualizer boost::posix_time. how do this? i'm not sure if express versions support installing debug visualizers extensibility restri

curve fitting - How to get predicted values on Sigmoid Growth model in R -

i trying forecast future revenue bu using sigmoid growth model in r. model this: sigmoid growth ("sigmoid" means "s-shaped"), y = a/( 1+ce^(-bx) ) + noise my code: x <- seq(-5,5,length=n) y <- 1/(1+exp(-x)) plot(y~x, type='l', lwd=3) title(main='sigmoid growth') even draw plot, don't know how future values. suppose want predict next 6 years revenue values. make y function, , plot ( plot has special support functions): y <- function(x) 1/(1+exp(-x)) plot(y,-5,11,type="l",lwd=3)

Excel VBA Grouping Command Buttons on Worksheets -

i have seen lot of information on getting several command buttons similar things, i've seen user forms. i want have group of command buttons move data cell cell. don't want copy , paste same code each command button. here part of want each command button: range(commandbutton1.topleftcell.address).select selection.copy if application.worksheetfunction.istext(range("r5")) , range(commandbutton1.topleftcell.address).value <> range("r5") range("r6").select activesheet.paste range(commandbutton1.topleftcell.address).select else range("r5").select activesheet.paste range(commandbutton1.topleftcell.address).select end if application.cutcopymode = false i've tried use class modules can't seem function @ all. want able throw code class or run on command buttons in group. want different group of command buttons on same sheet execute different code. what route should take? when create firs

post processing - VTK: How to display only a particular range of data -

i have vtk file contains density values each cell. default, paraview displays density range. however, view density data within particular range , corresponding cells only. is possible view cells, fall in particular range? i have found way: view-> selection inspector in selection inspector, current object: (select grid want visualize) selection type: threshold field type: cell scalars: (select cell scalar visualize, in case: density) add thresholds -> lower: (set value) upper: (set value) display style->cell label tab visible; label mode: (select cell scalar visualize, in case: density) now done!

ios - Double KeyChainItemWrapper -

i have strange problem keychainitemwrapper. i used create 2 of them so: keychainitemwrapper *kcwrapper = [[keychainitemwrapper alloc] initwithidentifier:@"first" accessgroup:nil]; keychainitemwrapper *kcwrapper1 = [[keychainitemwrapper alloc] initwithidentifier:@"second" accessgroup:nil]; i set object this: [kcwrapper setobject:@"something" forkey:(__bridge id)ksecvaluedata]; [kcwrapper1 setobject:@"something1" forkey:(__bridge id)ksecvaluedata]; this worked perfectly, until... nothing changed? now error: *** assertion failure in -[keychainitemwrapper writetokeychain], /users/wingair/documents/iosprojects/tulipstempelkort- ios/stempelkort/../keychainitemwrapper.m:305 line 305 is: // no previous item found; add new one. result = secitemadd((__bridge cfdictionaryref)[self dictionarytosecitemformat:keychainitemdata], null); nsassert( result == noerr, @"couldn't add keychain item." ); been stuck here quite

html5 - Webkit Validation Bubble behaves like it has fixed position on Chrome -

i have form, first input required: <form> <input type="text" required> <input type="submit"> </form> users must scroll submit button: input[type="submit"] { margin-top: 150%; } if submit form, without filling in required field, viewport scroll top, , see html5 validation bubble. if scroll down again the submit button is, validation bubble remains fixed in place. i'd expect disappear or move upwards field it's attached to. this jsfiddle shows i'm talking about. what's going on here? seen before? i'm seeing on latest versions of chrome , chromium. doesn't happen on ff because bubble disappears interact page. it's same me in fx 23.0, document scrolls, bubble stays. guess because these elements not part of html document, rather overlays, , developers maybe didn't bother, forgot it, or it's bug. in chrome it's bug, because in opera 15.x (based on chromium)

XSLT If id has class -

i can't find anywhere. how can write if statement in xslt show words 'yes' if div id of 'cat' has class assigned called 'true'? if div in question current node, , don't know whether has id of 'cat' or class attribute, might write <xsl:if test=".[@id='cat' , contains(@class,'true')]"> yes </xsl:if> if you're in template matches on div[@id='cat'] , can use simpler test test="contains(@class,'true')" . (and conversely.) note test formulated succeed divs class="untrue" -- if that's issue situation, solution becomes bit messier. in xslt 1.0, simplest way write this: <xsl:if test=".[@id='cat' , contains(concat(' ', @class, ' '),' true ')]"> yes </xsl:if> in xslt 2.0, i'd write like: <xsl:if test=".[@id='cat' ,

windows ce - How do I filter and substitue TextBox characters during input in VB.net 2005 -

i have 2 textbox input fields must numeric only, limited 7 digits. however, target device has tiny keyboard shared numeric keypad accessible via numlock key, key 'e' doubles '1'. problem numlock enabled backspace/del key not work input difficult... fat fingers pushing wrong key, etc... so automatically convert 'e' '1', 'r' '2', etc, type. don't want see 'e' '1', has numlock pressed. has accept 0..9 if numlock pressed. substitute these characters: "ertdfgxcvertdfgxcv0123456789" these: "012345678901234567890123456789" is there easy way in vb.net-2005 ? you can use event; private sub textbox1_keypress(sender object, e keypresseventargs) handles textbox1.keypress dim counter integer = 0 each c char in "ertdfgxcvertdfgxcv" if e.keychar = c e.keychar = chr(48 + counter) end if counter += 1 if counter = 10 counter = 0

javascript - Interpret ember templates twice? -

i have template loops through array of navigation links. use ember linkto helper links. my template: <script type="text/x-handlebars" id="_sidenav"> <div id="sidenav"> <ul> {{#each model.sidenav}} <li>{{link}} <a> <i {{bindattr class="iconclass"}}></i><p>{{label}}</p> </a> </li> {{/each}} </div> </script> my model: [ { "label": "overview", "iconclass": "icon-overview", "link": "{{#linkto overview}}hello{{/linkto}}" }, { "label": "posts", "iconclass": "posts", "link": "{{#linkto totalenergy}}hello{{/linkto}}" } ] you can see have put linkto helpers in model, doesn't make sense, , of course te

least squares - Supressing Octave leasqr CONVERGENCE NOT ACHIEVED message -

i'm trying fit function using leasqr in octave. performs of time. sometimes, however, leasqr fails converge. (i'm not sure why, because solution comes looks fine). untill can figure out why it's not converging suppress output. whenever leasqr fails converge following warning: convergence not achieved! i've tried implementing answer this question, it's not working me. code looks this: pager('/dev/null'); page_screen_output(1); page_output_immediately(1); [fx.k1,fx.lambda1,fx.c1,... fx.k2,fx.lambda2,fx.c2] = peaktrack_expfit(t,mn,fnr,mode); how suppress these convergence messages?

images getting cut off in flexslider carousel -

i using woothemes flexslider carousel below slides , when clicking on next arrow, seems not moving on enough , cut off images. worked fine when had 7 images, once added 2 more images when issue appear. there need differently in css? http://dl.dropboxusercontent.com/u/2399619/walmart-careers/event-past-description.html thanks can give me. debbie

newrelic platform - sum of squares or square of total? -

according https://newrelic.com/docs/plugin-dev/metric-data-for-the-plugin-api plugins should report sum of squares specified period. taking @ json example, i'd more square of total value. e.g.: { "name": "primary mysql database", "guid": "com.your_company_name.plugin_name", "duration" : 60, "metrics" : { "component/productiondatabase[queries/second]": 100, "component/analyticsdatabase[queries/second]": { "min" : 2, "max" : 10, "total": 12, "count" : 2, "sum_of_squares" : 144 } } } obviously there 2 values, 2 , 10. according sample sum_of_squares (10+2)^2=144 define "square of total". me however, term "sum of squares" 2^2+10^2=104 . so when taking multi-value metrics - 1 correct number? you're absolutely right example values documented incorrect. i'll not

ios - I keep getting three errors when trying to define a character array -

errors instance variable declared type name requires specifier or qualifier expected ';' @ end of declaration list i can't figure out why happening. please help! here code : viewcontroller.m #import "evalviewcontroller.h" @interface evalviewcontroller () { digits[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; //errors: instance variable declared, type name requires specifier or qualifier, expected ';' @ end of declaration list } @end @implementation evalviewcontroller @synthesize terminal; @synthesize expression; //add ieval prefix output -(void)writetoterminal:(nsstring *)string { self.terminal.text = [nsstring stringwithformat:@"consolecalc> %@", string]; } - (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib. //define operation characters

javascript - how can I position objects in raphael.js related to center -

when set x, y values objects position them on paper, measures x, y top left corner. there way change position related center middle of paper? raphael has rectangles, circles, , ellipses. latter 2 positioned center coordinates, have nothing worry about. rectangle positioned based on top left corner coordinates so answer question: raphael not provide way position rectangle center coordinates. however can easily. @ demo . for example: // lets assume center coordinates cx , cy var rec = paper.rect(cx, cy, 120, 80); // position in middle, var rec = paper.rect(cx - 120/2, cy - 80/2, 120, 80); it simple that. luck! edit if want in project, raphael.js , override rectangle class.

wysihtml5 Dissable Parser Rules when pasting but enable for prepoluted text and typing? -

Image
using wysihtml5 editor, there way disable parser rules pasting, or paste plain text? such plain text, no tags or other formatting pasted? commenting out parser rule not work me because still want pre-populated text (with anchor , line-break tags) parsed parser rules. although not essential, editor detect urls , create anchors type, not when pasting. the reason want because lot of garbage characters (like new lines %0a , span tags) pasted when pasting using parser rules (specially msword, web content). pasting plain text prevent random hidden content being pasted. just reference, parser rules extremely simple: var wysihtml5parserrules = { tags: { br: {}, a: { set_attributes: { target: "_blank", rel: "nofollow" }, check_attributes: { href: "url" // important avoid xss } } } }; if want plain text time, go project scripts , find file wysihtml5-toolbar.min.js fin