Posts

Showing posts from April, 2013

java - log4j in a multithread environment. One Appender per Thread or one Logger per Thread or...? -

in multithreaded environment (web service provider) need create log entries in database per request (normally per thread). approach use this? same logger threads , create appender per thread. @ end of request/thread close/remove appender. a logger per thread (different class name per thread). @ end of request/thread somehow release specific logger other? from apache log4j faq : yes, log4j thread-safe. log4j components designed used in heavily multithreaded systems. as marko topolnik comments, ignore multithreading when planning logging statements, , let log4j take care of it.

tcl - linking procedure to button -

i have created same user interface using gui builder tcl. however, became limited in terms of how structure interface , spacing between widgets. i've created interface i'm looking create procedure block specific widget. example, quit button exit program. to achieve created following procedure: proc btnquit args { exit } this doesn't cause syntax or runtime error however, when button pressed, program not exit. simplest case there others more complex -command flag not apply situations. thoughts? below entire code. bringing user interface. #includes necessary packages package require bwidget package require tk namespace eval main_menu {} #do not modify!! graphical user interface code not modify!! #limit size of window wm maxsize . 475 180 ;#x-500, y-210 wm minsize . 475 180 ;#x-500, y-210 #[device name] test frame w/ associated check boxes labelframe .lblfrmselection -text "testable devices" -padx 1 -relief groove -height 175 -width...

jsp - set multiple default value in select tag in struts2 -

how can set multiple default value using select tag in struts2. e.g have list of names "namea, nameb, namec". want these 3 names selected default. can populate list struggling set multiple default value. <s:select id = "name" size = "5" name = "nameform.nameids" cssstyle = "width:365px;margin-top:10px; margin-bottom:10px;" list = "name.namelist" listkey = "id" listvalue = "displayname" multiple = "true" ></s:select> you need use value attribute of <s:select> tag. , because using bean generate <s:select> values need create list of bean properties used in listkey attribute. in case list of id -s. <s:set var="idslist" value="{'id1','id2','id3'}" /> <s:select list="name.namelist" listkey="...

visual studio 2012 - Web Client Software Factory 2008 ASP.NET project migration to dotNET 4.5 64 bit possible? -

i have old web client software factory project built vs2008, wcsf 2008 , ms enterprise library 3.1 have make changes project migrated solution visual studio 2012. compiles fine .net 3.5 , runs on iis 7.5 32bit web application (classic mode asp.net v2.0). is possible migrate such project .net 4.5 (64 bit)? my guess no. last version of wcsf 2010 , ms enterprise library 5.0. think both built on .net 3.5 did try such migration before? thanks i'm planning same thing couple of applications. did checked out on msdn , wcsf project discussion on codeplex seems there's no future roadmap wcsf. see: web client software factory roadmap 2012 , beyond ?

jquery - Call jAlerts from Google -

i change alerts in website jalert of jquery. have been programming that. in website called jquery.min google , "migrate" jquery.com, couldn't call jquery.alerts.js google, have call 1 of servers don't want it. knows knows correct link?? think wrong in code?? bellow can find call's code: <head> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <!-- llava de la pƔgina de jquery a...pues jquery jeje --> <script type="text/javascript" src="//code.jquery.com/jquery-migrate-1.1.1.min.js"></script> <!-- migra para que las funciones viejas funcionen --> <script type="text/javascript">window.jquery || document.write('<script type="text/javascript" src="../scripts/jquery.alerts.js"><\/script>')</script> <script type="text/javascript" src="//sites.googl...

entity framework - ASP.NET Models - Best Empty Object Creation? -

so if want add artist website, , create model holds , additional details like: namespace supermusic.models { public artist newartist { get; set; } public ienumerable<recordcompanies> recordcompanies { { //some code populate possible record companies } } now can have view create new artist , model populate drop down of record companies artist can associated with. but in controller, have define "new artist". believe there 2 ways this: newartistmodel.newartist = context.artist.create(); newartistmodel.newartist = new artist(); is 1 of these more correct other? or there difference in code , 1 of these incorrect? thanks again answer noob questions! the first option newartistmodel.newartist = context.artist.create(); correct method creating new instances context create entity framework aware proxy objects. proxy objects provide full support navigation properties etc. there's more complete answer here

Properly loading JQuery on Rails (object has no method) -

i working on course posted @ http://schneems.com/ut-rails . here app working with: https://github.com/schneems/ruby_javascript_data_viz.git . i using rails 3.2.6 , ruby version 2.0.0p247. i have cloned file desktop, installed bundle, , set database. when use console (chrome) see if jquery working, error: > $('body').hide(); type error: object #<htmlbodyelement> has no method 'hide' when view page source see if jquery loading, can see line: <script src="/assets/application.js?body=1" type="text/javascript"></script> however, don't see jquery. missing here? i have searched issue, , have found many similar questions, can't seem find me going. thank you!! make sure jquery plugin loaded , document ready before using hide() function. wrap code in $(function() { $('body').hide(); } and try.

Node.js controlling no of post calls per second -

i subscribing inhouse api (post request) restricts me make 5 calls per second. node.js being used make these rest api calls. how write code restrict no. of api calls invoked per second ? use setinterval(makeapicall, 200); execute api calls every 200 milliseconds. every execution of makeapicall function make 1 call queue. var queue = [ { arg1 : 'arg1value', arg2 : 'arg2value' }, { arg1 : 'arg1value', arg2 : 'arg2value' } ]; setinterval(function() { var arguments = queue[0]; // api call function, using arguments makeapicall(arguments.arg1, arguments.arg2); // remove queue queue.splice(0, 1); }, 200);

java - Scheduled tasks does not run during certain time in the night -

one of scheduled tasks fails 11:30 p.m in night 8:00 a.m in morning, after seems work fine error: ** task scheduler completed task "\open_items" , instance "{2f836ec9-04aa-4169-a364-33a2ac4fc9e4}" , action "c:\windows\system32\cmd.exe" return code 255. ** the task scheduled "run whether user logged in or not", can't find out whats causing problem the task runs java program--> in turn calls batch file uses curl hope hear on this, soon. error code 255 means 'the extended attributes inconsistent' . check url , other parameters before invoking cmd.exe. check if 'open_items' directory if exists etc.

ember.js - Ember, Ember-data, and jquery-ui.dialog, "Oh my!" -

the task: open form in lightbox create new "event"; opened form should bookmarkable. the road blocks: there examples of opening lightbox using {{action}} tags, not find 1 opened in own route. there many examples using older versions of ember.js. there not lot of documentation related ember-data , rest (i know, know...it isn't "production ready"). the problem: the fields in form not being tied backing model "null" being posted servlet (a spring controller). my first iteration not far off final outcome (jsfiddle) . thing made works swapping this: ep.eventsnewroute = ember.route.extend({ ... setupcontroller : function(controller, model) { controller.set("model", model); }, ... }); ...for this: ep.eventsnewroute = ember.route.extend({ ... setupcontroller : function(controller, model) { this.controllerfor("events-new").set("model", model); }, ... }); t...

php script gateway timeout -

for unknown me reason, code below not seem work <?php $now = gmdate('d, d m y h:i:s') . ' gmt'; header('expires: ' . $now); header('last-modified: ' . $now); header("cache-control: no-store, no-cache, must-revalidate"); header("pragma: no-cache"); error_reporting(0); $copyright = "by www.magnaromagna.it"; $name = $_post["name"]; $day = $_post["day"]; $month = $_post["month"]; $year = $_post["year"]; $cycle = $_post["cycle"]; $chartsize = $_post["chartsize"]; $name = strip_tags($name); if($chartsize == "small") { $chartwidth = 450; $chartheight = 252; $tablewidth = 500; } elseif($chartsize == "medium") { $chartwidth = 625; $chartheight = 350; $tablewidth = 655; } else { $chartwidth = 800; $chart...

r - More elegant way to return a sequence of numbers based on booleans? -

here's sample of booleans have part of data.frame: atest <- c(false, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, false) i want return sequence of numbers starting @ 1 each false , increasing 1 until next false. the resulting desired vector is: [1] 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 here's code accomplishes this, i'm sure there's simpler or more elegant way in r. i'm trying learn how code things more efficiently in r rather getting job done. result <- c() x <- 1 for(i in 1:length(atest)){ if(atest[i] == false){ result[i] <- 1 x <- 1 } if(atest[i] != false){ x <- x+1 result[i] <- x } } here's 1 way it, using handy (but not widely-known/used) base functions: > sequence(tabulate(cumsum(!atest))) [1] 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 ...

SQL Server Logging Denied Access -

i wondering if knew if logging capabilities of sql server extended tracking user attempts query information on not have access. example, if user attempts query object or schema on lacks permissions, logs capture attempt when receives error similar below: msg 229, level 14, state 5, procedure sproc, line 1 execute permission denied on object 'sproc', database 'db', schema 'schema'. any advice appreciated, in advance there event called user error message under errors , warnings section. can log event

database connection - Teradata: Difference between ANSI and TERA modes with respect to record insertion -

i working on application takes records hadoop , inserts them teradata via sqoop(jdbc). i using tera mode connection , target table set table. getting duplicate row issue datasets. as far know tera mode supposed ignore duplicate records while doing inserts. can please confirm behavior? for set table in tera mode in teradata there 2 scenarios: 1.) set table table_name (which throw duplicate row exception ): insert dbname.table_name(id,name) values(1,'mukesh'); //success insert dbname.table_name(id,name) values(1,'mukesh'); //failure insert dbname.table_name(id,name) values(1,'mukesh'); //failure in tera mode not case sensitive, treats records same. , throw duplicate row exception . 2.) set table table_name(which not throw duplicate row exception ): insert dbname.table_name(id,name) select id,name dbname.table_name2; if there records in dbname.table_name2 in table dbname.table_name , if try execute above query, ignores duplicate r...

java - Changing the variable assigned everytime a loop iterates -

i trying build program allows user enter length , width of object many times choose (i build more code choose how many times loop goes). having problems figuring out how input , construct object every time loop iterates. thanks! public static void main(string[] args) { scanner console = new scanner(system.in); (int = 1; <= 2; i++) { system.out.println("enter length" + + ": "); int length = console.nextint(); system.out.println("enter length" + + ": "); int width = console.nextint(); object instance1 = new object(length1, width1); } } you can use arraylist/linklist, if entries big go linklist. scanner console = new scanner(system.in); system.out.println("enter how many records want: "); int j = console.nextint(); //"loop run "+ j +" times" list<objectname> objectlist = new arraylist<objectname>(); int length = 0; int width = ...

Strange Ajax/jQuery/PHP login issue -

i have dynamic login header. 2 links, login / register , profile / logout. i have php class function being used check if logged in , displaying relevant links, worked fine. i moved ajax login didn't want page refresh , login box drops down , rolls up. again, works fine. i've noticed slight issue, slight mean irritating :) once logged in, every single page refresh on new page shows flicker 'profile' becomes 'login' , flickers again. happens when page loading , doesn't last long it's not nice. could me solve please? i'm pretty new ajax/jquery , spent ages wiht of guys in here getting ajax/jquery part functional in first place. this script toggles login divs <script> window.onload = function(){ $(function() { var loggedin = <?php echo json_encode($general->loggedin()); ?>; $("#loggedin").toggle(loggedin); $("#loggedout").toggle(!lo...

c++ - RegisterClass for window class returning "file already exists" error -

at moment trying create blank window part of dll provides behind scenes communication our platform. no other part of dll ever display anything. currently instantiate window class such: wndclass wc; wc.cbclsextra = 0; wc.style = 0; wc.hinstance = hinstance; wc.lpszclassname = "preview"; i register class: if((registerclass(&wc)) == 0) { dword dwerrornum = getlasterror(); **some logging function here** return; } registering class results in getlasterror() returning 0x57 translates "cannot create file when file exists" horribly cryptic @ best not directly writing files. is there better way me create simple, blank window, or better way me debug beyond i've done? error code 0x57 not have files. error_invalid_parameter. looking @ code, have filled in 4 of ten members of wndclass. fill in rest well, , should fine.

pointer as a parameter -

i have problem function created, function should return number of characters entered in array. return 20 limit of array itself. code: int longitudcadena (char *pcadena) { // cantidad counter of chars in array int cantidad=0; //m constant equals 20, limit of array for(int a=0;a<m;a++){ if(pcadena!=0){ pcadena++; cantidad++; } else { return 0; } } return cantidad; } replace if(pcadena!=0) if(*pcadena!='\0') . also, change else condition either else { return cantidad; } or else { break; }

c++11 - Resolving ambiguous overload on function pointer and std::function for a lambda using + -

in following code, first call foo ambiguous, , therefore fails compile. the second, added + before lambda, resolves function pointer overload. #include <functional> void foo(std::function<void()> f) { f(); } void foo(void (*f)()) { f(); } int main () { foo( [](){} ); // ambiguous foo( +[](){} ); // not ambiguous (calls function pointer overload) } what + notation doing here? the + in expression +[](){} unary + operator. defined follows in [expr.unary.op]/7: the operand of unary + operator shall have arithmetic, unscoped enumeration, or pointer type , result value of argument. the lambda not of arithmetic type etc., can converted: [expr.prim.lambda]/3 the type of lambda-expression [...] unique, unnamed non-union class type — called closure type — properties described below. [expr.prim.lambda]/6 the closure type lambda-expression no lambda-capture has public non- virtual non- explicit const conversion functi...

c++ - Android + OpenCV: OnTouch getX(), getY() doesn't return right values -

i using opencv4android facedetection sample. have global table rectangles of spoted faces: private rect[] facesarray; also global floats store onclick coordinates, private float onclickx; private float onclicky; which generated ontouchevent: @override public boolean ontouchevent(motionevent e) { onclickx = e.getx(); onclicky = e.gety(); switch (e.getaction()) { case motionevent.action_down: // not important matter happens here } return super.ontouchevent(e); } in oncameraframe method before returning mat view doing: core.circle(mrgba,new point(onclickx,onclicky), 40, new scalar(0, 255, 0, 255)); so happens. draw small, green circle on coordinates fetched in ontouchevent , sent global variables. variables (onclickx, onclicky) read oncameraframe , used core.circle() function. problem that, circle isn't drawn precisely under finger in lower-right place. happens: https://dl.dropboxusercontent.com/u/108321090/device-2013-07-24-00...

python - Parsing uncommon symbol using BeautifulSoup -

i have link <a href=abc.asp?xyz=foobar&baz=lookatme´_beautiful.jpg> , there unusual symbol ´ , not present in standard english keyboard. mirror reflection of symbol ctrl+k produces in editor . after ran code found on stackoverflow: soup = beautifulsoup.beautifulsoup("<a href=abc.asp?xyz=foobar&baz=lookatme´_beautiful.jpg>"); in soup.findall('a'): print a['href'] the output abc.asp?xyz=foobar&baz=lookatme want have abc.asp?xyz=foobar&baz=lookatme´_beautiful.jpg . website i'm scraping in .br domain . of writings in portugese , though links in english , uncommon symbol may not valid english language symbol. thoughts or suggestions ? edit: looked @ representation python string produced me , <a href=abc.asp?xyz=foobar&baz=lookatme\xb4_beautiful.jpg> one way around produce custom regex , , snippet stackoverflow: import re urls = ...

forms - Django Choicefield with required=True and no exception on blank choice -

i guess problem clear title. basically have form dynamic choice fields. , create blank option select field. choices = [('', '----------')] problem if submit blank option, form validates. have django 1.5 installed, if in earlier version worked, , validation exception thrown, not. so big question , how , should validate ? i tried ovveride choicefield , it's validate method, still same result: class dynamicchoicefield(forms.choicefield): # thing need override here validate function. def validate(self, value): if self.required , not value: raise validationerror(self.error_messages['required']) andy ideas guys ? yes , clear me. when change required =false . or try use django force_insert =true in model, never used , try it.

ios - call method from other class (self issue) -

i know proper solution problem…if in myotherclass need call method in mymainclass example know how: mymainclass *class = [mymainclass alloc] init]; [class runsomemethod]; the problem if in runsomemethod refer self different self because different instance called myotherclass. understand (and know how workaround it), please educate me on right way handle , call original instance of mymainclass if need be. thanks! instead of creating instance of own class, can use self object call method. then when refer self in method, using same instance. so, should call method [self runsomemethod]; alternatively, if want class refer 1 object @ times, may want consider creating class singleton class, i.e., no matter - class issue 1 object. singleton way to create singleton class, go mymainclass.h , add property: + (mymainclass *)singletoninstance; then in implementation file, mymainclass.m add in following code: //just below @implementation mymainclass static myma...

ruby on rails - Is this an anti-pattern or is this ok? -

i have following: exercise.log_entries.for_user(@user).for_date(date) is bad code rails? can't @user.log_entries because needs scoped specific exercise. is considered ok or bad? how refactor? if you're using access controls, it's little smelly, though wouldn't complain loudly it. concern not leading off access controls means future refactoring might end breaking controls, embarrassing @ least. how associations set up? possible? @user.log_entries.for_exercise(exercise).for_date(date)

javascript - cursor.find() callbacks not returning in meteorjs -

i returning results collection second result dependent on first. so, find resulta, , resultb has not equal result a. my console.log statement shows data want, however, when return it, nothing shows in handlebars template. nothing returns if json.stringify it. mycollection.find({}, {limit:1, skip: _.random(minimum, maximum)}).foreach(function(a){ mycollection.find({'': {$ne: a._id}}, {limit:1}).foreach(function(b){ console.log({resulta: a, resultb: b}) return {resulta: a, resultb: b}; }); }); what doing wrong here? now have tried using deps.autorun incase collections aren't ready (which because console.log works) template.votes.helpers({ twoitems: function(){ var minimum = 0; deps.autorun(function(){ var maximum = (items.find().fetch().length) - 1; if (maximum){ var itema = items.find({}, {limit:1, skip: _.random(minimum, maximum)}).fetch()[0]; } if(it...

javascript - jQuery .bind binded function not firing -

i've been searching solution while can't still code work. i'm trying bind 'input' event. here's have far <script type="text/javascript"> $(document).ready(function () { $('#txtrtmuserid').bind('keyup', function () { var inputvalue = $('#txtrtmuserid').val(); inputvalue = inputvalue.replace(/-/g, ""); var outputval = ""; var inputlength = inputvalue.length; (var = 0; < inputlength; i++) { outputval += inputvalue.charat(i); if (i == 7) { outputval += "-"; } if (i == 11) { outputval += "-"; } if (i == 15) { outputval += "-"; } if (i == 19) { outputval += "-"; } } $('#txtrtmuserid').val(outputval); }); }); here...

algorithm - Is it possible to compute the minimum of a set of numbers modulo a given number in amortized sublinear time? -

is there data structure representing large set s of (64-bit) integers, starts out empty , supports following 2 operations: insert(s) inserts number s s ; minmod(m) returns number s in s such s mod m minimal. an example: insert(11) insert(15) minmod(7) -> answer 15 (which mod 7 = 1) insert(14) minmod(7) -> answer 14 (which mod 7 = 0) minmod(10) -> answer 11 (which mod 10 = 1) i interested in minimizing maximal total time spent on sequence of n such operations. possible maintain list of elements s , iterate through them every minmod operation; insert o(1) , minmod o(|s|) , take o(n^2) time n operations (e.g., n/2 insert operations followed n/2 minmod operations take n^2/4 operations). so: possible better o(n^2) sequence of n operations? maybe o(n sqrt(n)) or o(n log(n)) ? if possible, interested know if there data structures additionally admit removing single elements s , or removing numbers within interval. ...

java - How Set.contains() decides whether it's a subset or not? -

i expect following code give me subset , complementary set. but actually, result shows "error: not subset!" what it.next() , how revise code result want? thanks! package chapter8; import java.util.hashset; import java.util.iterator; import java.util.set; public class 3 { int n; set<integer> set = new hashset<integer>(); public static void main(string args[]) { 3 three = new three(10); three.display(three.set); set<integer> test = new hashset<integer>(); iterator<integer> = three.set.iterator(); while(it.hasnext()) { test.add(it.next()); three.display(test); three.display(three.complementaryset(test)); } } boolean contains(set<integer> s) { if (this.set.contains(s)) return true; else return false; } set<integer> complementaryset(set<integer> s) { if(this.s...

java - How to detect when a JButton is pressed (swing)? -

in java's swing package, wondering how detect when jbutton pressed. there function called when button pressed? thanks yes, when deal button pressing, want add known action listener. first, must import java.awt.event.actionlistener; then can following button.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { // makes sure button pressing button variable if(e.getsource() == button) { // action necessary code } } });

c# - How to call an extension method without using -

using system; class runner { static void main() { a = new a(); // how a.printstuff() without 'using' console.read(); } } class { } namespace extensionmethod { static class aextensions { public static void printstuff(this a) { console.writeline("text"); } } } how call extension method without 'using'? , not extensionmethod.aextensions.printstuff(a), since doesn't make use of extension method. that possible if extension method , class in same namespace, if have use different namespaces have use using , don't think there way without using . may reduce number of using putting extensions in 1 namespace linq ( system.linq.extensions ) note : can remove namespace extension methods, make them globally available

nodes - Drupal 6 How to hide fileds on creating content but show on editing content? -

i have 2 fields, start date , end date. want hide end date while adding new content , want start date not editable on editing , show end date edit. how can in drupal 6 node module? use form alter , can user url paramters see if add or edit form if add form $form['start_date']['#access']=false; , skip same in edit form

xpath - Specify default value in case of an empty nodeset -

using xpath 2.0, how can specify default value in case of empty node set? i'd able tune of $datatypes/type[@key="somevalue"] or "default value" have default value returned if key not found. may not looking for, think need have conditional expressions . therefore try this: if ($datatypes/type[@key="somevalue"]) $datatypes/type[@key="somevalue"] else "default value"

ruby on rails - Capybara 2.1 and Heroku config issue -

trying git push heroku part of rails tutorial they're using capybara 2.1 appear causing issue during push. following message: important! of defaults have changed in `capybara 2.1`. if you're experiencing failures, please revert old behavior setting: capybara.configure |config| config.match = :one config.exact_options = true config.ignore_hidden_elements = true config.visible_text_only = true end the documentation merely says "set these options" followed code above. i'm novice, have no idea set options. best guess in 1 of many files in config, not sure one. looking @ doc (not version of calybara for) states put configuration file in lib/capybara.rb rather initializer. http://rubydoc.info/github/jnicklas/capybara/master/capybara.configure

spring mvc - JQuery ajax error for large response -

i using spring-mvc , jquery ajax. ajax function is jquery("#usersearch").click(function () { jquery("body").addclass("loading"); var formvalues = jquery('#user-search').find(':input[value][value!=""]').serialize(); jquery.ajax({ type: "get", url: "/samplewebservice/sample/user-byname", data: formvalues, datatype: 'json', timeout: 600000, success: function (data) { jquery('#json').val(json.stringify(data)).trigger('change'); jquery('body').removeclass("loading"); }, error: function (e) { alert('error while request..' + e); jquery('body').removeclass(...

JBoss EAP 6.x with Hibernate Oracle Sequence Duplicate Value on Primary Key -

i have defined number of hibernate entities using pure jpa annotations. these use predefined oracle sequence on database automatically generate primary key values. @id @sequencegenerator(name = "users_id_generator", sequencename = "my_seq") @generatedvalue(strategy = generationtype.sequence, generator = "users_id_generator") @column(name = "u_id", updatable = false, unique = true, nullable = false, precision = 19) private long id; when deployed jboss eap 6.1 works after short period hibernate starts generating duplicate keys on inserts (ora-00001 errors). i don't care id ordering or gaps, can't tolerate duplicate keys... going on here? this not documented, many of solutions on here , other sites relate older versions of hibernate hilo sequencegenerator default. after investigation found underlying cause jboss eap 6 sets hibernate.id.new_generator_mappings=true by default, uses org.org.hibernate.id.enhanced.sequence...

linux - resolve all symbolic links -

i have following structure -> b b -> c c -> d d -> e (a symlink b, b symilnk c , on) do tool in linux can resolve links till actual file found. eg resolve a should directly print e on linux, trick: readlink -f

c - Freeing the head node of linked list -

if free head node of linked list remove head node other nodes still in memory or free entire list , how ? your linked list should like: head +---+ +---+ +---+ | 1 |--->| 2 |--->| 3 |---+ +---+ +---+ +---+ | null head node keeps address of fist node only, if free(head) , free memory of first node value 1 only , other-nodes still in memory , valid access them, should first save address of node 2 , access linked list (else have memory leak in code). do like: new_head = head->next; free(head); once deallocate/free() memory, undefined behavior access not (address becomes invalid). from comment: yes, need loop free() memory nodes in linked-list, this: while(head){ // while head not null new_head = head->next; // first save address of next free(head); // free first node head = new_head; // s...

php - sessions from my login system are not working -

i developing website , have problem login system. consider 2 users, user1 , user2. if user1 gets access account and, in same browser, if user2 gets access account, user1 must logged out session not happen in system, moreover, system thinks user1 user2 because user2 connected. following code login page , authentication: login code <html> <body> <div class="wrap"> <div id="content"> <div id="main"> <div class="full_w"> <form action="login_oficial.php" method="post" autocomplete="off"> <label for="login">usuario:</label> <input id="login" name="login" class="text" /> <label for="pass">contraseƱa:</label> <input id="pass" name="pass" type="password" class="text" /> <input type="submit"...

java - How does offScreenPageLimit work for viewpager -

after go out of offscreenpagelimit, system call new view or page back? the source code viewpager best place find answer. in nutshell, viewpager keeps internal list of items (that respresent 'pages'). number of items in list based on the moffscreenpagelimit value. default it's set 1 , can change calling setoffscreenpagelimit(int limit) . in (package protected) method populate() , viewpager gets populated pages, following code snippet located: final int pagelimit = moffscreenpagelimit; final int startpos = math.max(0, mcuritem - pagelimit); final int n = madapter.getcount(); final int endpos = math.min(n-1, mcuritem + pagelimit); that determines bounds of dataset backs pageradapter , hence positions pages requested for. non-existing pages created using (package protected) addnewitem() method, ends calling instatiateitem() on associated pageradapter . part implement, either directly or through 1 of concrete subclasses. if changes along way, i.e....

model - MVC Parital view ID to render another partival view -

my mvc page has parent view show parish page. every parish has multiple churches , every church has own mass times. parish page has churches partial view want use church id render parital view of mass times (stored procidure). how can use id of partial view , create anothe partial view. had been banging head unable resolved. render partial view in side div tag. use div id , clone div create partial view. see below code sample. <div id="someid"> //render partial view here. </div> clone div , create many partial view u need.

Java Android WebView - how to launch javascript function from a separate .js file? -

i don't know html , javascript , need start function javascript. i've found can start javascript function mywebview.loadurl("javascript:function()"); if it's within html. i've got bunch of htmls in raw folder , separate script.js file works htmls. need start function script.js - do that? put javascript.js file in same folder (raw) html files are. inside <head> tag of html files import javascript files (if imported already, check if src path inside <script> tag correct), this: <script type="text/javascript" src="javascript.js" ></script> doing so, load in html, javascript functions contained in javascript.js file , can call mywebview.loadurl("javascript:function()"); successfully.

android - Set SurfaceView behind the Drop Down List -

Image
i want surfaceview must appear behind options dropdown list [edit dimension etc.]. when tap on options on activity surfaceview should appear behind dropdown list. please check image below link find problem surfaceview not appear behind option drop down list. easy understand questions. please me how can this. thanks in advance image : layout: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_gravity="center" android:orientation="vertical" android:weightsum="1" > <framelayout android:id="@+id/toplinearlayout" android:layout_width="fill_parent" android:layout_height="50dip" android:background="@drawable/bar" > <imageview android:...