Posts

Showing posts from February, 2010

generating random numbers in java and finding percentage of how many are less than or equal to 50 -

my question why isn't code generating amount of numbers users enters? right code generating 1 number. here original question given me: "in main method, prompt user number n. write method called assessrandomness generates random number between 1 , 100 'n' times , return percentage of times number less or equal 50. call assessrandomness method main , display result user main . not interact user within assessrandomness method." output: how many random numbers should generate? 10 <assume random numbers generated 11 7 50 61 52 3 92 100 81 66> 40% of numbers 50 or less my code: public static void main(string[] args) { scanner in = new scanner(system.in); system.out.println("how many random numbers should generate?: "); int number = in.nextint(); assessrandomness(number); } public static double assessrandomness(int n){ int random = (int)(math.random()*100); int randomnumberslessthan50 = 0; i...

Taking advantage of alphabetical order in String database search in Java -

i writing java program. i have thousands of lists stored .txt files. each list contains thousands of words, set in alphabetical order. words in each list different (there no repetitions). i have search these lists, in order see whether query-word present in each list or not. how can take advantage of alphabetical order make search quicker? brute-force approach ( .equals() method) works takes several hours. thank in advance help! grateful if send me bits of code. java provides arrays.binarysearch(object[] array, object key) , collections.binarysearch(list<? extends comparable<? super t>> list, t key) methods improve results. they're not optimal solution, they're easy use , better brute force.

c# - Miller-Rabin Primality test fails for large numbers -

after studying other answers related miller-rabin test primality, implemented version in c#, begins fail somewhere in region of 3 billion, , time gets 4 billion, stops recognizing primes. suspect suffering overflow, cannot figure out where. goal work value in range 0 <= n <= 2^63 - 1. i created fiddle: https://dotnetfiddle.net/3f7p97 among ideas tried were: using precalculated bases 2, 325, 9375, 28178, 450775, 9780504, 1795265022 advertised working numbers less 2^64 website: http://miller-rabin.appspot.com/ recommended answerer of question: miller rabin primality test accuracy writing overflow resistant power-mod function computing a^b mod n. writing overflow resistant multiplication function computing a*b mod n (using russian peasant algorithm). here code fiddle of time created question: using system; using system.collections.generic; using system.linq; // author: paul a. chernoch // // purpose: use rabin-miller algorithm test if numbers prime. // problem: s...

xml parsing - Any Alternate Solution to Xml Unmarshalling Error in Java-8? : “secure-processing org.xml.sax.SAXNotRecognizedException" -

note: error has been discussed here , various solutions have been suggested rid of jars conflicts java-8's default implementation. my question extension problem. for sake of completeness, here stacktrace facing, when run code java-8: feb 29, 2016 12:06:41 pm com.sun.xml.internal.bind.v2.util.xmlfactory createparserfactory severe: null org.xml.sax.saxnotrecognizedexception: http://javax.xml.xmlconstants/feature/secure-processing @ org.apache.xerces.parsers.abstractsaxparser.setfeature(abstractsaxparser.java:1487) @ org.apache.xerces.jaxp.saxparserimpl.setfeatures(saxparserimpl.java:145) @ org.apache.xerces.jaxp.saxparserimpl.<init>(saxparserimpl.java:128) @ org.apache.xerces.jaxp.saxparserfactoryimpl.newsaxparserimpl(saxparserfactoryimpl.java:112) @ org.apache.xerces.jaxp.saxparserfactoryimpl.setfeature(saxparserfactoryimpl.java:140) @ com.sun.xml.internal.bind.v2.util.xmlfactory.createparserfactory(xmlfactory.java:121) @ com.sun.xml.in...

Should a Kafka consumer consume from all partitions to get a complete message? -

i going through kafka, , understand topics partitioned ordered sequences of partitions. since topics partitioned, should consumer consume of partitions, in order complete message? if so, responsibility make complete message out of messages? each complete message written, in entirety, single offset in single partition. reading single message 1 partition using of available consumer api's, you're assured of getting whole thing. see kafka site more info

nginx - JasperServer proxy CSRF error -

i have new installation of jasperreports server 6.2 using bundled tomcat on ubuntu 14.04 lts nginx proxy can access https://mydomain.xyz/jasperserver . works, i'm not able manage users , roles. if bypass nginx , go straight tomcat http://123.123.123.123:8080/jasperserver , works perfectly. log indicates: 2016-02-28 19:44:08,024 error csrfguard,http-nio-8080-exec-3:44 - potential cross-site request forgery (csrf) attack thwarted (user:, ip:127.0.0.1, uri:/jasperserver/flow.html, error:required token missing request) this same older question: running jasperserver behind nginx: potential csrf attack . i've tried both mitigations suggested, , it's still not working. i tried setting underscores_in_headers on; , first in http , in server , in both. when didn't work, removed underscores jasper_csrf_token , owasp_csrftoken in web-inf/esapi/owasp.csrfguard.properties i rebooted server sure cleared , restarted, still not working. i'm seeking suggestions...

ios - How to display .svg image using swift -

i have .svg image file want display in project. i tried using uiimageview, works .png & .jpg image formats, not .svg extension. there way display .svg image using uiwebview or uiimageview ? try code var path: string = nsbundle.mainbundle().pathforresource("nameoffile", oftype: "svg")! var url: nsurl = nsurl.fileurlwithpath(path) //creating url points towards our path //creating page request load our url (which points our path) var request: nsurlrequest = nsurlrequest(url: url) webview.loadrequest(request) //telling our webview load our above request

unity3d - Difference registered user from guest on login -

im using unity3d , smartfoxserver develop multiplayer game. i want players can register (im using sign assistance smartfoxserver), can login play. also, can play guest players. i enabled feature in admin, when made loginrequest in client, if user doesn't exists (or password wrong) i'm logged in guest. i need command registered users login , 1 guest players login or way tell smartfoxserver difference between registered user login, , guest login. there built in solution? here's 1 way of doing it. implement customhandler login event //inside main extension addeventhandler(sfseventtype.user_login, userlogineventhandler.class); public class userlogineventhandler extends baseservereventhandler{ @override public void handleserverevent(isfsevent event) throws sfsexception { string loginname = (string) event.getparameter(sfseventparam.login_name); //send blank username login guest, smartfox create guest user if(loginname.isempty('')) return //...

java - File not saved on different computer using outputstream and filechooser -

i trying edit inside .xls file using apache poi library. updation succesfull on local computer.but, stuck when jar file of application not saved excel file on computer on installed. filechooser filechooser = new filechooser(); filechooser.settitle("generated data of dvat "); filechooser.settitle("generate xls file of " + "dvat 31"); filechooser.getextensionfilters().addall( new extensionfilter("xls files", "*.xls")); filechooser.setinitialfilename(common .replacewhitespaceandslash("dvat31") + "_" + common.replacewhitespaceandslash(common.comp.getname()+"_") +this.fromdate+"_"+this.todate+ ".xls"); filechooser.setinitialdirectory(new file(system .getproperty("user.home") + "/desk...

javascript - ExtJs Grid into a BufferedGrid -

the problem of making grid buffered grid not resolved.as have applied of techniques being used,the problem in grid still exists.how can apply bufferedrenderer or bufferedgrid property in applied extjs grid loads 20000 records? the way can tell try buffered store, try set on store buffered: true; that allows store prefetch , cache in page cache, pages of records, , satisfy loading requirements page cache. to use buffered stores, initiate process loading first page. number of rows rendered determined automatically, , range of pages needed keep cache primed scrolling requested , cached. example: mystore.loadpage(1); // load page 1 a bufferedrenderer instantiated monitor scrolling in grid, , refresh view's rows page cache needed. pull new data page cache when scrolling of view draws upon data near either end of prefetched data. the margins trigger view refreshing prefetched data ext.grid.plugin.bufferedrenderer.numfromedge, ext.grid.plugin.bufferedrenderer.lead...

c++ - How to set different compiler warning levels for native code and external code in CMake -

suppose setting strict compiler warning level own code problem code dependent on external library wasn't written rigorously, when include header file external library sorts of warnings. there way can set different warning levels different files in cmake? here example showing situation, suppose have main.cpp #include "external.h" int main(){ // code } and corresponding cmakelists.txt cmake_minimum_required(version 2.8) project(test) set(project_srcs ${project_source_dir}/main.cpp ) if(msvc) if(cmake_cxx_flags matches "/w[0-4]") string(regex replace "/w[0-4]" "/w4" cmake_cxx_flags "${cmake_cxx_flags}") else() set(cmake_cxx_flags "${cmake_cxx_flags} /w4") endif() elseif(cmake_compiler_is_gnucc or cmake_compiler_is_gnucxx) set(cmake_cxx_flags "${cmake_cxx_flags} -w -wall -werror -wshadow") endif() include_directories(${external_inc}) add_executable(test ${project_srcs}) target_link...

javascript - Filtering data based on dynamic check box Categories in Angular JS? -

i'm trying achieve filter check box option dynamic data category , sub category. how want is, [] category [] sub category [] sub category [] category [] sub category [] sub category [] sub category ... , on assume [] check box above. here's sample json data : [ { "category": { "name": "aaa - 1" }, "parentcategory": { "name": "aaa" }, "title" : "xxxxx", }, { "category": { "name": "aaa - 2" }, "parentcategory": { "name": "aaa" }, "title" : "yyyy", } ] based upon above data, i'm trying want is, sidebar : [] aaa [] aaa - 1 [] aaa - 2 main content : initially show title. after checked, show title related category/sub category. note : pl don't thin...

listview - Typo3 BE list_view creation? -

i need make new list out of existing 1 without loosing connection. lets have entry set of "cats", somehow need produce list "cats" have flag "red". need list "cats" within page tree not in same folder. love way, simple user suspect there doing me. how can create "red cat" lists in typo3 be? thanks! the single table view lets sort property. not enough not filtered list , display records single pid (the 1 have selected in page tree). your best option create extension backend module. add list action controller , query against repository cats stored. remember set default query settings correctly not respect pid or record (respectstoragepid). also, default location of backend templates might buggy generated extension builder (if decide use that).

which task / program will consume lot of memory space of android device? -

i want use memory or stress memory, @ peak capability consuming of ram space. came tasks parallelly searching text in many files, calling functions recursively fill stack space. searching not fill memory on own. fill heap need hold many or large objects in memory. for example: list<string> mlist = new arraylist<string>(); (int = 0; < 999999; i++) { mlist.add("garbage"); }

html5 - Align css drop down menu to the center -

Image
i'm trying align bootstrap dropdown menu center of parent div . it's left aligned default guess. the code $('ul.nav li.dropdown').hover(function() { $(this).find('.dropdown-menu').stop(true, true).delay(200).fadein(500); }, function() { $(this).find('.dropdown-menu').stop(true, true).delay(200).fadeout(500); }); /* bootstrap dropdown hover menu*/ body { font-family: 'pt sans', sans-serif; font-size: 13px; font-weight: 400; color: #4f5d6e; position: relative; background: rgb(26, 49, 95); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(26, 49, 95, 1)), color-stop(10%, rgba(26, 49, 95, 1)), color-stop(24%, rgba(29, 108, 141, 1)), color-stop(37%, rgba(41, 136, 151, 1)), color-stop(77%, rgba(39, 45, 100, 1)), color-stop(90%, rgba(26, 49, 95, 1)), color-stop(100%, rgba(26, 49, 95, 1))); filter: progid: dximagetransform.microsoft.gradient( startcolorstr='#1a315f', end...

Performance of like 'query%' on multimillion rows, postgresql -

we have table 10 million rows. need find first few rows 'user%' . this query fast if matches @ least 2 rows (it returns results in 0.5 sec). if doesn't find 2 rows matching criteria, taking @ least 10 sec. 10 secs huge (since using auto suggestions, users not wait long see suggestions.) query: select distinct(name) user_sessions name 'user%' limit 2; in above query, name column of type citext , indexed. whenever you're working on performance, start explain ing query. that'll show the query optimizer's plan, , can sense of how long it's spending doing various pieces. in particular, check full table scans, mean database examining every row in table. since query fast when finds , slow when doesn't, sounds indeed hitting full table scan. believe it's indexed, since you're doing like , standard string index can't used efficiently. you'll want check out varchar_pattern_ops (or text_pattern_ops , depending on colu...

hash - Meteor,why same password after hashing, different string stored in database -

i found meteor default use sha-256 hash password. confused same password each account after hashing become different string stored in database. tell detail implementation, thx per meteor docs, accounts-password uses bcrypt . if @ source code of loginwithpassword , should able find out salt stored. second source, read masteram's answer laravel & meteor password hashing indicates meteor 2011 on uses $2y$ hash strings, i.e. php crypt_blowfish , uses crypt_blowfish - blowfish hashing salt follows: "$2a$", "$2x$" or "$2y$", 2 digit cost parameter, "$", , 22 characters alphabet "./0-9a-za-z". using characters outside of range in salt cause crypt() return zero-length string. 2 digit cost parameter base-2 logarithm of iteration count underlying blowfish-based hashing algorithmeter , must in range 04-31, values outside range cause crypt() fail. versions of php before 5.3.7 support "$2a$" salt prefix: php 5...

selenium webdriver - Not able to click on hidden element in protractor?(Please go through the image.) -

Image
here html code : <li class="subdropdown"> <a href="" class="submenu-toggle">create position</a> <ul class="list-unstyled dropdown-submenu" role="menu"> <li style="cursor: pointer;"> <a ng-click="openpositionmodal($event)"><i class="glyphicon glyphicon-list-alt"></i> new position</a> </li> here test case: 1) move cursor on "create position" toggle menu. 2) after mouse hover, click on "new position" menu list. browser.actions() , "by link text" , "by partial link text" locators should here: var ec = protractor.expectedconditions; // open menu // choose position var chooseposition = element(by.linktext('create position')); browser.actions().mousemove(chooseposition...

c++ - How to check if double linked list is a pallindrome without using extra space? -

Image
recently went interview , asked me "to check if below double linked list pallindrome without using storage stl's, linked-list, stack, queue, tree, string, character arrays. etc.." unable give perfect solution though. below image view. this not homework question merely question find solutions shared. declare 2 iterators, start , end. loop through list , decrement/increment them simultaneously, comparing @ each step. note: algorithm assumes have overridden operators, works sort of list, not numerical lists. for(int i=0;i<list.size()/2;i++){ if(*start!=*end) return false; start++; end--; } return true; the key here using iterators instead of working list directly.

matlab - Find Date Range Rows and Extract -

Image
this should straight-forward in matlab don't know how , stuck. have data looks below in form: mm/dd/yyyy hh:mm windspeed - hourly data spanning years 1991 present (2013) of cell arrays , numeric array: 8/22/1993 23:00 2.381453514 8/23/1993 0:00 3.39369154 8/23/1993 1:00 5.398661613 8/23/1993 2:00 7.231492996 8/23/1993 3:00 9.187699318 8/23/1993 4:00 9.802619934 8/23/1993 5:00 8.85418129 8/23/1993 6:00 9.889941216 8/23/1993 7:00 10.4628706 8/23/1993 8:00 10.8967123 8/23/1993 9:00 10.12729263 8/23/1993 10:00 9.106620789 8/23/1993 11:00 7.600066185 8/23/1993 12:00 6.597990036 8/23/1993 13:00 6.764455795 8/23/1993 14:00 7.360760689 8/23/1993 15:00 5.828835011 i trying extract third column ( windspeed ). need able change date range extract month @ time example rows containing month "08" august of year 1993 , future use rows containing "09" september , year 2013. i'm not sure if it's better use datenum or find function , how code either ...

android - Gson Map Key Pair to json -

i want parse json this: map<pair<string, date>, product> since json cannot have pair has key gives me this: {"android.util.pair@a24f8432":{"name:"name","brand":"brand"....}} at point achieve goal i'll have create pair<string, date> object serialize , deserialize methods. this need help, have no idea how this. have create mypair class extending pair , implementing jsonserializer<pair<string, date>> ...? thank time! edit: i'm trying use typeadapter<t> no luck... public class mytypeadapter extends typeadapter<pair<string, date>> { @override public pair<string, date> read(jsonreader jsonreader) throws ioexception { if (jsonreader.peek() == jsontoken.null) { jsonreader.nextnull(); return null; } string id = jsonreader.nextstring(); date evaluated = null; try { evaluated = mysimpledateformat.parse(jsonreader.nextst...

How to serve favicon.ico and robots.txt files from ASP.NET MVC3 application -

asp.net mvc3 application hosted in apache in mono virtual host address http://www.mysite.com requests files robots.txt , favicon.ico , apple-touch-icon.png cause 404 error below since there no mvc3 controllers names. how server files ? it possible force apache serve them regular files or can force mvc3 application return files ? proper way implement ? system.web.httpexception: controller path '/robots.txt' not found or not implement icontroller. @ system.web.mvc.defaultcontrollerfactory.getcontrollerinstance (system.web.routing.requestcontext requestcontext, system.type controllertype) [0x00000] in <filename unknown>:0 @ system.web.mvc.defaultcontrollerfactory.createcontroller (system.web.routing.requestcontext requestcontext, system.string controllername) [0x00000] in <filename unknown>:0 @ system.web.mvc.mvchandler.processrequestinit (system.web.httpcontextbase httpcontext, icontroller& controller, icontrollerfactory& factory) [0x00000] i...

Javascript Regex Negative Look-ahead (Validating EXACTLY {X} Occurrences and Not More) -

i think it's called negative look-ahead /x(?!y)/ , i'm not sure since started doing regex stuff today. i'm trying validate following: // matches aa-00 through zz-99 var regex = /([a-za-z]{2}(?!\b))((-){1})([0-9]{2}(?!\b))/; var result = regex.test("ev-05"); // should pass console.log("ev-05: " + result + "\n"); result = regex.test("ev-09"); // should pass console.log("ev-09: " + result + "\n"); result = regex.test("ev-11"); // should pass console.log("ev-11: " + result + "\n"); result = regex.test("ev-30"); // should pass console.log("ev-30: " + result + "\n"); result = regex.test("ev03"); // should fail console.log("ev03: " + result + "\n"); result = regex.test("e-17"); // should fail console.log("e-17: " + result + "\n"); result = regex.test("ev-5...

android - AndroidAnnotations @REST: The converter class must be a subtype of org.springframework.http.converter.HttpMessageConverter RestClient.java -

i want create rest client using androidannotations when define converters on @rest annotation, receive following compile error: the converter class must subtype of org.springframework.http.converter.httpmessageconverter restclient.java i use libraries: /libs androidannotations-api-2.7.1.jar gson-2.2.4.jar jackson-core-asl-1.9.13 jackson-asl-0.9.5 jackson-mapper-asl-1.9.13 spring-android-auth-1.0.1.release.jar spring-android-core-1.0.1.release.jar spring-android-rest-template-1.0.1.release.jar /compile-libs androidannotations-2.7.1.jar my source similar example androidannotations package com.sinffredy.spring; import org.springframework.http.converter.json.mappingjacksonhttpmessageconverter; import com.googlecode.androidannotations.annotations.rest.get; import com.googlecode.androidannotations.annotations.rest.rest; @rest(rooturl = "http://my.url/ajax/services", converters = { mappingjacksonhttpmessageconverter.class }) public interface restclient { ...

jquery - remove item from localStorage -

i'm trying remove item localstorage. when user clicks on delete button, need examine contained in localstorage , remove value based on row deleted. for example, localstorage contains following comma delimited list: contact,user,account if row deleted account row, need remove account value list localstorage contain: contact,user or, if row deleted user row, need remove user value list localstorage contain: contact,account here jquery code: <script type="text/javascript"> var j$ = jquery.noconflict(); j$(document).ready(function() { var datarows = j$('tr.datarow'); localstorage.activebuttons = ''; var active = localstorage.activebuttons.split(','); datarows.each(function(index, elem) { updateimages(elem, active[index]); }); j$("img[id$=':deleteimage']").on("click", function(event) { updateimag...

c - What does %% do in printf? -

given following program in c, #include <stdio.h> int main() { printf(" \"books %% or %% apparels\""); getchar(); return 0; } the program prints books % or % apparels, know significance of %%, because looks unnecessary. % indicates format escape sequence used formatting variables passed printf() . so have escape print % character. http://en.cppreference.com/w/c/io/fprintf if replace %% % , this #include <stdio.h> int main (int argc, char *argv[]) { printf(" \"books % or % apparels\""); return 0; } there 2 escape sequences printf() : "% o" [guesswork] not yields valid escape sequence printf() disregards , print is. "% a" printf() try float empty parameter list , print "hexadecimal floating point, lowercase" ( %a , see above webpage). due c calling convention (disclaimer: i'm not expert on this), garbage memory used , explains result...

javascript - Focus on next form element directly after button -

how focus on next textarea comes after button clicked? http://jsfiddle.net/infatti/gmpcz/ $('.add').click(function(){ $(this).closest('div').next('textarea:visible').focus(); }); closest() starts current element , searches dom first element matching selector. div want isn't ancestor of link, sibling. http://jsfiddle.net/8tvxd/ $('.add').click(function(){ $(this).next('div').find('textarea:visible:first').focus(); });

c# - How to change the Windows font folder? -

so this question covers nicely how current font path, if want change path? for example, currently system.environment.getfolderpath(system.environment.specialfolder.fonts); would contain c:\windows\fonts but if purposes of project want point d:\resources\fonts is there way can that? or way tell windows not use environment path , instead use path want? you don't need change system settings. can load fonts whichever folder like. example: var pfc = new privatefontcollection(); pfc.addfontfile(fontfile); var fontfamily = new fontfamily(pfc.families.first().name,pfc); richtextbox1.font = new font(fontfamily, 20f, fontstyle.bold); richtextbox1.text = "test";

angularjs - Angular.js - using NG-Grid, how to get the length of value inside cell. Nothing seems to work -

i new angular , ng-grid , trying desperately @ new company speed on it. using ng-grid anugular.js there way format cell using custom cell template if cell contains more x number of characters. i've search web , api , examples cannot find answer one. instance if cell has more 40 characters make background of cell red. doesn't seem .length() function comparison reason. this works great: {green: row.getproperty(col.field) > 30}> but doesn't {green: row.getproperty(col.field).length() < 40}> using .length function wrong here or can used inside ng-grid cells? how length of value inside cell? here basic plnkr based on simple example. http://plnkr.co/edit/fcupoz81vxfgt9sbhznz thanks use length instead of length() function. string property not function. http://plnkr.co/edit/8kb8rje0wnc2opyuwoyz?p=preview

c# - Selectively Serialize and Deserialize -

i have user object in linq-to-sql mapping. there password attribute on want deserialize when submitted user--for example, during login. never want pass attribute user, though, since contain encrypted version of actual password , i'd rather not expose information password or encryption method. there way object-wide tell linq-to-sql never pass password attribute when returning user object? i use https encryption, because in accessing service, default enforce encryption, saves on client side code. have few possible answers though: blank out password when return user object wcf side. (you can change value of password of object, , not save change.. return object client ) use custom object login response returns necessary information client. implement data transfer object pattern, nuget package automapper. if aren't salting , hashing passwords, please please please consider it.

c++ - OpenCV: imread gives CV_8UC3, can't convert to CV_8UC4? -

need image try load , convert opencv: here code: templ = imread("template.bmp",-1); cout<<"templ before convert: "<<type2str(templ.type())<<endl; templ.convertto(templ,cv_8uc4); cout<<"templ after convert: "<<type2str(templ.type())<<endl; this gives me cv_8uc3! image not made converting 4 channels or this? or need scaling factor (read sth this)? thanks help, best regards! cvtcolor( src,dst, cv_bgr2bgra );

php - Can <?=$var?> syntax cause problems? -

this question has answer here: are php short tags acceptable use? 24 answers i know syntax <? ?> not allowed, , spark notices if have them enabled... haven't seen many people use <?=$var?> echo variable... illegal syntax or accepted in versions of php? <?php echo $var; ?> vs <?=$var?> yes, depends on php.ini settings. short_open_tag has on . your code not work, if short open tags aren't allowed (old servers [< php 5.4.0] don't support default). if you'd write code downwards compatible , not use it. i got lot of anoying trouble because of being lazy , using short open tags. ;-)

python - pyqt: Lower dock widget -

Image
i trying find way lower dock widget title bar showing. right trying hide widget inside dock widget getting this: the dock widget "lowers" width doesn't stretch across whole screen, there way can fix that? or other way of lowering dock widget? here code window: class ui_mainwindow(object): def setupui(self, mainwindow): mainwindow.setobjectname(_fromutf8("mainwindow")) mainwindow.resize(320, 240) self.centralwidget = qtgui.qwidget(mainwindow) self.centralwidget.setobjectname(_fromutf8("centralwidget")) mainwindow.setcentralwidget(self.centralwidget) self.dockwidget = qtgui.qdockwidget(mainwindow) self.dockwidget.setfeatures(qtgui.qdockwidget.nodockwidgetfeatures) self.dockwidget.setobjectname(_fromutf8("dockwidget")) self.dockwidget.setallowedareas(qt.bottomdockwidgetarea) self.textedit = qtgui.qtextedit() self.textedit.setgeometry(qtc...

.htaccess - Redirect with htaccess should not access some pages -

i have 3 pages: index.html about.html contact.html i need create htaccess redirects home ( index.html ) if visitor not go 1 of 3 pages. example: if go page: asdf.html redirected index.html but if income contact.html shows me page. ¿how can do? thank you. enable mod_rewrite , .htaccess through httpd.conf , put code in document_root/.htaccess file: options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase / rewritecond %{request_uri} !^/(index|about|contact)\.html [nc] rewriterule ^(?!.+?\.(?:jpe?g|gif|bmp|png|css|js)$).*$ /index.html [l,r,nc]

python - Attribute never updates between requests to a FlaskView -

i've class this: class ma_class(flaskview): route_base = '/' state = false @route('/load') def load(self): self.state = true return 'load : ok' @route('/stuff') def do_something(self) if not self.state: return 'you must invoke load method' when send request url/load load : ok in response. but after, when send request url/stuff you must invoke load method . self.state hasn't changed, , have no idea why. thanks reading http stateless. means 1 request not know second request , on, unless tell in way. if using flask, can use "session" achieve that. sessions way save information acorss multiple requests (e.g login). from flask import session class ma_class(flaskview): route_base = '/' @route('/load') def load(self): session['state'] = true return 'load : ok' @route('/stuff') def do_something(self) if 'stat...

javascript - Pick random value from firebase snapshot -

i'm using firebase's foreach each child in tree url objective, when page loads grab random item firebase , show it data structure grabbit (table name) active (for active items sale) category (the category of item ie womensclothes, mensshoes etc) unique id of item on page load go http://gamerholic.firebase.com/grabbit/active , grab 1 of categories , return it.. script var grabbitref = new firebase('https://gamerholic.firebaseio.com/grabbit/active/'); grabbitref.on('value', function(snapshot) { if(snapshot.val() === null) { alert("invalid"); } else { // snap shot data: snapshot.foreach(function(snapshot) { var name = snapshot.name(); alert(name); }); } }); after have random category "electronics", new snapshot , have return random item that's in electronics var grabbitref = new firebase('https://gamerholic.firebaseio.com/grabbit/active/'+name); grabbitref.on('value...

css transitions - css3 cubic-bezier timing function in and out -

i have css3 transition, i've used cubic-bezier timing function works correctly on way in not on way out. have feeling what's happening runs cubic-bezier forward on animation out, , forwards again on way out, instead i'm trying have reverse cubic-bezier curve on way out. you can see when hover on box swings out fast , slows, , when release hover moves out super fast. here in action, not 100 percent sure how fix this. http://jsbin.com/apunaca/2/edit

Composite columns and "IN" relation in Cassandra -

i have following column family in cassandra storing time series data in small number of "wide" rows: create table data_bucket ( day_of_year int, minute_of_day int, event_id int, data ascii, primary key (data_of_year, minute_of_day, event_id) ) on cql shell, able run query such this: select * data_bucket day_of_year = 266 , minute_of_day = 244 , event_id in (4, 7, 11, 1990, 3433) essentially, fix value of first component of composite column name (minute_of_day) , want select non-contiguous set of columns based on distinct values of second component (event_id). since "in" relation interpreted equality relation, works fine. now question is, how accomplish same type of composite column slicing programmatically , without cql. far have tried python client pycassa , java client astyanax, without success. any thoughts welcome. edit: i'm adding describe output of column family seen through cassandra-cli. since looking thrift-based solutio...

asynchronous - ASync Array update with AJAX request -

i've been trying figure out how update global variable using ajax request. i'm stuck , need help. var markerarray = []; function jsonload(position){ //loads json , markers console.log("data getting jsoned"); $.getjson('json/***.json', function(result){ //gets json , parses results $.each(result, function(index, value){ //for each result, give index , value reps.push({value: value, index: index}); //push value @ array. ex. ian calderon }); try{ (var i=0; i<reps.length; i++){ if(reps[i].value.lat !== 'undefined' && reps[i].value.position === position){ var marker = (createmarker(reps[i].value.lat, reps[i].value.long, reps[i].index)); //only try create marker if there values updatearray(markerarray, marker); }}} catch(e){ } }); } i have tried doing this: function updatearray(array, obj){ $.ajax({ success : function(){ array.push(obj);...

c - free( ptr ) error - invalid size -

i have c program seems performing ok unless call free on pointer. #include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <stdlib.h> int main() { int i; gid_t *list; int num_groups = getgroups(0, null); list = malloc(num_groups * sizeof(list)); if (getgroups(num_groups, list) != -1) { (i = 0; < num_groups; i++) { printf("%d ", *list++); } } free(list); // free(): invalid size: 0x0000000002448040 *** return 0; } i've seen lots of similar posts refer invalid next size , not invalid size . i'm newbie when comes c - can't work out what's going on. you changing list *list++ , therefore free invalid. need free original pointer obtained malloc . as dasblinkenlight notes, you're not allocating memory right way. think going idiom, forgot *: list = malloc(num_groups * sizeof *list); ^ ...

Similar technology to Chrome's Native Client Messaging in Firefox? -

we want replace custom npapi interface between browser based web application , client side daemon process. is there similar technology chrome's native client messaging in firefox? js-ctypes[1] closest alternative mozilla. https://developer.mozilla.org/en-us/docs/mozilla/js-ctypes i have c++ module compile binary executable native-messaging or library js-ctypes. difference between 2 native-messaging calls binary executable , performs stdin/stdout data exchange, , js-ctypes opens static/shared library (via dlopen) , calls exposed methods of library can return compatible data types[2] , optionally call passed javascript callback method. [1] https://developer.mozilla.org/en-us/docs/mozilla/js-ctypes [2] https://developer.mozilla.org/en-us/docs/mozilla/js-ctypes/js-ctypes_reference/ctypes#predefined_data_types

c# - User Control binding not working for nested property -

i have user control called informationcontrol. using in window, this: <general:informationcontrol grid.row="0" timetostart="{binding timetostart}" poor="{binding path=mine.poor}" status="{binding path=mine.minestatus}"/> the binding on timetostart dependency property working fine, when use path=object.property doesn't seem work. however, when use path=object.property on regular control (i.e. not usercontrol) works fine: <itemscontrol grid.row="2" name="items" itemssource="{binding path=mine.participants}"> i'm breaking in getter mine, , in binding logging saying null, has been set. fact it's trying property in first place makes me feel binding correct can't work out why it's not working. do need different make sure binding nested properties works on usercontrol dependency properties ? code behind information control, set break point @ debug.print("newval...

javascript - How to get value from two dropdown and pass it to different url? -

i have 2 dropdown , want selected year value of first 1 , add url of header page , second dropdown url options when select php page second dropdown can see year value on page. <?php $id = $_get['id']; ?> <form method="post"> report period: <select name="year" id="year" > <option style="display:none;"> select</option> <?php $result1 = mysql_query("select year year_data id=$id"); while ($row = mysql_fetch_assoc($result1)) { $period= $row['year']; echo "<option value=\"$period\">$period</option>"; } ?> </select> type: <select name="report" id="report" > <option style="display:none;">--select--</option> <?php echo "<option value=\"".reporta."...