Posts

Showing posts from June, 2010

tomcat - How to design a sample ussd app in java and test using a simulator -

i'm trying develop simple hello word application assignment in java, i'm stuck on how begin, have downloaded simulator (leibcit) cant figure out how make work servers, i'm running tomcat jboss open other simulators. do perhaps have detailed description on how can go developing application user dials code, maybe: *111# i bring menu hello // user selects 1, opens menu 1 how 2. previous screen bye // ends session. any appreciated. i'm new here , sorry if question's been asked, looked around couldnt find understand.

jquery - html2canvas - SecurityError: The operation is insecure -

i have used html2canvas.js in project convert element(body) canvas , convert canvas image. element contains images load cross domain. canvas create element working perfectly, when try canvas.todataurl("image/png"); gives error securityerror: operation insecure please me solve issue. canvas.todataurl("image/png"); working fine when image not load cross domain. thanks in advance. not html2canvas issue--just security issue. if lucky... you can use imageobject.crossorigin='anonymous' when downloading cross domain image. requires both server , browser allow anonymous x-domain transfers. sadly, servers , browsers don't yet allow. alternatively don't go cross-domain...serve image on own website. alternatively wrap image request in json request. here's script that: http://www.maxnov.com/getimagedata/

ruby on rails - permitted_params - rails4 and inherited_resources -

i've tried use ir in rails4 app, code class workspacescontroller < inheritedresources::base private def permitted_params params.permit(:workspace => [:name, :owner_id]) end end raises activemodel::forbiddenattributeserror exception. the same problem following code def permitted_params params.permit(:name, :owner_id) end whats wrong code? ps: i've tried following protip http://blog.josemarluedke.com/posts/inherited-resources-with-rails-4-and-strong-parameters 4.0rc1 doesn't work :( i had same problem. you need put permitted_params method public method in controller class. it's not private method. i hope help.

python - Sorting list of tuples based on multiple keys and returning top results -

i have list that: [ ('abilty', 'ability', 14, 1), ('aand', 'wand', 14, 1), ('aand', 'sand', 14, 1), ('aand', 'land', 272, 1), ('aand', 'hand', 817, 1), ('aand', 'and', 38093, 1), ('aand', 'band', 38093, 1), ('aand', 'iand', 38093, 1), ('aand', 'fand', 38093, 1)] in list 1 word if there more 1 value (for example there 8 match aand )then want sort them according 3rd attribute , choose first highest one. example in sample result should [ ('abilty', 'ability', 14, 1), ('aand', 'and', 38093, 1), ] i try unfortunately not work. me ? thanks. first sort list: >>> new_lis = sorted(lis,key=lambda x : (x[0],x[2]),reverse = true) #lis list >>> new_lis [('abilty', 'ability', 14, 1), ('aand', 'and', 38093, 1), ('aand', 'band',

iphone - How to render 2 different objects with different textures? -

i using opengl es glkitbaseeffect. started rendering single 3d mesh single texture. every fine , dandy. added second base effect (for 2nd texture) can render 2nd 3d mesh. i cant seem working. i think problem misunderstanding way vbo vertex , index buffers sent gpu. i call following twice (one per texture file): // apply buffers... glgenbuffers(1, &_vertexbufferframeborder); glbindbuffer(gl_array_buffer, _vertexbufferframeborder); glbufferdata(gl_array_buffer, sizeof(meshdata), meshdata, gl_static_draw); glgenbuffers(1, &_indexbufferframeborder); glbindbuffer(gl_element_array_buffer, _indexbufferframeborder); glbufferdata(gl_element_array_buffer, sizeof(meshindices), meshindices, gl_static_draw); // position glenablevertexattribarray(glkvertexattribposition); glvertexattribpointer(glkvertexattribposition, 3, gl_float, gl_false, sizeof(vertexdata), buffer_offset(0)); // normal glenablevertexattribarray(glkvertexattribnormal); glvertexattribpointer(glkvertexattribnor

Oracle PL SQL Trigger - To make data consistent -

oracle / pl sql trigger have table dealing residential properties called unit_tbl. the primary composite key (unit_num, complex_num , owner_num) many owners can own same unit in same complex. other columns include num_of_bedrooms (ie 4, 3, 2, 1) , property_type (ie house, duplex, apartment, condo). assume following statement entered: insert unit_tbl (unit_id, complex_id, owner_id, num_beds, property_type) values (001, 1000, 010, 3, 'apartment'); i'd raise error if same unit_id , complex_id entered owner (of same property) if num_beds not match previous entry or if property type not match previous entry. for instance, error raised if insert or update follows: insert unit_tbl (unit_id, complex_id, owner_id, num_beds, property_type) values (001, 1000, 011, 2, 'apartment'); -- num_beds here not match same property entered. i've tried creating trigger: create or replace trigger unit_consist_check before insert or update on unit_tbl

C#/ Delegate does not have type parameters -

i have 2 c# files: eventdel.cs : public delegate void eventdel(docdevent event); hbe.cs contains next field: public eventdel<me> tocatchone {get; set; } it gives me next error: delegate not have type parameters. how can solve it? your delegate not appear generic, try inside hbe.cs: public eventdel tocatchone {get; set; } or inside eventdel.cs: public delegate void eventdel<hbe>(docdevent event);

pdo - Fatal error: Call to a member function prepare() on a non-object in C:\xampp\htdocs\cms\include\article.php on line 8 -

i getting error , wondering how fix it? when trying add articles feed. class article { public function fetch_all() { global $pdo; $query = $pdo->prepare("select * articles order `article_id` desc"); $query->execute(); return $query->fetchall(); } public function fetch_data($article_id) { global $pdo; $query = $pdo->prepare("select * articles article_id = ?"); $query->bindvalue(1, $article_id); $query->execute(); return $query->fetch(); } } ?> don't use global attempt. that's not oop design , 1 of reasons whey code fails. instead make sure have been created $pdo far , pass constructor of article . further note capability of called typehints . while using them can enforce special type method param. if pass value @ runtime (like null or else) php throw error: typehint-----------------| public function __con

matrix - Determinant calculation javascript -

i have got bit of javascript , html code , want display calculated value of matrix determinant, function doesn't want display in input place,where want displayed, instead blank space. html <div id = "table"> <div id = "header">wyznacznik [3x3]</div> <form id = "row1"> <input type = "text" class = "det"/><!--first row--> <input type = "text" class = "det"/> <input type = "text" class = "det"/> </form> <form id = "row2"> <input type = "text" class = "det"/><!--second row--> <input type = "text" class = "det"/> <input type = "text" class = "det"/> </form> <form id = "row3"> <input type = "text" class = "det"/><!--third row--> <input type = "tex

calendar - Reading a iCal file only gets most recent event? -

i have ics file generated project doing, , validates in http://severinghaus.org/projects/icv/ . when try import korganizer or maya loads recent event however. example, ics file is: begin:vcalendar calscale:gregorian prodid:-//k desktop environment//nonsgml libkcal 4.3//en version:2.0 begin:vevent dtstamp:20130504t094939z created:20130503t230000z last-modified:20130504t094939z summary:cat dtstart:20130504t000000 dtend:20130504t010000 transp:opaque end:vevent begin:vevent dtstamp:20130504t094939z created:20130503t230000z last-modified:20130504t094939z summary:foo dtstart:20130504t000000 dtend:20130504t010000 transp:opaque end:vevent begin:vevent dtstamp:20130504t094939z created:20130503t230000z last-modified:20130504t094939z summary:dog dtstart:20130504t000000 dtend:20130504t010000 transp:opaque end:vevent end:vcalendar it read in, display first event. c

python - Getting <generator object <genexpr> -

i have 2 lists: first_lst = [('-2.50', 0.49, 0.52), ('-2.00', 0.52, 0.50)] second_lst = [('-2.50', '1.91', '2.03'), ('-2.00', '1.83', '2.08')] i want following math it: multiply 0.49 1.91 (the corresponding values first_lst , second_lst ), , multiply 0.52 2.03 (corresponding values also). want under condition values @ position 0 in each corresponding tuple idential -2.50 == -2.50 etc. obviously, same math remaning tuples well. my code: [((fir[0], float(fir[1])*float(sec[1]), float(fir[2])*float(sec[2])) fir in first_lst) sec in second_lst if fir[0] == sec[0]] generates object: [<generator object <genexpr> @ 0x0223e2b0>] can me fix code? you need use tuple() or list() convert generator expression list or tuple : [tuple((fir[0], fir[1]*sec[1], fir[2]*sec[2]) fir in first_lst)\ sec in second_lst if fir[0] == sec[0]] working version of code

r - Not understanding the behavior of ..density -

Image
in dataframe below, expect y axis values density 0.6 , 0.4, yet 1.0. feel there extremely basic missing way using ..density.. brain freezing. how obtain desired behavior using ..density.. appreciated. df <- data.frame(a = c("yes","no","yes","yes","no")) m <- ggplot(df, aes(x = a)) m + geom_histogram(aes(y = ..density..)) thanks, --jt as per @arun's comment: at moment, yes , no belong different groups. make them part of same group set grouping aesthetic: m <- ggplot(df, aes(x = , group = 1)) # 'group = 1' sets group of x 1 m + geom_histogram(aes(y = ..density..))

c++ - Why forwarding reference does not deduce to rvalue reference in case of rvalue? -

i understand that, given expression initializing forwarding/universal reference,lvalues deduced of type t& , rvalues of type t (and not t&&). thus,to allow rvalues, 1 need write template<class t, enable_if<not_<is_lvalue_reference<t> >,otherconds... > = yes> void foo(t&& x) {} and not, template<class t, enable_if<is_rvalue_reference<t>,otherconds... > = yes> void foo(t&& x) {} my question , why forwarding references, rvalues deduced of type t , not t&& ? guess, if deduced t&& same referencing collapsing rule works t&& && same t&& . because @ time, deducing rvalue a arguments a&& instead of a seen unnecessary complication , departure normal rules of deduction: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1385.htm http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1377.htm we didn't know if 1 exception of deduction

c++ getline and stringstream -

i'm trying read in file, has 5 lines, , every line 3-4 string long. here's input file: 10:30 hurley 1234567a 10:15 10:45 hurley 1234567a 11:30 08:35 jacob 1x1x1x1x1x 08:35 jacob 1x1x1x1x1x 08:10 08:05 jacob 1x1x1x1x1x 08:45 sayid 33332222 09:15 and get: 10:30 hurley 1234567a 10:15 10:45 hurley 1234567a 11:30 08:35 jacob 1x1x1x1x1x 11:30 08:35 jacob 1x1x1x1x1x 08:10 08:05 jacob 1x1x1x1x1x 08:10 08:45 sayid 33332222 09:15 this code: void enor::read(status &sx,isle &dx,ifstream &x){ string str; getline(x, str, '\n'); stringstream ss; ss << str; ss >> dx.in >> dx.name >> dx.id >> dx.out; /*getline(x, str, '\n'); x>>dx.in>>dx.name>>dx.id>>dx.out;*/ if(x.fail()) sx=abnorm; else sx=norm; } how can read in file without having 3rd , 5th line filled 2nd , 4th line's time? want dx.out empty. should use method, or possible done

html5 - CSS: horizontal menu with two images on each entry side and rollover -

i'm beginner in css , can't google solution design challenge have. have css horizontal menu this (entry1) (entry2) (entry3) , "(" , ")" images. i'd change () images on mouse over. i'd extremely grateful tip. best regards, kuba in css : .menu li a{ background:transparent url("images/seperator.gif") right no-repeat; } change .menu , "images/seperator.gif" yours

java - Quicksort partitioning -

i have following array: int[] arr = { 19, 4, 2, 3, 9, 2, 10, 2, 7, 12, 5, 16, 8, 3, 11, 14, 0, 5 }; and use quicksort's partitioning partition array pivot element 7: public static void partition(int[] arr, int low, int high) { int pivot = arr[low + (high - low) / 2]; int = low; int j = high; while (i <= j) { // if current value left list smaller pivot // element next element left list while (arr[i] < pivot) { i++; } // if current value right list larger pivot // element next element right list while (arr[j] > pivot) { j--; } // if have found values in left list larger // pivot element , if have found value in right list // smaller pivot element exchange // values. // done can increase , j if (i <= j) { swap(arr, i, j); i++; j--; } } } i confused outcome:

eclipse - IntelliJ IDEA Android make is slow -

i switched idea had have problems eclipse. overall feels great. however, 1 issue annoys me. building simple application take lot of time. if change 1 line, building takes 1min. in eclipse took 3 seconds. i've searched lot how improve performance, nothing helped. use 64 bit version of idea, increased ram, gave compiler higher heapsize (java , android dx compiler), checked "make project automatically" , "compile independent modules in parallel". didn't change situation. why eclipse faster in building .apk idea is? how handle long process? in case antivirus software causing issue (zonealarm). please vote crazycoder's comment up, had correct intention. build , launching app takes 2 seconds now. great, great.

android - using self signed certificate on mobile data plan -

short story: experiencing different android app behaviors based on whether i'm on wireless or mobile data. looks related using https self signed certificate. long story: have tomcat instance running, configured ssl connector , self signed certificate. works great. can access using https desktop , android app. android app, had use bks hold cert managed working too. problem? when switch phone mobile data, following failure: <?xml version='1.0'?> <!doctype html public '-//wapforum//dtd xhtml mobile 1.0//en' 'http://www.wapforum.org/dtd/xhtml-mobile10.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <title>the request failed</title> </head> <body> <p><big>the request not understood.</big></p> <p> <i>technical description:</i><br/>400 bad request - check spelling requested url</p> </body>

.net - C# method CopyfFromScreen crashes after 200 uses? -

for program need method takes screenshot every half minute. googled , came method: public static bitmap capturescreen() { bitmap bmp = new bitmap(screen.primaryscreen.bounds.width, screen.primaryscreen.bounds.height, system.drawing.imaging.pixelformat.format32bppargb); graphics gfx = graphics.fromimage(bmp); gfx.copyfromscreen(screen.primaryscreen.bounds.x, seen.primaryscreen.bounds.y, 0, 0, screen.primaryscreen.bounds.size, copypixeloperation.sourcecopy); return bmp; } well works fine first 200 uses of method or so. function crashes @ copyfromscreen , says caused invalid argument exception. i'm confused why because parameters don't change. could function has bug? if there alternatives take screenshot? probably 2 separate failures dispose. both graphics , image / bitmap implement idisposable , "obvious" of 2 here: using(graphics gfx = graphics.fromimage(bmp)) { gfx.copyfromscreen(screen.

Update Joomla website -

i updated joomla website on localhost - content of articles. need upload joomla folders remote server see these updates on webpage? possible upload specific folders articles (where folder located inside joomla directory)? seems, kind of new topic. if updates ' some ' articles, not mess around database. may edit articles on live side , copy & paste. should safer way.

Two pointers comparison -

pf1==pf2 pf1 , pf2 point same array element pf1>pf2 pf1 higher address location pf1<pf2 pf2 lower address location i want know if third sentence should be: pf2 higher address location ? the third statement should either: pf2 higher address location pf1 lower address location these statements equivalent in context. original quote got caught not making mind of 2 correct statements wanted make , ended being erroneous combining them. under memory addressing schemes such segmented addressing on 8086, possible have 2 different values segment:offset refer same address (because segments overlap). depending on whether (or how) pointer values normalized before comparison, might have pf1 < pf2 pointers still refer same address. however, sufficiently esoteric you're unlikely ever run such problem in practice.

Php 'update' command script possibly needs sql injection protection? -

this question has answer here: how can prevent sql injection in php? 28 answers my database suffered sql injection attack, because relatively new programming , did not know that. have been trying learn how prevent them, cannot figure out how script. have type of script implemented though. how can prevent sql injection attack using script? <?php $autor = $_get["multi"]; $autop = $_get["multis"]; $sql = "update autoj set autob = '$autop' autoq = '$autor'"; $hd = "something"; $dd = $_get['something']; $ud = "something"; $pd = "something"; $mysqli = new mysqli($hd, $ud, $pd, $dd); if (mysqli_connect_errno()) { printf("connect failed: %s\n", mysqli_connect_error()); exit(); } $result = $mysqli->query($sql); if ($result) { .... try this: $hd = "

mvvm - Binding ComboBox selected Item to a property of the View Model -

hi trying bind combobox selected item property in view model setter take value , perform other logic. combobox working correctly pulling items off observablecollection systems have been unable bind selecteditem serial property. selected item not getting string value of combobox. eveything else ok datacontext assigned view in code behind. ideas viewmodel: public class cablingrequests : observablecollection<cablingrequest> { public observablecollection<cablingrequest> pendingrequests { get; set; } public observablecollection<cablingrequest> processedrequests { get; set; } public observablecollection<cablingrequest> systems { get; set; } public observablecollection<cablingrequest> selectedsystemconfiguration { get; set; } private string _serial; public string serial { { return _serial; } set { if (_serial == value) return; _serial = value; getselecte

javascript - Thread-safe array deletions -

i know 1 can either splice item out of array, or delete delete . former approach can cause concurrency problems, e.g. if 1 thread walking on array while has shifted or spliced. delete doesn't have issue if foreach used on array, since foreach walk on holes in array. however, array can't keep growing forever , necessitate sweeping, potentially causing same issue in case of splice. sounds need locking, i'd amused if javascript had facilities it. thoughts? no, can't have concurrency problem javascript isn't multithreaded. if use webworkers won't have problems no data shared (workers communicate passing messages). in node.js script isn't multi-threaded. so use splice , there no need lock array.

c# - How to use OAuth 2 -

i have should have been easy application, need done. however, oauth 2 confusing me. basically, need upload file or group of files box , dropbox , etc. folder backup purposes. i have gone through sharpbox . seems super easy, cannot compile it. there missing reference or causes throw error: could not resolve reference. not locate "assemblyapplimit.cloudcomputing.sharpbox.net40". check make sure assembly exists on disk. if reference required code. also following error: the type or namespace name 'dropboxcredentials' not found (are missing using directive or assembly reference?) as far can tell, there aren't updates. how can fix problem? the first error getting because library "assemblyapplimit.cloudcomputing.sharpbox.net40" can't found. make sure add available folder, reference in project, , include build. second error getting because did not provide dropbox oauth credentials. must authenticate user before maki

python - How to call variables generated in loop -

i need generate number of variables in loop. achieved using code: nbottom=list of unknown size loc=locals() k,val in enumerate(nbottom) : loc["imp_local"+str(k)]=700 k,val in enumerate(nbottom) : loc["imp_global"+str(k)]=600 now need work them, creating dictionary like: dic1={'imp_local0': 700, ..., 'imp_localn': 700} dic2={'imp_global0': 700, ..., 'imp_globaln': 700} how can this? don't generate local variables. generate dictionary: dict1 = {'imp_local'+str(k):700 k,val in enumerate(nbottom)} dict2 = {'imp_global'+str(k):600 k,val in enumerate(nbottom)} refer dict comprehensions (pep 274) details

how to run java on website and to get values to html -

i know question may sound easy of stuck it. first of define trying achieve. on eclipse running piece of code sends data on specific port, , via html , javascript getting it's sent , print them on screen. i have account 1 of free hosting websites. want run code on website e.g mywebsite.blahblah.com/... , html file on computer want access website, values produced java code , print them on screen. i have no idea start. codes are java , html import java.net.inetsocketaddress; import java.net.unknownhostexception; import java.util.collection; import org.java_websocket.websocket; import org.java_websocket.websocketimpl; import org.java_websocket.handshake.clienthandshake; import org.java_websocket.server.websocketserver; public class gpsserver extends websocketserver { static int port = 9876; public gpsserver(int port) throws unknownhostexception { super(new inetsocketaddress(port)); } public gpsserver(inetsocketaddress address) { super(address); } public void

c - Improper Tiff image generated from RGB888 data -

Image
i'm trying convert rgb888 image data tiff image. code generates improper image. i'm reading rgb data text file.here output image black region shouldn't there seems code making low rgb values zero. i'm creating tiff image without alpha channel.please me comprehend issue. tiff *out= tiffopen("new.tif", "w"); int sampleperpixel = 3; uint32 width=320; uint32 height=240; unsigned char image[width*height*sampleperpixel]; int pixval; int count=0; file *ptr=fopen("data.txt","r"); if (ptr!=null) { while(count<width*height) {fscanf(ptr,"%d",&pixval); *(image+count)=(unsigned char)pixval; count++;} } printf("%d\n",count); tiffsetfield(out, tifftag_imagewidth, width); // set width of image tiffsetfield(out, tifftag_imagelength, height); // set height of image tiffsetfield(out, tifftag_samplesperpixel, sampleperpixel); // set number of channels per

Java MySQL - Unknown Null Pointer Exception in simple MySQL Login Frame -

i have simple login screen connects mysql database. connects fine, throws null pointer exception when tries execute. here 2 snippets of code stack trace. bolded line exception being thrown. package gui; import java.sql.*; import javax.swing.joptionpane; import java.awt.event.*; public class loginframe extends javax.swing.jframe { connection con; statement st; resultset rs; // login constructor public loginframe() { connect(); initcomponents(); setlocationrelativeto(null); } public void connect(){ try { con = drivermanager.getconnection( "jdbc:mysql://instance44668.db.xeround.com:5719/obliquedb?" + "user=name2&password=pass"); } catch (sqlexception ex) { system.err.println("cannot connect database server"); system.err.println(ex.getmessage()); } {

How to append batch file command to a strings(file names) using batch file -

i'm in process of creating batch file list names of sql scripts in folder text file. plan convert text file batch file can use execute scripts in server. have following string appended before each file name while creating initial text file sqlcmd -s %mssqlserver_name% -d %mssqlserver_dbname% -i this batch file command , appended before each file names. eg: sqlcmd -s %mssqlserver_name% -d %mssqlserver_dbname% -i 001_alter_person.sql the code i'm using is set mssqlserver_name = "%mssqlserver_name%" set %mssqlserver_dbname = "%mssqlserver_dbname%" set myvar=sqlcmd -s %mssqlserver_name% -d %mssqlserver_dbname% -i /r . %%g in (*.sql) echo %myvar% %%~nxg >> d:\test.txt pause out put i'm getting sqlcmd -s -d -i 015_alter_vboard_papers.sql let me know how tackle this set myvar=sqlcmd -s %%mssqlserver_name%% -d %%mssqlserver_dbname%% -i should cure problem - % escapes % note spaces significant in variable names, set

php - Add/Remove Select Box Not Giving Values -

Image
(the question @ bottom of post) hello, following tutorial . i have made 3 boxes total, 1 values , 2 separate values. like picture shows : this jquery : <script type="text/javascript"> $(document).ready(function() { $("#and").click(function() { $("#totalselect option:selected").each(function() { $("#select-and").append("<option value='" + $(this).val() + "'>" + $(this).text() + "</option>"); $(this).remove(); }); }); $("#removeand").click(function() { $("#select-and option:selected").each(function() { $("#totalselect").append("<option value='" + $(this).val() + "'>" + $(this).text() + "</option>"); $(this).remove(); }); }); $("#or").click(function

java - Parse JSON file using GSON -

i want parse json file in java using gson : { "descriptor" : { "app1" : { "name" : "mehdi", "age" : 21, "messages": ["msg 1","msg 2","msg 3"] }, "app2" : { "name" : "mkyong", "age" : 29, "messages": ["msg 11","msg 22","msg 33"] }, "app3" : { "name" : "amine", "age" : 23, "messages": ["msg 111","msg 222","msg 333"] } } } but don't know how acceed root element : descriptor , after app3 element , name element. i followed tutorial http://www.mkyong.com/java/gson-streaming-to-read-and-write-json/ , doesn't show case of having root , childs elements. imo

function - Populating an array with values that fall below the averange and calculating the variance -

i trying select values one-dimensional range of data fall below average. would code right? think there problem how place them array belowavg... function moybelow(data range) variant dim integer dim n long redim belowavg() variant dim varian double dim somcar() variant n=worksheetfunction.count(data) rendmoy=worksheetfunction.average(data) i=1 n if data.cells(i).value < rendmoy belowavg(i).value = data(i).value end if nb = belowavg.count j=1 nb sumsq= sumsq + (belowavg(i) - rendmoy)^2 next j next varian = sumsq/nb end function here's function returns array of doubles contains below average cells in range: function getbelowaveragevalues(data range,rangeaverage double) double() dim filteredrangevalues variant dim belowaveragevaluescount long dim belo

Eclipse CDT with MinGW displays warnings as errors -

i have little problem. i installed eclipse cdt , created c project using mingw , simple warnings (like "unused variable" etc) shown errors. the program build fine , can run it, these errors annoying. i checked compiler settings , "warnings errors (-werror)" unchecked. what do? if -werror checked, build fail. way should check enforces take care of warnings right beginning. you can suppress warnings (but not all), special options gcc (mingw). can see options needed suppress or warning in end of warning itself. nevertheless, recommend against it. it's rather better resolve warnings right beginning. strive design projects in way able built -pedantic -wall -wextra -werror options. there 3 main benefits of approach: your code bulletproof; your code conform standard closely; your code more portable across different compilers (as of them tend treat warnings errors default). remember, leaving annoying warning flood bad habit, , should r

codeigniter - how to fix codeingiter pagination and route -

i have problem whit codeignitet pagination , route! set route function class this: $route['admin/panel/students/new-stuedents-list/:num'] = "admin/newstuedentslist/$1"; then in controller, create function call newstuedentslist , load pagination library, every things work fine pagination nav... :( page loaded successfully... , data correct... bat when click example page 2 , page 2 loaded pagination nav show page butten ...!!! when call page 4 form url (http:// localhost/d/index.php/admin/panel/students/new-stuedents-list/30) , again data correctly ... pagination nav show page 1 butten , number of page dont change!!! $this->load->library('pagination'); $config['base_url'] = 'http://localhost/d/index.php/admin/panel/students/new-stuedents-list/'; $config['total_rows'] = $this->db->get('new_contest')->num_rows(); $config['pre_page'] = 10; $config['num_links'] = 20; $config['full_t

how to pass a variable from an HTML form to a perl cgi script? -

i use html form pass variable perl cgi script can process variable, , print out on html page. here html code: http://jsfiddle.net/wtvq5/ . here perl cgi script links html. here way (since uses less lines , more efficient). #!/usr/bin/perl use warnings; use strict; use cgi qw( :standard); $query = cgi->new; # process http request $user = $query->param('first_name'); # process $user... example: $foo = "foo"; $str = $user . $foo; print "content-type:text/html\r\n\r\n"; print "<html>"; print "<head>"; print "<title>hello - second cgi program</title>"; print "</head>"; print "<body>"; print "<h2>hello $str - second cgi program</h2>"; print "</body>"; print "</html>"; 1; here's way read tutorial , makes more sense me: #!/usr/bin/perl use warnings; use strict; ($buffer, @pairs, $pair, $name, $value

java - JAX-RS (Jersey) Admin Only API Calls -

this may turn out more of style question, i'm little stumped on how best design restful api. let's want provide following api calls: get /player returns current player get /player/{id} returns specified player post /admin/player/{id} registers specified player put /admin/player/{id} updates specified player as surmised, last 2 require administrative rights, , first 2 merely require user logged system. so question involves how best lay api out resources. first instinct create single playerresource doesn't have class-level @path annotation, rather defines each method @path("player/...") or @path("admin/player/...") accordingly. work? smells bit me, there better way style-wise? alternative can think of create separate resource class contain admin-only calls, smells me since i'd have 2 resources dealing same model class. i'm looking little guidance on how best design thing. first restful web app, forgive horrible ign

objective c - Asynchronous dispatch in a called method -

i trying complete long calculation determinate progress bar. working fine below code. however, in method calls scan , moves on scorewithequation before scan has finished updating storedlibrary object. i've tried different methods waiting dispatch queues finish, end hanging ui. need using callback? i've looked solution, don't understand how pass arguments , return variables , forth. -(void) scan{ if (!_sheet){ [nsbundle loadnibnamed: @"progresssheet" owner: self]; } [nsapp beginsheet: _sheet modalforwindow: [[nsapp delegate]window] modaldelegate: self didendselector: null contextinfo: nil]; [_sheet makekeyandorderfront:self]; [_progressbar setindeterminate:yes]; [_progressbar setminvalue:0]; [_progressbar startanimation:self]; __block nsmutablearray *temptracks = [[nsmutablearray alloc]init]; //do stuff dispatch_async(dispatch_get_global_queue(0, 0), ^{ //do stuff [_progressbar setdoublevalue:0.f]; [_

Rails model associations and contollers/routes -

i have setup association have shows associated cities. the relationship many shows 1 city. i create new shows city like such: mysite.com/cities/1/shows/new i have setup models : shows belongs_to :city city has_many :shows how setup city controller new shows action? how setup routes.rb this? i've figured out in routes.rb resources :cities resources :shows end you use rule such : match /cities/:id/shows/new => "shows#new" and after, in new action in controller shows, preload city_id params[:id], def new @show = show.new(:city_id => params[:id]) end

android - PreferenceFragment java.lang.RuntimeException -

i follow sample provided commonsware in link single header and when run it gave me force close below logcat , any advice appreciated , logcat : fatal exception: main java.lang.runtimeexception: unable start activity componentinfo {com.commonsware.android.pref1header/com.commonsware.android.pref1header. fragmentsdemo}: android.view.inflateexception: binary xml file line #1: error inflating class fragment @ android.app.activitythread.performlaunchactivity(activitythread.java:1651) @ android.app.activitythread.handlelaunchactivity(activitythread.java:1667) @ android.app.activitythread.access$1500(activitythread.java:117) @ android.app.activitythread$h.handlemessage(activitythread.java:935) @ android.os.handler.dispatchmessage(handler.java:99) @ android.os.looper.loop(looper.java:130) @ android.app.activitythread.main(activitythread.java:3687) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:507) @ com.android.interna

javascript - Font-face check from Modernizr -

modernizr detects css3 font-face support. http://modernizr.com/download/ how source of font-face test outside modernizr? there's file in repo related test, i'm not sure how use https://github.com/modernizr/modernizr/blob/master/feature-detects/css/fontface.js that file doesn't seem easy decouple rest of modernizr. in opinion easier go , use modernizr. you can customize in downloads section in way donwload checks need, if need font-face test, download part. if reason not want use modernizr, front-end developer called paul irish has done @font-face feature detection more or less looking for. hope helps.

java - DFS over string trie (prefix) -

i wrote following prefix trie: class trienode { char letter; hashmap<character,trienode> children; boolean fullword; trienode(char letter) { this.letter = letter; children = new hashmap<character, trienode>(); this.fullword = false; } } class tree{ static trienode createtree() { return (new trienode('\0')); } static void insertword(trienode root, string word) { int l = word.length(); char[] letters = word.tochararray(); trienode curnode = root; (int = 0; < l; i++) { if (!curnode.children.containskey(letters[i])) curnode.children.put(letters[i], new trienode(letters[i])); curnode = curnode.children.get(letters[i]); } curnode.fullword = true; } } i add dfs method in order find first node has more 1 child (so show me longest common prefix). i wrote code: static void dfs(trienode node) { (trie

jquery - Javascript create array using foreach checkbox values -

ok guys have form <input id="valor" name="valor[]" type="checkbox" value="1" /> <input id="valor" name="valor[]" type="checkbox" value="2" /> <input id="valor" name="valor[]" type="checkbox" value="3" /> <input id="valor" name="valor[]" type="checkbox" value="4" /> <input id="valor" name="valor[]" type="checkbox" value="5" /> <input id="valor" name="valor[]" type="checkbox" value="6" /> <input id="result" name="result" type="text" /> what need is: when check of checkboxes array format (for example) 1|2|4 is updated in real time inside result text field, can use in php explode tryed lot of thins none works ps. passing trough post not enough know if post field gonn

asp.net mvc 3 - Entity framework is making the id null on insert -

i'm getting following error when try insert new row in 1 of relational tables. have following 2 models: public class companycredit { [key] [databasegenerated(databasegeneratedoption.identity)] public int creditid { get; set; } public int plancredit { get; set; } public datetime? plancreditexpirationdate { get; set; } } and public class companyinformation { [key] [databasegeneratedattribute(databasegeneratedoption.identity)] public int id { get; set; } [required] [displayname("company name:")] public string companyname { get; set; } public string timezone { get; set; } //navigation properties public virtual companycredit credits { get; set; } } and relation in dbcontext modelbuilder.entity<companyinformation>().hasoptional(e => e.credits); i'm trying add record inside companycredit table so: if (_company.credits == null) { var _credits = new companycredit(); _credits.p

MIT Scheme Message Passing Abstraction -

in computer science course taking, homework, tasked several different questions pertaining message passing. have been able solve one, asks following: write mailman object factory (make-mailman) takes in no parameters , returns message-passing object responds following messages: 'add-to-route : return procedure takes in arbitrary number of mailbox objects , adds them mailman object's “route” 'collect-letters : return procedure takes in arbitrary number of letter objects , collects them future distribution 'distribute : add each of collected letters mailbox on mailman's route address matches letter's destination , return list of letters destinations did not match mailboxes on route (note: after each passing of 'distribute mailman object should have no collected letters.) some remarks given make code easier include: if multiple letters distributed same mailbox in 1 distribution round, 1 of them may “latest” let

c# - Changes in Model .NET asp.net MVC4 -

i've created project using steps create model; create controller model , scaffolding views; i've tried access, , works fine, i've made changes in model rebuilt , tried run 1 more time, , got error: {"the model backing 'codingcontext' context has changed since database created. consider using code first migrations update database ( http://go.microsoft.com/fwlink/?linkid=238269 )."} this error brings null inner exception and stack: at system.data.entity.createdatabaseifnotexists 1.initializedatabase(tcontext context) @ system.data.entity.internal.internalcontext.<>c__displayclass8.<performdatabaseinitialization>b__6() @ system.data.entity.internal.internalcontext.performinitializationaction(action action) @ system.data.entity.internal.internalcontext.performdatabaseinitialization() @ system.data.entity.internal.lazyinternalcontext.<initializedatabase>b__4(internalcontext c) @ system.data.e