Posts

Showing posts from August, 2010

python - Why is operator giving different output for immutable objects? -

python - Why is operator giving different output for immutable objects? - this question has reply here: why comparing strings in python using either '==' or 'is' produce different result? 11 answers the code "python" "python" returns true . why (1,2,3) (1,2,3) homecoming false ? though both immutable objects, is operator evaluating differently. why? the operators is , is not test object identity: x y true if , if x , y same object. x not y yields inverse truth value. you can think of identity object’s address in memory. 2 tuple same index have different address ! and in case based on interpreter , above stuff in interpreter equal strings point 1 memory address for improve understanding see below demo: >>> a=(0,1) >>> b=a >>> b true >>> c=(0,1) >>> c false pyth

Does the Django Rest APIClient class make an actual request? -

Does the Django Rest APIClient class make an actual request? - i wondering if request beingness made via http. in app have test looks like class authenticate(apitestcase): def setup(self): self.client = apiclient() self.password_for_admin = '123456' self.admin = user.objects.create_superuser(username='myname', email='email@email.com', password='123456') self.token = token.objects.create(user=self.admin) def test_authenticate(self): """ comment """ self.client.credentials(http_authorization='basic ' + base64.b64encode('{}:{}'.format(self.admin.username, self.password_for_admin))) response = self.client.post('/api/authenticate/') print response and in view i've got: @api_view(('post',)) def authenticate(request, format=none): """ comment """ import pprint log.deb

powershell - $Host.UI.Prompt() is ignoring the attribute 'DefaultValue' in FieldDescription -

powershell - $Host.UI.Prompt() is ignoring the attribute 'DefaultValue' in FieldDescription - i trying user input, , homecoming default value if no input given. i going $host.ui.prompt , since according msdn ( pshostuserinterface.prompt method ) should provide functionality - or thought. in short: $host.ui.prompt method accepts collection of fielddescription objects. each of objects can assigned defaultvalue attribute, supposed returned when no input given user specific field. i've got working desired, except default value part. to see if messed script, tried illustration scripts internet, this one: $host.ui.promptforchoice works fine, value defaultchoice returned expected when create no choice. $host.ui.prompt won't provide assigned defaultvalue s expected. like, default value not shown on prompt, , when nail come in without input given, empty/zero results. interestingly enough, when run exact script in powergui, gui popup shows assigned

html - Changes in footer background after editing in upper -

html - Changes in footer background after editing in upper <div> - hi first of , stackoverflow new html , css downloaded free website template net want editing did something, when removing upper div class footer background shrink total width main width , of changes happening in footer. ![before editing template][1] html of before editing <!doctype html> <html> <head> <meta charset="utf-8"> <title>wood working website template</title> <link rel="stylesheet" href="css/style.css" type="text/css"> </head> <body> <div id="header"> <div> <div id="logo"> <a href="index.html"><img src="images/logo.png" alt="logo"></a> </div> <ul id="navigation"> <li class="selected"&

sql - Determine correct column in dataset -

sql - Determine correct column in dataset - i need remap info export. info beingness pulled multiple tables view. in view pertinent columns , illustration values are: size_bucket size_desc 2 xs 3 s 4 m 5 l 6 xl size bucket corresponds column in table contains various size descriptions; example: size02 size03 size04 size05 size06 xs s m l xl the problem export, values of size_bucket wrong , don't correspond related sizexx column in other table. have table right mappings contain right values various sizexx columns. what need determine column contains right value , switch out value of size_bucket right corresponding sizexx column. so right values in mapping table have size02 size03 size04 size05 size06 size07 xxs xs s m l xl finally, here sample psuedo query i

google chrome - Flash Builder can't find PPAPI flash debugger -

google chrome - Flash Builder can't find PPAPI flash debugger - i able flash builder work npapi version of debugger, have installed chrome 64-bit (v 38.0.2125.101), seems work ppapi version found here. version installed error message: c:\program files (x86)\google\chrome\application\plugins\npswf32.dll flash builder cannot locate required version of adobe flash player. might need install flash player or reinstall flash builder. want seek run application current version? that directory doesn't exist, , doesn't ever did, have no thought why flash builder looking there, or how tell elsewhere. google-chrome flash-builder

multithreading - Connecting to Multiple TCP Servers From Client C# -

multithreading - Connecting to Multiple TCP Servers From Client C# - making properties tcpclient , ipendpoint appear have fixed issue! if explain why case appreciate it. declare class objects static don't exclusively understand why works way. i'd start saying usual, i've googled , googled haven't found answering question please point me if there reply question. i have written tcp server , client in c#, client able connect multiple servers. clear not server multiple clients connected it, had no issues configuring that. here little image explaining mean: pretty, know. in seriousness can't work. met error: a connect request made on connected socket have class called client, tcpclient , ipendpoint: public client(ipendpoint ip) { client = new tcpclient(); this.ip = ip; } this class has methods connect, send, receive etc. issue comes when this: client host = new client(hosts.elementat(0)); ipendpoint ipe = hosts.element

java - FileOutputStream.writeBytes out of bounds -

java - FileOutputStream.writeBytes out of bounds - my programme reads file byte array , tries carve out bmp image file. problem getting out of bounds error. { public static void main( string[] args ) { fileinputstream fileinputstream=null; file file = new file("c:/thumbcache_32.db"); byte[] bfile = new byte[(int) file.length()]; system.out.println("byte array size: " + file.length()); seek { //convert file array of bytes fileinputstream = new fileinputstream(file); fileinputstream.read(bfile); fileinputstream.close(); //convert array of bytes file fileoutputstream fileouputstream = new fileoutputstream("c:/users/zak/desktop/thumb final/carved_image.bmp"); fileouputstream.write(bfile,1573278,1577427); fileouputstream.close(); system.out.println("done"); }catch(exception e){ e.printstacktrace(); } } } the size of byte array 1 file

java - How to idendify the Text in image files and also how to read that text? -

java - How to idendify the Text in image files and also how to read that text? - in image format have total of text. (ie) scanned document in format of image file *.tiff. optical character recognize method normal format of alphabet. in image format contains text running letter. how identify , convert text in text files? with tesseract-ocr can train characters. if sure running letter font can utilize samples training info instead of default 1 ships it. haven t done running letter, library place start with. http://code.google.com/p/tesseract-ocr/ regards, prasanna. java algorithm ocr

Autofill formula for cell names in Excel -

Autofill formula for cell names in Excel - in excel worksheet rows of parameters , columns of systems so: system1 system2 height 58 65 width 12 17 weight 3 5 ... . . ... . . i looking way utilize info meaningful names such "height1", "height2". can name cells "height1" "height2" (formulas->define name) , utilize in cell =height1. however, when autofilling dragging equation right, name not alter height2 , left same value of 58. basically, looking same behavior autofill dragging =b2 =b3, meaningful names. thank you. here macro naming them in convention (haven't tried should work): sub namethem() dim rng range = 0 3 j = 0 1 set rng = range("a1").offset(1 + i, 1 + j) phone call activeworkbook.names.add(rng.end(xltoleft).value & j, rng) next j next end sub excel formula drag autofil

html - Mysterious Line Break between divs. JSFiddle included -

html - Mysterious Line Break between divs. JSFiddle included - was working on websites design , reason, there linebreak between 2 divs shouldn't exist. here jsfiddle http://jsfiddle.net/d593fdea/ i know design ugly right now, ignore of it. question has gap between div offerscontainer , recentwinnersheadlinecontainer. it bugging me because gap shouldn't exist , have no clue why does. help appreciated, give thanks you! html: <html> <head> <link rel="stylesheet" type="text/css" href="styles.css"> <link href='http://fonts.googleapis.com/css?family=roboto+slab' rel='stylesheet' type='text/css'> </head> <body> <div id="maincontainer"> <div id="navcontainer"> <div id="logoimgcontainer"><img src="logo.png"></div> <p id="navlinks">prizes winners faq contact us</p> </div> <div id=

backbone.js - Can I pass a global var to an underscore view? -

backbone.js - Can I pass a global var to an underscore view? - i wonder if possible pass global variable when rendering template. variable each time phone call controller, looks this: window.myvar = 0; //this var alter in given moment when create request server.. so: //into render method of view, have this: var template = _.template($("#mytemplate").html(), { variwanttopass : myvar } ); this.$el.html(template); this way can access template this: <%= variwanttopass.get('myvar') %> if possible?; , also, each time render view, code excute 1 time again , update value? yes, except template has be <%= variwanttopass %> and pass variable window.myvar not accidentally replace it and yes update after each render if pass variable each time working example: html: <script id="mytemplate" type="text/html"> <%= variwanttopass%> </script> <div></div> js: window

django - How can I change the returned value of a field in a QuerySet based on some passed parameter? -

django - How can I change the returned value of a field in a QuerySet based on some passed parameter? - i want able homecoming different values queryset (not changing database) based on parameter. i'd able write model enforced everywhere. if user type of user, want queryset field blank (or "hidden" or similar). here's simplified model: class somedetails(models.model): size = models.floatfield() this_is_okay_to_show = models.textfield() not_always_ok = models.textfield() simplified queryset: qssomedetails = somedetails.objects.all() i want not_always_ok either homecoming text value stored in database or homecoming empty string (or 'hidden' or similar). template filter work, needs in model. i'm not sure how pass parameter through create work. i sense reply right in front end of me, i'm not seeing it. define manager class somedetails model: class somedetailsmanager(models.manager): def __getat

javascript - Already embedded iframe not working with the youtube api -

javascript - Already embedded iframe not working with the youtube api - my iframe html <iframe id="player" frameborder="0" width="660" height="371" allowfullscreen="" src="https://www.youtube.com/embed/cmm6tdavsxg?feature=oembed"> my youtube js var tag = document.createelement('script'); tag.src = "https://www.youtube.com/iframe_api"; var firstscripttag = document.getelementsbytagname('script')[0]; firstscripttag.parentnode.insertbefore(tag, firstscripttag); var player; function onyoutubeiframeapiready() { player = new yt.player('player', { events: { 'onready': onplayerready, 'onstatechange': onplayerstatechange } }); } function onplayerready(event) { event.target.playvideo(); } but still not start playing or else... issue here? give thanks you onplayerready not fire ready check on localhost. also when l

python - Using itertools with a generator class -

python - Using itertools with a generator class - i'm trying write class generates words file programme reads in. i'm stuck __iter__ , next methods. thought read in file in __init__ i'm confused how iterate on because know itertools doing similar. advice? currently have code. def __init__(self): self.words = [] self.n = 0 open('words.txt') f: text = f.read() x in text.split(): if len(x) > 2 , x[0].islower(): self.words.append(x) def __iter__(self): homecoming self def next(self): if(self.n == 0): self.n = self.n + 1 homecoming self.words[0] else: self.n = self.n + 1 homecoming self.words[self.n-1] this how code should run. >>> mw = merriamwebster() >>> [w w in itertools.islice(mw, 5)] ['aal', 'aalii', 'aam', 'aardvark', 'aardwolf'] the __iter__ method in case needs homecoming object

How to check Internet connectivity in my Google map application (Android) -

How to check Internet connectivity in my Google map application (Android) - how set network validation on google map,its working when net or wifi on.but not working when net down please, seek this. hope help you. public static int type_wifi = 1; public static int type_mobile = 2; public static int type_not_connected = 0; public static int getconnectivitystatus(context context) { connectivitymanager cm = (connectivitymanager) context .getsystemservice(context.connectivity_service); networkinfo activenetwork = cm.getactivenetworkinfo(); if (null != activenetwork) { if(activenetwork.gettype() == connectivitymanager.type_wifi) homecoming type_wifi; if(activenetwork.gettype() == connectivitymanager.type_mobile) homecoming type_mobile; } homecoming type_not_connected; } public static string getconnectivitystatusstring(context context) { int conn = networkutil.getconnectivitystatus(context

r - predict.lm() in a loop. warning: prediction from a rank-deficient fit may be misleading -

r - predict.lm() in a loop. warning: prediction from a rank-deficient fit may be misleading - #r code # fit regression model each cluster y <- list() length(y) <- k vars <- list() length(vars) <- k f <- list() length(f) <- k (i in 1:k) { vars[[i]] <- names(corc[[i]][corc[[i]]!= "1"]) f[[i]] <- as.formula(paste("death ~", paste(vars[[i]], collapse= "+"))) y[[i]] <- lm(f[[i]], data=c1[[i]]) #training set c1[[i]] <- cbind(c1[[i]], fitted(y[[i]])) c2[[i]] <- cbind(c2[[i]], predict(y[[i]], c2[[i]])) #test set } hello, i have training info set (c1) , test info set (c2). each 1 has 129 variables. did k means cluster analysis on c1 , split info set based on cluster membership , created list of different clusters (c1[[1]], c1[[2]], ..., c1[[k]]). assigned cluster membership each case in c2 , created c2[[1]],..., c2[[k]]. fit linear regression each cluster in c1. dependant variable "death". predictors di

ruby - I don't know how to call a random method from an existing method -

ruby - I don't know how to call a random method from an existing method - for example, have class 4 methods. in 4th method want phone call 1 random method. for example, method can phone call "first", "second" or "third" class test def first puts "1" end def sec puts "2" end def 3rd puts "3" end def end end test = test.new test.some class test def first puts "1" end def sec puts "2" end def 3rd puts "3" end def public_send (self.class.instance_methods(false) - [__method__]).sample end end test = test.new test.some # >> 1 ruby random methods

asp.net mvc - Disable Editor Template Date.cshtml on specific view -

asp.net mvc - Disable Editor Template Date.cshtml on specific view - my model [datatype(datatype.date, errormessage = "please come in valid date in format mm/dd/yyyy")] [displayformat(dataformatstring = "{0:d}", applyformatineditmode = true)] [display(name = "from date")] public datetime fromdate { get; set; } my view @html.editorfor(model => model.fromdate) my date.cshtml (editor templates) @html.textbox("", string.format("{0:mm/dd/yyyy}", datetime.now), new { @class = "datefield", type = "date" }) my requirement show database value on particular view every time shows me current date. how please help me. you should utilize model instead of datetime.now @html.textbox("", string.format("{0:mm/dd/yyyy}", model), new { @class = "datefield", type = "date" }) asp.net-mvc razor view editortemplates

android - I need refresh imageView with a button(invalidate doesn't work) -

android - I need refresh imageView with a button(invalidate doesn't work) - i have custom imageview can draw, zoom , paint points(coordinates). i have button "reset" delete coordinates draw but imageview doesn't refresh when click, refresh after, when touch screen. gonna see code here onclick of buttons- btnres is button need help! //this method on "main extends activity" public void onclick(view v) { switch(v.getid()){ case r.id.btnfin: break; case r.id.btninv: break; case r.id.btnres://start on imagen.listaptos.clear(); //refreshing image imagen.invalidate();//dont works imagen.refreshdrawablestate();//dont works neither break; } } some thing class imagen understand after code public class imagen extends imageview static arraylist <marking> listaptos = new arraylist<marking>(); some cod

java - WebSockets, ByteBuffer and PC Architecture -

java - WebSockets, ByteBuffer and PC Architecture - i using websockets between windows machine , raspberry pi. utilize @onmessage websocket-api send binary info windows machine raspberry pi machine. specs given below. windows 7 64 bit jdk 1.8_u05 64 bit glassfish 4.0 open source edition raspberry pi 32 bit (debian) jdk 1.8.0 b132 stand lone websocket now problem, websocket connection windows machine raspberry pi sends binary info 0 byte array if i alter glassfish server tomcat i alter jdk version 1.8.0_u5 other this i alter glassfish version 4.0 4.1 i clueless why happening. can these related? how @ to the lowest degree find out cause of this? edit : have debugged, used fiddler, wireshark (at windows), logs , have found info going windows proper - raspberry pi receiving zeroes (logs only). java websocket glassfish raspberry-pi bytebuffer

mysql - I am trying to add information into two tables at the same time. One table -

mysql - I am trying to add information into two tables at the same time. One table - error when trying populate table i wanting input info single row within table, first set of info generated form input , sec auto-increment table. insert bar_location2 (`bar_admitted`) values ("{57}");<br> insert bar_location2 (your_id) select your_id your_detail; i can execute each query separately , table populate (unfortunately on separate rows), next error when combine two: 1064 - have error in sql syntax; check manual corresponds mysql server version right syntax utilize near 'insert bar_location2 (your_id) select your_id your_detail' @ line 2 sql=insert bar_location2 (`bar_admitted`) values ("{57}"); insert bar_location2 (your_id) select your_id your_detail; i have tried: start transaction;<br> insert bar_location2 (`bar_admitted`) values ("{57}");<br> insert bar_location2 (your_id) select your_id your_detail;<

wix extension - Wix - how to run an exe after installfinalize upon uninstall? -

wix extension - Wix - how to run an exe after installfinalize upon uninstall? - i using wix installer overwrite(read: modify existing registry values), add together new ones etc. upon uninstall need revert them original state (the ones modified). not supported wix , have utilize custom action (as read) want run exe run .reg file using reg import . according site: http://www.installsite.org/pages/en/isnews/200108/index.htm custom action has run after="installfinalize" because wix rollback delete registry import (as part of rollback). looks this: installer modifies reg values, uninstaller deletes touched registry changes (part of rollback), exe restore them. so did according how to, start exe elevated rights etc. http://wixtoolset.org/documentation/manual/v3/customactions/qtexec.html <component id="registry" guid="*"> <file id="regexe" source="registryrollback.exe"/> <fil

php - need help returning sql sum of $variable table name -

php - need help returning sql sum of $variable table name - i'm trying homecoming sum of balances table , can next code work when using specific table name $qry = mysql_query("select sum(balance) total table1 "); $row = mysql_fetch_assoc($qry); echo $row['total']; the problem i'm having table name changes , needs variable when utilize next code no result $table="table1"; $qry = mysql_query(" select sum(balance) total $table "); $row = mysql_fetch_assoc($qry); echo $row['total']; can offer help please? how about: $qry = mysql_query(" select sum(balance) total " . $table ); php mysql sql variables sum

QuickBooks Online oAuth tokens -

QuickBooks Online oAuth tokens - i developing .net web app through users connect quickbooks online using "connect quickbooks" button.the oauth authentication flow works fine when connecting qbo. when oauth response returned storing oauth token in database. question 1)how utilize oauth token next time user logs application end user not have reconnect quickbooks online. 2)what happens when tokens expire , how should handled ? please help. oauth quickbooks

iphone - iOS camera rotates properly in safari but not in web app mode? -

iphone - iOS camera rotates properly in safari but not in web app mode? - i building web app allow user take image , upload folder on server , image displayed on gallery page. upload portion works fine having problems ios. when run app in safari, works fine when access camera, can rotate photographic camera , take portrait or landscape pictures , upload , render on gallery page. problem when runs in web app mode homescreen...if launch access photographic camera while in portrait mode, photographic camera launches if turn phone in photographic camera mode image rotates if locking portrait mode. there way programmatically, allow photographic camera rotate when runs in safari? here code, perhaps incorrect? <form action="upload.php" method="post" enctype="multipart/form-data" style="width:100%;"> <span style="text-align: center; word-wrap: break-word;"> please take picture:

string - Matlab - Find index of a cell by its value -

string - Matlab - Find index of a cell by its value - i have cell array filednames 11x1 in each cell single string , want index of cell equal string name. i've found example: c = { {'a'}, {'b'}, {'c'}, {'a'}, {'a'} } % info idx = find(strcmp([c{:}], 'a')) % single line engine however when apply case: find(strcmp([fieldnames{:}], 'b_h_epsq_h')) nothing happens, , strcmp([fieldnames{:}], 'b_h_epsq_h') , doesn't find match, although if type strcmp([fieldnames{2}], 'b_h_epsq_h') reply 1. i tied transpose cell array illustration 1x5 still no success use following: idx = strcmp(fieldnames, 'b_h_epsq_h') find(idx) example: >> fieldnames = {'a', 'b', 'c', 'd', 'e'}; >> idx = strcmp(fieldnames, 'c') idx = 0 0 1 0 0 >> find(idx) ans = 3 string matlab strcmp cell-array

php - How to use the cache in doctrine 2 and zend framework 2? -

php - How to use the cache in doctrine 2 and zend framework 2? - plz need help here , i've goolged lot without result :/ how can exploit query , result stored in memcache , i'm working zend framework 2 , doctrine 2 ? , here configuration in module.config.php : // doctrine config 'doctrine' => array( 'driver' => array( __namespace__ . '_driver' => array( 'class' => 'doctrine\orm\mapping\driver\annotationdriver', 'paths' => array(__dir__ . '/../src/' . __namespace__ . '/entity') ), 'orm_default' => array( 'drivers' => array( __namespace__ . '\entity' => __namespace__ . '_driver' ), ) ), /***** enabling memcache ****/ 'configuration' => array( 'orm_

php - How to show HTML snapshot to crawlers -

php - How to show HTML snapshot to crawlers - i'm running website uses ajax populate products database. want create site crawlable searchenginge's. i'v read post on google webmasters making ajax applications crawlable. have no clue how create work in application. don't see how apply on application without rewriting big parts of code. of guys might give me tips. my application url: www.mysite.com/productcategory/category1/ this url show products category1 , ajax phone call creates html. there no special url parameters. done because there pagination. clicking on next page executes same ajax script returns products next page. url modified (with jquery history) to: www.mysite.com/productcategory/category1/?page=2 clicking on next page button script called get_products.ajax.php , parameters (like page=2) send post . phone call get_products.ajax.php same, no parameters in url. lot of info stored in sessions limit number of database queries. list of product

Android google map can't be found -

Android google map can't be found - i have layout shows map on app <?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="fill_parent" > <relativelayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/fragment_create_instant_album_create_button_text_view" > <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerinparent="true" android:orientation="vertical" android:paddingleft="30dp" android:paddingright="30dp" > <textview android:layout_width=&quo

python - Count the number of list elements that does not include certain strings -

python - Count the number of list elements that does not include certain strings - i have big text file containing 900000 lines. have count lines not have 'year1995' , 'year1996' in line. did follows: fname = r"data.txt" open(fname,'r') fi: lines = fi.read().splitlines() print len(lines) test = [l l in lines if 'year1995' or 'year1996' not in l] print len(test) but code not producing expected result. any ideas? the code have there set every single line in test . because first if statement evaluate true because non-empty strings truthy. alter test within comprehension: [l l in lines if not ('year1995' in l or 'year1996' in l)] python

javascript - Insert country code to phone input field with jQuery -

javascript - Insert country code to phone input field with jQuery - in "contact us" form, need insert country code (ie 972, 1, 91) phone input field after choosing country select list. example; if user chooses "us" list, phone input field start number "1" , user go on write number. how do jquery? thank you you can purchase adding value code of country us value of alternative should 1 your html should be, <select id="country"> <option value="">select country</option> <option value="1">us</select> <option value="91">in</select> </select><br/> code: <input type="text" id="code" /> jquery $(function(){ $('#country').on('change',function(){ $('#code').val(this.value);// changing code textbox value current country value }); }); javascript jquery

oop - How should I model a single entity that has data from multiple data sources? -

oop - How should I model a single entity that has data from multiple data sources? - multiple info sources used provide same info cars. users able view , compare auto info each source. for 2 types of cars, 3 info sources used provide info cars. 3 info sources same. for other types of car, 2 info sources used. 1 info source vary among 15 different info sources depending on type of car. other info source remain fixed (and 1 of 3 noted in above paragraph). for given type of car, info source may have info (e.g. price) auto not nowadays in other info sources. in cases, 1 info source may have auto not exist in other (two or three) info sources. each auto need mapped same auto among different info sources. scheme determine mapping. in cases, admin need @ auto info , determine same auto beingness referred in different info sources. how should model in relational database , oop? should each source-car become table/class (e.g. kellyblu

javascript - Validate multiple selectors on click and unclick -

javascript - Validate multiple selectors on click and unclick - jquery(function($){ var nickname = $('#nickname'); var email = $('#email'); var email_match = $('#email_match'); var password = $('#password'); var birthday_day = $('#birthday_day'); var birthday_month = $('#birthday_month'); var birthday_year = $('#birthday_year'); var gender_femal = $('#gender_female'); var gender_femal = $('#gender_male'); var error = $('.error'); nickname.blur( function(){ if (nickname.val() < 1) error.html('error') }); nickname.click( function(){ if (nickname.val() > 0) error.html('') }); }); now works nickname selector easiest way check selectors without re-create paste same function. for example blur/focus(function(){if (nickname || email || password < 0) error.html('error'); }); while i'm typin

design patterns - Javascript - Separating variables in different script -

design patterns - Javascript - Separating variables in different script - i have few pieces of scripts written already. however, variables within different script certainly collide each other upon import some of examples scripts the next script a <script> var vx = 0; var vy = 0; var d = null; function init() { ...} function commentbox() { ... } commentbox.prototype.create = function() { ... } </script> the next script b <script> var vx = 0; var vy = 0; var x = 0; var y = 0; var p = null; function init() { ...} function ball() { ... } ball.prototype.create = function() { ... } </script> upon import, variables , methods certainly collide each other. here's question. possible separate them without need modify name? know there exists design patterns how can accomplish this? i have been using prototype pattern various "object" in these script don't k

javascript - How to get jquery cloned html object in C# propery -

javascript - How to get jquery cloned html object in C# propery - i have div in page contains input elements. want clone finish html of div can save in database , next time can retrieve cloned html , 1 time again render in page in exact same way @ time of saving including input values same @ time of saving. i cloing html of div as: var htmlobject= $('.mydiv').clone(); now above variable htmlobject of type object. now in c# in model i've string type of property html: public string html { get; set; } but when send htmlobject server using ajax call, html property null. question should type of property html htmloject catched properties preserved next time when retrieve db , send client div should recreated same? instead of using clone() , returns dom object, grab string contents of div using: var htmlstring = $('.mydiv').html(); you can pass htmlstring straight c# string property html . edit: include input values in string, see

python - Django REST Framework - pass model to ViewSet via router -

python - Django REST Framework - pass model to ViewSet via router - i'm trying create rest-modelviewset has no model predefined, takes model when registered router. need dynamically add together models rest-api, without configuring new viewsets or serializers. my thought pass model in kwargs of __init__ , can't figure out how correctly this. here tried: //viewset class themeviewset(viewsets.modelviewset): def __init__(self, **kwargs): self.model = kwargs['model'] self.serializer_class = none super(themeviewset, self).__init__(**kwargs) def get_serializer_class(self): if self.serializer_class not none: homecoming self.serializer_class class themeserializer(serializers.hyperlinkedmodelserializer): class meta: model = self.model self.serializer_class = themeserializer homecoming self.serializer_class //router: router = routers.defaultrouter() router.re

c - Copying char array into another without copying newline -

c - Copying char array into another without copying newline - i'm using fgets read string in char array, , want move pointer on 5 indices , re-create rest of array separate array, don't want re-create newline character; i've got this: char str1[45], str2[50]; fgets(str2, 50, stdin); *str2 += 5; sprintf(str1, "%[^\n]s", str2); but when seek compile, error says: unknown conversion type character â[â in format [-wformat] i'm pretty sure i've used "%[^\n]s" before scanf, , worked fine, suggestions? the pattern %[^n]s valid format scanf not valid format specifier printf (or sprintf ). additionally, *str2 += 5 not skip first 5 characters (as appears intention) instead adds 5 byte stored in first element of str2 . str2 = str2 + 5 not compile since str2 array. assign result temporary or pass straight sprintf. here improve way of doing asking: size_t len; char *str1 = null, str2[50]; fgets(str2, 50, stdin); len = s

sql - Does datalist tag need to be bind on serverside when not using database -

sql - Does datalist tag need to be bind on serverside when not using database - i have few lines of code in no server connection , databse fetching included. problem image not beingness displayed when want show in datalist. <asp:datalist id="dlpic" runat="server" repeatdirection="horizontal" repeatcolumns = "4"> <itemtemplate> <div class="item" id="construction"> <div class="border"> <a id="imagelink" href="~/images/gallery/gallery_halmar001.jpg" class="zoom prettyphoto" runat="server" > <img src="images/gallery/gallery_halmar001.jpg" class="scale-with-grid" /> </a> </div> <h5><a href="#"></a></h5> <p></p> <div class="shadow"></div> </div> </itemtemplate>

c# - windows store app message dialog box -

c# - windows store app message dialog box - i want open stdinfopage page after clicking go admin button on message box how can that? here button coding private void button_login_click(object sender, routedeventargs e) { if (myreader.hasrows && this.frame != null) { while (myreader.read()) { if (privilege == 1) { displaymsgbox("click open admin page ", "go admin"); this.frame.navigate(typeof(stdinfopage)); } else { displaymsgbox("privilege 0", "ok"); } } } else { displaymsgbox("sucess else", "ok"); } conn.close(); } } here message box code private async void displaymsgbo