Posts

Showing posts from May, 2010

c# - varchar column sorted by itself -

Image
i have table columns, columns varchar. have noticed rows in table sorted automatically. i, instead, want rows in same order inserted table. clues? please note haven't applied order by clause , dates same columns. as evident although added testing book 3 first, automatically came below testing book 2 not desired. is because pk composite? you did not specify rdbms using, can following regards microsoft sql server: you cannot guarantee predictable / repeatable ordering without order clause if want rows ordered when inserted, need to: add new column either identity (could int or bigint) or datetime / datetime2 datatype default constraint of getdate() or getutcdate() and order new field the new field has nothing pk. in reference suggestion else made. pk relationships, not sorting, , while identity typically used pk, there plenty of situations have pk of 1 or more non-auto-incrementing fields , still have auto-incrementing field. if need detail on millisecond

python - Subnavigation in Django -

i need subnavigation on pages. inherit base.html main navigation located, don't know how make subnavigation differs page page. i've thought making template tag in can specify items subnavigation in each template file, , output subnavigation if subnavigation items specified. how others it? why can't have separate block subnavigation , override block in child templates? base.html <a href="">calls</a> <a href="">messages</a> {% block subnav %} {% endblock %} calls.html {% extends "base.html" %} {% block subnav %} <a href="">outbound calls</a> <a href="">inbound calls</a> {% endblock %} messages.html {% extends "base.html" %} {% block subnav %} <a href="">sent messages</a> <a href="">recieved messages</a> {% endblock %}

slidetoggle - jQuery simle drop down menu . it doesnt work properly -

here code. class of .dropdown-menu menu botton (where release code when hover on it) , class .dropdown-menu li child thanks <script type="text/javascript"> jquery(document).ready(function(){ jquery('.dropdown-toggle').hover(function(){ jquery(this).children('.dropdown-menu').slidetoggle(); }); }); </script>

c# - Combo Box selected Item gives Exception -

i have combobox following items: 1024 2048 4096 8192 i using following code retrive item selected user: string cach = form.combocache.selecteditem.tostring(); but line giving exception null reference exception, object reference not set instance of object if line giving nullreferenceexception 1 of following true: form null form.combocache null form.combocache.selecteditem null either reason code work out of case, or put breakpoint on line , debug it, @ form in watch window. once you've worked out part null, need step , work out why it's null - because presumably expecting not null. don't have enough context here work out (we don't know kind of app you're writing - web, winforms etc) - it'll obvious debugger.

how to detect a metal using magnetic sensor in android phone? -

i want detect metal using magnetic sensor values. getting values continuously x=30.00 ,y=-20.00 ,z=-13.00 now want know how use these values detecting metal(mathameticalcalu,formulas) code is sensormanager = (sensormanager) getsystemservice(sensor_service); // compass sensor (ie magnetic field) mycompasssensor = sensormanager.getdefaultsensor(sensor.type_magnetic_field); float azimuth = math.round(event.values[0]); float pitch = math.round(event.values[1]); float roll = math.round(event.values[2]); to detect metal, have check intensity of magnetic field, i.e. magnitude of magnetic field vector. float mag = math.sqrt(x^2 + y^2 + z^2); then need compare value expected value of magnetic field @ location on earth. luckily, android provides functions so. @ geomagneticfield , reference here https://developer.android.com/reference/android/hardware/geomagneticfield.html then if value reading out of sensors quite far expected value, there's "something"

media player - Android MediaPlayer can't stop -

i have code fragment in brocardcastreceiver this: if (cmd != null && cmd.equals(play_sound)) { log.i("mp", "mp has been prepared "); mp.setlooping(true); mp.start(); return; } if (cmd != null && cmd.equals(stop_sound) && mp != null) { if (mp.islooping()) { mp.setlooping(false); } mp.stop(); mp.release(); return; } it aims control alarming or stop alarming. can make mp run successfully, when want stop it, mp null. how can stop mp being changed? try in code stopplaying(); and declare methode . private void stopplaying() { if (player1 != null) { player1.stop(); player1.release(); player1 = null; } }

How to get facebook profile picture of user in facebook SDK 3.0 Android -

i using facebook sdk 3.0 have profile picture of user login. here code use: url image_value = new url("http://graph.facebook.com/"+id+"/picture" ); profpict=bitmapfactory.decodestream(image_value.openconnection().getinputstream()); but don't desired result. you should change code following: url image_value = new url("http://graph.facebook.com/"+id+"/picture" ); possible parameters url can found here: https://developers.facebook.com/docs/graph-api/reference/user/picture/

php - PHP_Uml to XMI to UML Diagram on Ubuntu / Linux -

i using php_uml pear package , created xmi in version 1 , 2. unfortunately argouml not parse xmi 1 correctly, , xmi 2 fails "new" argo. phpuml . -x 1 -o project.xmi is there tool has correct uml2, can reverse engineering and, especially, forward engineering in php 5.3 , above? i appreciate free or costs , runs under linux / ubuntu (without wine, mono etc.). using phpstorm. that's necessary, because can't manipulated. you may want try fully-functional , free 30 day trial of mapforce ( http://www.altova.com/mapforce.html ). far know, can convert xmi uml2 correctly.

android - why views do not appear when we use thread -

protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); this.requestwindowfeature(window.feature_no_title); setcontentview(r.layout.activity_welcome); new thread(new btthread()).start(); } in btthread, there public void run() method thread.sleep(3000)first , jump activity. during first activity time, cannot see content of activity_welcome. if ideas this, appreciate have help. you can't start new activity on thread other main thread. if btthread inner class of activity can call runonuithread(new runnable() { public void run() { //startactivity } });

swing - Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError -

i trying read .docx file jtextpane , giving exception. using poi library. should do? me out, please. here code: file = new file( "c:\\users\\siddique ansari\\documents\\cv parser\\siddique_resume.docx"); fileinputstream fis=new fileinputstream(file.getabsolutepath()); xwpfdocument document=new xwpfdocument(fis);// line no 549 extractor = new xwpfwordextractor(document); string filedata = extractor.gettext(); document doc = jtextpane1.getdocument(); system.out.println(filedata); doc.insertstring(doc.getlength(), filedata, null); and exception : exception in thread "awt-eventqueue-0" java.lang.noclassdeffounderror: org/apache/xmlbeans/xmlexception @ cvparser.excelsheet.jbutton3actionperformed(excelsheet.java:549) @ cvparser.excelsheet.access$400(excelsheet.java:39) @ cvparser.excelsheet$5.actionperformed(excelsheet.java:219) @ javax.swing.abstractbutton.fireactionperformed(abstractbutton.java:1995) @ javax.swing.abstractbutton$handler.action

android - Xperia Z full screen camera preview? -

i coding app android uses surfaceview class realize camera preview, works on nexus galaxy , desire hd the surface view layout width/height attribute match_parent but encountered problem: on sony xperia z , screen resolution 1080p , largest preview resolution 1280*720 thus, camera preview occupies part of full screen , other space blank. how can make preview full screen ? resize surfaceview in landscape mode: // float camera_ratio = preview_size.width * preview_size / height; viewgroup.layoutparams params = surfaceview.getlayoutparams(); params.height = surfaceview.getholder().getsurfaceframe().height(); params.width = math.round(camera_ratio * params.height); surfaceview.setlayoutparams(params); or switch around parameters if app in portrait mode. edit: holy moly, sorry resurrecting half year old question!

ios - Hiding tab bar on one view in Xcode storyboard -

i have tab bar application hide tab bar 1 of views exchange toolbar. using storyboard , setting bottom bar none , dragging in toolbar looks way want on storyboard. when run tab bar doesn't go away. it wont work because simulate view when tabbar hidden. if want hide tabbar have programmatically. see answer iphone: possible hide tabbar? and try use hidetabbar method in viewwillappear, , showtabbar in viewdiddisapear.

Android Image upload to C# .NET REST service -

i know question has been asked lot on stackoverflow , on internet, seems there never common or best solution upload image multi-platform .net rest service. i have found solution question asked before here service side, first question is, best , optimized way upload image android specific service specified in link ? my second question is, how can add json data accompany image being uploaded? have seen solutions of appending data in header param , not json? perfect way ? i have few proposals while uploading file web service: write web serivice allow multi part file upload using multipartformdatastreamprovider dont read whole file content while uploading web service. rather use httpclient library upload mutiple part content. see multipartentity . httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("service url"); filebody body1 = new filebody(new file(path), mimetype); multipartentity reqentity = new multipartentity(); reqen

c++ - Is in-class initialization "real" when it appears? -

c++11 introduced this: struct myclass { int foo = 0; //* }; until i've been using without thinking it, i'm wondering: is initialization doing/executing actual initialization @ particular line ( //* in code), or mere convenience notation does/executes later , when object constructed? not sure mean "later" , "at particular line", above equivalent following: struct myclass { myclass() : foo(0) { } }; so if understand question correctly, answer is: "yes, when object constructed".

ruby on rails - Pass data between two controllers but not via url as params -

below code <% if @user.empty? == true %> <p> sorry no data display</p> <%else%> <% @user.each |n|%> user id = <%=n.id%> <br \> user type = <%=n.type%> <br \> user name = <%= n.name%> <br \> <%= link_to "good. can proceed on creating new", new_user_product_path(current_user)%> <%end%> <%end%> this code under searches#index . can see, after set of results shown, want user able create new product. when creating product, want make sure <%= n.name%> pass on new_user_product_path(current_user) (its form). not via url. the form field want populate is <%= f.hidden_field :user_name%> so, how do it? thanks i think found solution i made <%=n.name%> <% $name = n.name %> , since global variable, accessible now.

Double jQuery form trigger -

i having problem earlier jquery having submit() handler triggered twice. made test file basic submit event handler , worked fine yet following code not work: $(document).ready(function(){ $('#regform').submit(function(e){ e.preventdefault(); $('#regform').fadeto('slow', 0, function(){ $('#regform').css('display', 'none'); $('#mainbox').animate({height: 90}, 100); $('#one, #two, #three #four').fadeto('slow', 0, function(){ $('#one').html('processing...').fadeto(300, 1, function(){ $.post("/data/handles/account/register.php", {user: $('#user').val(), pass: $('#pass').val(), passc: $('#passc').val(), email: $('#email').val()}, function(data){ if (data.error == 8) { alert('yes');

r - Adding abline to augPred plot -

apologies basic question, new r. i looking read off augpred plot in order average out values provide prediction between time period. > head(tthm.groupeddata) grouped data: tthm ~ yearmon | wsz_code wsz_code treatment_code year month tthm cl2_free bro3 colour ph turb yearmon 1 2 3 1996 1 30.7 0.35 0.00030 0.75 7.4 0.055 jan 1996 2 6 1 1996 2 24.8 0.25 0.00055 0.75 6.9 0.200 feb 1996 3 7 4 1996 2 60.4 0.05 0.00055 0.75 7.1 0.055 feb 1996 4 7 4 1996 2 58.1 0.15 na 0.75 7.5 0.055 feb 1996 5 7 4 1996 3 62.2 0.20 na 2.00 7.6 0.055 mar 1996 6 5 2 1996 3 40.3 0.15 0.00140 2.00 7.7 0.055 mar 1996 this model: modellme<- lme(tthm ~ yearmon, random = ~ 1|wsz_code, data=tthm.groupeddata) and current plot: plot(augpred(modellme, order.groups=t),xlab="date", ylab=&qu

Android: Checking Background Resource Drawable -

please how can background resource check? example: button button1; protected void oncreate(bundle savedinstancestate) { .......................................... button1 = (button) findviewbyid(r.id.example1); } public void onclick1 (view v){ button1.setbackgroundresource(r.drawable.example2); } public void onclick2 (view v){ my question here, checking if button1 button drawable = example2 if (..........................){ //action } if not, when clicked done action else { //another action } } you can use getbackground() method of view class both buttons , compare this: if (button1.getbackground().getconstantstate().equals(button2.getbackground().getconstantstate())) { } else { }

c# double modulus returns 0 with "Optimize Code" turned on -

so made own struct represent angle values, convenience methods. however, while works in debug mode, when turning on optimizations in release mode, code behaves differently. missing something? change when it's jitted? it's .net 3.5 project in vs2010. basically following: func<double, double> fromdegrees = degrees => degrees*math.pi/180; double value = fromdegrees(9); double period = math.pi*2; double newangle = (value % period + period) % period; // newangle 0! a more complete example: public struct angle { public readonly double value; public const double angulartolerance = 0.001; // 0.06 degrees public static readonly angle fullrotation = (angle) (math.pi*2); public angle(double angle) { value = angle; } public static angle fromdegree(double degrees) { return (angle) (degrees*math.pi/180); } public angle normalizerotation(angle? period = null) { period = period ?? f

install4j: Using environment variable for file chooser default -

i adding file chooser on form , want default initial directory environment variable. if specify ${my_env_varb}, don't see being populated (install4j version 5.1.5) environment variables not supported in text field expressions, have add "set variable" action "variable name" of "myvar" , script of system.getenv("my_var") and use syntax ${installer:myvar}

python - How do I find the most common words in multiple separate texts? -

bit of simple question really, can't seem crack it. have string formatted in following way: ["category1",("data","data","data")] ["category2", ("data","data","data")] i call different categories posts , want frequent words data section. tried: from nltk.tokenize import wordpunct_tokenize collections import defaultdict freq_dict = defaultdict(int) cat, text2 in posts: tokens = wordpunct_tokenize(text2) token in tokens: if token in freq_dict: freq_dict[token] += 1 else: freq_dict[token] = 1 top = sorted(freq_dict, key=freq_dict.get, reverse=true) top = top[:50] print top however, give me top words per post in string. i need general top words list. if take print top out of loop, gives me results of last post. have idea? why not use counter ? in [30]: collections import counter in [31]: data=["category1",("data&qu

objective c - Enforce initializing superclass's ivar after calling superclass's init method -

i need enforce initialization of ivar in superclass ivar can not initialized without other data in subclass initialized. 2 solutions have thought of is: pass required generated key ivar superclass's init method calling second superclass method subclass's init method here example (contrived, non-working) code. stringbasedonsubclasskey ivar should initialized nsstring subclass's key method. @interface mysuperclass : nsobject @property (nonatomic, readonly) nsstring *stringbasedonsubclasskey; @end @interface mysubclass : mysuperclass @property (nonatomic, assign, readonly) int value; @end @implementation mysubclass - (instancetype)init { if (self = [super init]) { _value = 30; } return self; } - (nsstring *)key { return [nsstring stringwithformat:@"uniquekey-%d", self.value]; } so question is there way enforce initialization of stringbasedonsubclasskey ivar using return value of "key" method? don't b

c# - Search results xml, c # - Windows Application Store -

good day, creating app bible, i'm having trouble searching verse ("v"). have created whole structure can filter book ("b"), loads list of chapters ("c"), when select chapter, creates list , loads verses. want put code when user clicks on list number, displayed text of verse. xml <?xml version="1.0" encoding="utf-8"?> <bible> <b n="gênesis" indice="1"> <c n="1"> <v n="1">text text</v> <v n="2">text text text</v> </c> <c n="2"> <v n="1">text text</v> <v n="2">text text text</v> </c> <b n="Êxodo" indice="2"> <c n="1"> <v n="1">text text</v> <v n="2">text text text</v> </c> <c n="2">

list - c#: Object reference not set to an instance of an object -

this part of code. list<datetime>[] newarraydate1 = new list<datetime>[70]; datetime temp1 = arraydate1[k][aa]; newarraydate1[k].add(temp1); i used messagebox.show(temp1) , there value in temp1. error shown on first line of program. when create array, create containing structure. members initializeded default values, in case of list<datetime> null . essentially, seventy null references, each 1 capable of holding list of datetime . to fix this, should either assign new arrays in loop list<datetime>[] newarraydate1 = new list<datetime>[70]; (int = 0 ; != newarraydate1.length ; i++) { newarraydate1[i] = new list<datetime>(); } or use linq: list<datetime>[] newarraydate1 = enumerable .range(0, 70) .select(n => new list<datetime>()) .toarray();

OOP - objects and instances -

this question has answer here: difference between object , instance 18 answers i have seen lot of posts objects, classes , instances , have become little confused. need clarification following example. say create game, has 3 menus: main menu, level menu option menu. now define class called gamemenu since these menus have titles , instructions , buttons etc... instantiate menus using class example: mainmenu = gamemenu(); levelmenu = gamemenu(); optionmenu = gamemenu(); and pass parameters titles , button labels , such inside brackets - in context of example right in saying class gamemenu , objects collectively mainmenu , levelmenu , optionmenu , , instances 1 specific object mainmenu instance, optionmenu instance , levelmenu instance. that taught, means objects , instances exact same things in case terms object , instance synonyms each other n

regex - Javascript: is this the right way to use a regular expression to replace multiple parts of a string? -

i curious regular expressions and, being new programming wondering if there problems (or better way) of replacing different parts of same string in fashion: str2.replace(/hanna/ig, 'clark').replace(/anna/ig, 'ark') for example: html: <p id="test2" onclick="fixit2()">hanna hanna bobanna banana nana fo fanna</p> javascript: function fixit2() { var str2 = document.getelementbyid('test2').innerhtml; alert(str2); alert(str2.replace(/hanna/ig, 'clark').replace(/anna/ig, 'ark')); } i have been working on here: http://jsfiddle.net/a2lkd/6/ well, if achieves want there no problem... using regular expressions replace patterns in strings common practice. should make sure regular expression using right 1 task. please note strings immutable , new string returned replace operations. original string not modified.

Event binding with jquery live() function -

first here code: html: <div id="foreground"> <button type="button" id="go">start</button> </div> <div id="background"> <p>you on background</p> </div> js: $(function () { $("#go").click(function (e) { var $q = $(this); var $vazy = $('<button type="button" id="vazy"> vazy </button>'); var $loc = $('<input type="text" id="placename" placeholder="location"/>'); $vazy.insertafter($q); $loc.insertafter($q); $q.hide(); e.stoppropagation(); }); $("#vazy").live("click", function () { alert('k'); //$("#foreground").hide(); //$("#background").show(); }); }); css: #background { display: none; } jsfiddle... the problem @ line 15 button id #v

c# 4.0 - Metro App UI ProgressRing does not update and UI hangs -

i have button named bexecute , it's click event handler has body: try { // activate progress ring prprogress.visibility = visibility.visible; prprogress.isactive = true; bexecute.isenabled = false; // task dotask(); } catch(exception ex) { // } { // stop progress ring prprogress.visibility = visibility.collapsed; prprogress.isactive = false; bexecute.isenabled = true; } this method has these problems: the ui appears hang until task completed , resumes per normal. progressring never appears activated. the bexecute button never appears enabled/disabled. i can wrap doexecute() in task.run() method, frees ui , never see progressring , nor see bexecute being enabled/disabled. any suggestions? i guess dotask() cpu intensive method taking long time complete. way you're doing now, executes on ui thread , blocks. should wrap in task.run() call suggested, need await it, otherwise rest of event handler exec

xcode - 'Install App' AppStoreView like the Facebook App for iOS has it -

Image
i want know if there known possibility add such 'appstoreinstallview' app can, without using sharedapplication open appstore, ask user install new app. people don't know how works: 1:you see 'ad' , click on bottom install-now button (it says 'jetzt installieren' (this german screenshot)) 2:a view slides in , opens appstore page of shown app 3:to install app need press install, native appstore app, asked enter password , proceeds download app. i tried webview, didn't work, either won't load webpage or redirect me (via sharedapplication suppose) native appstore app. so know how implement such feature in own app? see here more information regarding topic you'll want use skstoreproductviewcontroller . there's excellent reference here , essentials will from article, can use code: - (ibaction)showstoreview:(id)sender { skstoreproductviewcontroller *storeviewcontroller = [[skstoreproductview

i can't see more my global object created by Components.utils.import("resource://gre/modules/myfile.jsm") in firefox 17 -

i have used next code create myglobalobject in multiwindows application in firefox 15- . netscape.security.privilegemanager.enableprivilege("universalxpconnect"); components.utils.import("resource://gre/modules/myglobalobject.jsm"); my file myglobalobject.jsm simple: var exported_symbols = [ "myglobalobject" ]; if ("undefined" == typeof(myglobalobject)) { var myglobalobject = {}; myglobalobject[0]=1; } since firefox 17+ code doesn't operate. have created add-on next main.js: exports.main = function() { var { cu } = require("chrome"); cu.import("resource://gre/modules/myglobalobject.jsm"); }; nevertheless can't access myglobalobject in javascript-code inside of application. in misunderstanding programming firefox 17+ consists? when creating add-ons add-on sdk, cu.import() won't recognize scope of package correctly. means have assign exported symbols explicitly : var {cu} = r

MySQL insert with autoincrement - is insert ignore neccessary to avoid concurrency issue? -

i using simple insert statement in mysql innodb, auto-increment in primary id. need worry if user , user b execute same script @ same moment, user a's insertion overwritten user b's? no, not. can treat thread safe. from reference: when accessing auto-increment counter, innodb uses special table-level auto-inc lock keeps end of current sql statement, not end of transaction http://dev.mysql.com/doc/refman/5.1/en/innodb-auto-increment-handling.html

c - Android ndk. Can't get reference to JVM -

a couple of days ago started having fun android ndk. trying compile 1 of sample programs book little problem arised. so here need obtain reference javavm. // global env ref (for callbacks) static javavm *g_vm; jniexport jint jnicall java_jni_natives_libmain (jnienv * env, jclass class, jobjectarray jargv) { // obtain global ref caller jclass (*env)->getjavavm(env, &g_vm); ... eclipse says " method 'getjavavm()' not resolved " every other line containing methods of (*env) object . includes directory has path: c:\programs\ide\adt-bundle-windows-x86_64-20130219\android-ndk-r8e\platforms\android-14\arch-arm\usr\include don't think might include paths, can wrong. are compiling .cpp file? <jni.h> has different jnienv implementations c , c++, , you're using c version. in c++ code this: jniexport jint jnicall java_jni_natives_libmain (jnienv * env, jclass class, jobjectarray jargv) { // obtain global ref calle

iphone - Google Now like interface on iOS -

so, absolutely love google now's cards interface on android.. , has come ios. is there tutorial, or sample project out there can me create cards interface ios applicaion? from research, have been able replicate "stacked" cards using custom uicollectionviewflowlayout. - (nsarray *)layoutattributesforelementsinrect:(cgrect)rect { nsarray *allattributesinrect = [super layoutattributesforelementsinrect:rect]; cgpoint centerpoint = cgpointmake(cgrectgetmidx(self.collectionview.bounds), cgrectgetmidy(self.collectionview.bounds)); (uicollectionviewlayoutattributes *cellattributes in allattributesinrect) { if (cgrectcontainspoint(cellattributes.frame, centerpoint)) { cellattributes.transform = cgaffinetransformidentity; cellattributes.zindex = 1.0; } else { cellattributes.transform = cgaffinetransformmakescale(0.75, 0.75); } } return allattributesinrect; } t

How to fill cells from sheet A with values from sheet B when ID matches (in Excel)? -

consider following 2 sheets. sheet aaa has list of companies emptry column roa . sheet bbb has roa value of these companies. sheet aaa b 1 id roa 2 1 3 2 4 3 5 4 sheet bbb b 1 id roa 2 1 60.40 3 3 10.10 4 4 9.00 looking @ id in both sheets, need formula fill in column aaa.b , resulting in b 1 id roa 2 1 60.40 3 2 4 3 10.10 5 4 9.00 what formula need in cell aaa.b2 (and down) done? believe vlookup function appropriate here, unsure how use in case? use lookup function match , isna: =if(isna(match(a1,sheet2!$a$1:$a$3,0)),"",lookup(a1,sheet2!$a$1:$a$3,sheet2!$b$1:$b$3))

math - I am getting NaN for an answer to my quadratic equation calculator- JAVA -

this main class: import java.util.scanner; public class calc { public static void main(string[] args){ scanner variablea = new scanner(system.in); scanner variableb = new scanner(system.in); scanner variablec = new scanner(system.in); int a1, b1, c1; system.out.println("enter 'a' variable"); a1 = variablea.nextint(); system.out.println("enter 'b' variable"); b1 = variableb.nextint(); system.out.println("enter 'c' variable"); c1 = variablec.nextint(); algorithm algorithmobject = new algorithm(); algorithmobject.algorithm(a1, b1, c1); } } and second one public class algorithm{ public void algorithm(int a, int b, int c){ double x1; double square = math.sqrt(b*b - 4*a*c); double numerator = b*-1 + square; double finalanswer = numerator/2*a; system.out.println(finalanswer); } } eclipse doesn't give me errors, after asks 3 variables , enter th

asp.net - Entity framework (code first), many to many, users and roles -

i got mvc 3 application custom membershipprovider, stores newly registered users database. i'm using code first approach existing database (i've used entity framework power tools this). got tables users, roles , usersroles. in table users got: userid (pk) username password email ... in table roles got roleid (pk) name description in table usersroles got userid (set composite pk) roleid (set composite pk) public partial class user { public user() { this.roles = new list<role>(); } public int userid { get; set; } public string username { get; set; } public string password { get; set; } public string email { get; set; } public virtual icollection<role> roles { get; set; } } public partial class role { public role() { this.users = new list<user>(); } public int roleid { get; set; } public string name { get; set; } public string description { get; set; } public virtual icolle

java - How to write hashCode method for a particular class? -

i'm trying generate hashcode() method simple class i'm not getting anywhere it. appreciate help. i've implemented equals() method, looks follows, , know if need implement compareto() method. i've imported java.lang.character use character.hashcode() doesn't seem work. private class coord{ private char row; private char col; public coord(char x, char y){ row = x; col = y; } public coord(){}; public char getx(){ return row; } public char gety(){ return col; } public boolean equals(object copy){ if(copy == null){ throw new nullpointerexception("object entered empty"); } else if(copy.getclass()!=this.getclass()){ throw new illegalargumentexception("object entered not coord"); } else{ coord copy2 = (coord)copy; if(copy2.row==this.row && copy2.col==this.col) retu

javascript - JS slidetoggle on UL -

i trying slidetoggle ul's. stuck. here question: those codes working: <div class="splitleft" onclick="toggle_item(b)"> <?php echo $admin_logs ?> <ul class="menu" id="b"> <li><a href="index.php?content=admin&page=show_logs_all"><?php echo $admin_logs_desc ?></a></li> <li><a href="index.php?content=admin&page=show_logs_player"><?php echo $admin_watch_players ?></a></li> <li><a href="index.php?content=admin&page=show_logs_admins"><?php echo $admin_watch_admins ?></a></li> </ul> </div> <script>function toggle_item(e){$(e).slidetoggle();}</script> but don't want it. want this: <ul class="menu" onclick="toggle_item(b)" id="b"> <li><a href="

java - HashMap get an element and set into customized value type -

i have problem while set element , set customized value type. here customized type class user public class user { private list<integer> friendlist=new arraylist<integer>(); //uid list private hashmap<string,string> checkinmap =new hashmap<string, string>(); // location , time private int uid; public user(int uid){ this.uid=uid; } public int getid(){ return uid; } public void setcheckins(hashmap<string,string> inmap){ this.checkinmap=(hashmap<string, string>) inmap; } public void setafriend(int uid){ this.friendlist.add(uid); } } then, parse json array data, sure parsing json fine here. hashmap<integer,user> usermap =new hashmap(); hashmap<string,string> inmap =new hashmap(); for(i=0;i<users.size();i++){ jsonobject auser=(jsonobject)users.get(i); temp_uid=integer.parseint(auser.get("uid").tostring()); usermap.put(temp_uid, new user(temp_uid)

android - Add new string to resource string array dynamically -

im making workout log , want ther user able add new exercise types. i made string array in resources , spinner take strings string array in resources. im not sure how add new string resources string array java code. tried code, exception. thanks helping :) public void onclick(view v) { switch(v.getid()){ case r.id.setnewexercise: string[] exercisestringarray = getresources().getstringarray(r.array.exercisetypes); arrayadapter<charsequence> list = arrayadapter.createfromresource(this, r.array.exercisetypes, android.r.layout.simple_list_item_1); string exercisecheck = addnewexercise.gettext().tostring(); try{ (int = 0; < exercisestringarray.length; i++) { if (exercisecheck.equals(exercisestringarray[i])) { toast.maketext(getapplicationcontext(), "this exercise exist", toast.length_long).show(); break; } else if (i == exe

php - array_splice removing more than one item -

i have following method: public function selectfinal(){ $db = new database(); for($i = 0; $i < 5; $i++){ $key_id = mt_rand(0, count($this->candidates) - 1); $itm = $this->candidates[$key_id]; $host = $itm["host"]; $item = $itm["item"]; $db->query("insert ignore trends (trend_id, host, item) values (?, ?, ?)", array($this->nextid, $host, $item)); array_splice($this->candidates, $key_id, -1); print_r($this->candidates); $this->nextid++; } } for print_r() getting output: array ( [0] => array ( [host] => www.youtube.com [item] => iytnbm8wa1c ) [1] => array ( [host] => www.youtube.com [item] => kffacxfa7g4 ) [2] => array ( [host] => www.youtube.com [item] => kxyiu_jcytu ) [3] =>

c# - Parsing JSONObject -

i trying json webservice , able figure out . btw json data - { "x-yz-111/ab.cd": { "p1": "f", "p2": "43.46" }, "x-yz-112/ab.cd": { "p1": "f", "p2": "8.02" }, "x-yz-113/ab.cd": { "p1": "f", "p2": "9066.58" }, "x-yz-114/ab.cd": { "p1": "f", "p2": "6.00" }, "x-yz-115/ab.cd": { "p1": "f", "p2": "6.00" }, "x-yz-116/ab.cd": { "p1": "f", "p2": "10.00" }} using windows.data.json; private async void getjson_click(object sender,routedeventargs e) { var client=new httpclient(); client.maxresponsebuffersize=1024*1024; var

regex - Regular expression Capture and Backrefence -

here's string i'm searching. t+4accgt+12caagtactaccgt+12caagtactaccgt+4accga+6ctaccgt+12caagtactaccgt+12caagtactaccg i want capture digits behind number x digits (x being previous number) want capture complete string. ie capture should return: +4accg +12aagtactaccgt etc. and : accg aagtactaccgt etc. here's regex i'm using: (\+(\d+)([atgcatgcnn]){\2}); and i'm using $1 , $3 captures. what missing ? this loop works because \g assertion tells regex engine begin search after last match , (digit(s)), in string. $_ = 't+4accgt+12caagtactaccgt+12caagtactaccgt+4accga+6ctaccgt+12caagtactaccgt+12caagtactaccg'; while (/(\d+)/g) { $dig = $1; /\g([tagcn]{$dig})/i; $1; } the results are accg caagtactaccg caagtactaccg accg ctaccg caagtactaccg caagtactaccg i think correct not sure :-| update: added \g assertion tells regex begin after last matched number.

android - Trying to read NFC NDEF Payload in PhoneGap -

i found similar answer question here given new both phonegap , nfc, wondering if can me? i able read nfc tag (type="text") don't know how extract payload data (text) tag read. in logcat receive following message e.tag = {"iswritable":true,"id":[4,72,-35,98,93,43,-128],"techtypes": ["android.nfc.tech.nfca","android.nfc.tech.mifareultralight", "android.nfc.tech.ndef"],"type":"nfc forum type 2","canmakereadonly":true,"maxsize":142, "ndefmessage":[{"id":[],"type":[116,101,120,116,47,112,108,97,105,110], "payload":[110,117,108,108],"tnf":2}]}; i can't figure out how convert bytearray string. there simple way me this? using phonegap nfc plugin https://github.com/chariotsolutions/phonegap-nfc hope can help! thanks! i able solve problem using phonegap nfc plugin. extracted payload tag read using 1st

ios - Selections not occurring when UISearchDisplayController is being used -

i using uiseachdisplaycontroller uitableview. set programatically in viewdidload method uitableviewcontroller: - (void)viewdidload { [super viewdidload]; [self loadprojectsandtitles]; searchbar = [[uisearchbar alloc] initwithframe:cgrectmake(0, 0, 600, 44)]; searchdisplaycontroller = [[uisearchdisplaycontroller alloc] initwithsearchbar:searchbar contentscontroller:self]; searchdisplaycontroller.delegate = self; searchdisplaycontroller.searchresultsdatasource = self; searchdisplaycontroller.searchresultstableview.allowsselection = true; self.tableview.tableheaderview = searchbar; } everything working absolutely fine except when click on row when uisearchbar being used, - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath method not being called although being called when uisearch not being used. question is normal behaviour or should selection m

android - Display big image in ImageView -

if choose big picture such it is gallery , try display in imageview, imageview not display it. public class colorvieweractivity extends activity { // skip other methods private static final int select_photo_request = 100; @override public boolean onoptionsitemselected(menuitem item) { switch (item.getitemid()) { case r.id.open_image: selectimage(); break; } return true; } private void selectimage() { intent photopickerintent = new intent(intent.action_pick); photopickerintent.settype("image/*"); startactivityforresult(photopickerintent, select_photo_request); } @override protected void onactivityresult(int requestcode, int resultcode, intent imagereturnedintent) { super.onactivityresult(requestcode, resultcode, imagereturnedintent); switch(requestcode) { case select_photo_request: if (resultcode == result_ok) {

vb.net - Why am I getting a type name instead of the text from my textbox? -

Image
so making program here. it's simple hotel reservations program. how structured. i'm having trouble passing info across forms. example, have total amount qty being called in new form's textbox , getting system.windows.forms.textbox, text: $1,200.00. so, i'm getting amount alright rest of garbage well. :( my code, private sub form3_load(byval sender system.object, byval e system.eventargs) handles mybase.load ' gives first textbox focus me.activecontrol = cctypecombobox amounttextbox.text = form2.totaltextbox.tostring() end sub bingo! change: amounttextbox.text = form2.totaltextbox.tostring() to: amounttextbox.text = form2.totaltextbox.text

templates - Wordpress comments children customization to work with bootstrap? -

i have been searching whole day how customize comments template on wordpress. im working on new wordpress theme , trying build using bootstrap. @ end comment template got me stuck. i never liked how wordpress customize comments , pain customize it, , twitter bootstrap have nice comment nesting using media list. but problem wordpress use different nesting children comments. what have rendering on template this <div id=comments"> <ul class="media-list"> <li id="comment-124" class="media"> <div class="avatar pull-left"> avatar image </div> <div class="media-body"> <div class="media-heading"> comment info time when posted </div> <p> comment text </p> </div> </li> <ul class="children"> , children commen

windows phone 7 - AppBar button stlye -

in windows store apps there appbarbuttonstyle s nice round button ones mentioned here . is there simple way styles wp7? i found tutorials on net ( like this ), , 3rd party libraries (e.g. http://coding4fun.codeplex.com/ ) feels there should standard simple way of doing without getting complex. there? the roundbutton coding4fun toolkit job fine. there no built-in component in windows phone sdk. also, remember way appbar operates in windows store , windows phone 8 apps different at core , same interaction , building ideas don't apply.

Kendo UI upload file size limit using ASP.NET MVC? -

i using mvc.net kendo ui. have implemented kendo ui upload, , works fine. need able upload large file, around 200mb. updated maxrequestlength , executiontimeout properties in web.config file. when upload 90mb file, waits while errors out, has else managed upload large file using kendo ui? thanks did updated maxallowedcontentlength? if yes, , problem still unresolved, post server response here? (you can catch using fiddler)

c# - Get cookies from httpwebrequest -

i'm trying cookies website using code cookiecontainer cookiejar = new cookiecontainer(); var request = (httpwebrequest)httpwebrequest.create("http://www.foetex.dk/ugenstilbud/pages/zmags.aspx"); request.cookiecontainer = cookiejar; var response = request.getresponse(); foreach (cookie c in cookiejar.getcookies(request.requesturi)) { console.writeline("cookie['" + c.name + "']: " + c.value); } console.readline(); the thing want display console.writeline, im not getting single of them. the following example uses httpcookie class , properties read cookie specific name. httpcookie mycookie = new httpcookie("mytestcookie"); mycookie = request.cookies["mytestcookie"]; // read cookie information , display it. if (mycookie != null) response.write("<p>"+ mycookie.name + "<p>"+ mycookie.value); else

node.js - ReferenceError: t is not defined -

i have code index.coffee on express.js / blade.js template using i18next library express = require "express" gzippo = require "gzippo" assets = require "connect-assets" jspaths = require "connect-assets-jspaths" #stylus = require "stylus" blade = require "blade" i18n = require "i18next" http = require "http" https = require "https" fs = require "fs" json = "" #### application initialization # create app instance. app = express() # define port app.port = process.env.port or process.env.vmc_app_port or process.env.vcap_app_port or 3000 # config module exports has `setenvironment` function sets app settings depending on environment. config = require "./config" app.configure "production", "development", "testing", -> config.setenvironment app.settings.env # i18next init i18n.init detectlngqs: "lang" ,ns: { names