Posts

Showing posts from May, 2012

security - Constant-time string comparison function -

to compare 2 strings, use strcmp or 1 of variants. however, because strcmp take longer if more characters match, vulnerable timing attacks. there constant-time string comparison function in standard library on windows? i don't think windows nor visual studio has such functions. at least simple strcmp can whip yourself. if care equality: int strctcmp(const char*a, const char*b) { int r = 0; (; *a && *b; ++a, ++b) { r |= *a != *b; } return r; } if need sortable results and need process of longest string: int strctcmp(const char*a, const char*b) { int r = 0, c; (;;) { c = *a - *b; if (!r) r = c; if (!*a && !*b) break; if (*a) ++a; if (*b) ++b; } return r; } these not perfect timing wise should more enough network based.

c++ - Split string into string and int -

i trying use sscanf(inputcmd, "%s%d", cmd, value); convert string inputcmd string cmd , , int value in arduino sketch. isn't working, apparently variables wrong type (string, instead of char*) inputcmd in format foo90, , neither length of number or string can assumed constant. best way separate 2 parts of inputcmd , store them in 2 variables? cmd should foo, , value should 90. thanks. besides problem string versus char* , scanf format "%s" reads space-delimited string. if there's no space between string , number can't use sscanf . as possible solution can attempt substring of each part of input string, , number-part convert int . to find out length of first substring (which should put cmd ) , starting position of number, need iterate on characters of string until find non-alphabetic character.

dart - Drawer Avoid Infinite Activity Creation -

i use drawer each activity: final mydrawer _drawer = new mydrawer(); class mydrawer extends statefulwidget { @override _mydrawerstate createstate() => new _mydrawerstate(); } class _mydrawerstate extends state<mydrawer> { @override widget build(buildcontext context) { return new drawer( child: new listview( children: <widget> [ new drawerheader( child: new text("header"), ), new listtile( leading: new icon(icons.home), title: new text("home"), ontap: () { navigator.popandpushnamed(context, "/"); }, ), new listtile( leading: new icon(icons.android), title: new text("another page"), ontap: () { navigator.popandpushnamed(context, anotherpage.routename); }, ),new...

product - Prestashop Display both prices with and without tax -

i found how display both price , without tax on product list. when there specific price, old price same , without tax. displays old price tax incl price tax exc. example : 549,0 € ht (733.20€) - 659.88 € ttc (733.20€) {if (!$ps_catalog_mode , ((isset($product.show_price) && $product.show_price) || (isset($product.available_for_order) && $product.available_for_order)))} <div class="content_price"> <p style="font-size: 20px;"> {l s='from'}</p> {if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)} {hook h="displayproductpriceblock" product=$product type='before_price'} <div id="prix_ht"> <span class="price product-price"> {if !$pricedisplay}{convertprice price=$product.pri...

java - Best practice of designing JPARepository(ies) for ORM Domain graph -

i have been designing spring rest apis using standard mvc architecture domain layer pojos , repositories fetch domain data db tables. far these entities isolated design acted separate restcontroller, service, , repository flow each entity. have been looking understand best practice when comes association in domain objects i.e., orm. example, lets take following pseudocode illustrate domain classes (only purpose express design in question. have not provided complete classes): public class customer { @column private int id; @column; private string name; @onetomany private list<order> orders; //...getters setters } public class order { @column private int id; @column; private string ordernumber; @onetomany private list<product> products; @manytoone private customer customer; //...getters setters } public class product { @column private int id; @column; private string productname;...

Spark SQL : Handling schema evolution -

i want read 2 avro files of same data set schema evolution first avro file schema : {string, string, int} second avro file schema evolution : {string, string, long} (int field undergone evolution long) want read these 2 avro file store in dataframe using sparksql. to read avro files using 'spark-avro' of databicks https://github.com/databricks/spark-avro how efficiently. spark version : 2.0.1 scala. 2.11.8 ps. here in example have mentioned 2 files in actual scenario file generated daily there more 1000 such file. thank in advance:) use union like {string,string, [int, long]} is valid solution your? should allow read both new , old files.

javascript - JS file upload validation, but instant in windows window -

i have form , did validation in js, form not send when user sends sth different .doc/.docx. (cv uploading). want faster. error instantly when file selected, not when button submitted. (in windows window). how it? it's standard form: <div class="form-group"> <label>your cv</label> <input required type="file" accept="application/msword" class="form-control" name="cv" id="cv" aria-describedby="name" placeholder="select cv file"/> </div> i've got answer. here's code (isdoc own function): function onchange(event) { var file = $('#file_cv')[0].files[0]; if ( !isdoc(file.name) ) { alert("please, choose .doc or .docx type."); document.getelementbyid("file_cv").value=...

c# - GetPostBackClientHyperlink stops when navigating a second grid on the page -

i have 2 grids on page. on pageload both grids have data expected the first grid has event on rowdatabound protected void onrowdatabound(object sender, system.web.ui.webcontrols.gridviewroweventargs e) { if (e.row.rowtype == datacontrolrowtype.datarow) { e.row.attributes["onclick"] = page.clientscript.getpostbackclienthyperlink(gridview1, "select$" + e.row.rowindex); e.row.tooltip = "click select row."; } } the first grid's row click works expected. when start navigating through second grid using 'next' button, rowclick on first grid stops working. next button click on second grid below protected void lbtnnext_click(object sender, eventargs e) { try { int pageindex = (int)viewstate["current"] + 1; if (pageindex < grdimages.pagecount) { grdimages.pageindex = pageindex; bindsecondgrid(); ...

c# - Executing a PowerShell script and leaving it running -

i have powershell script that, once executed listens on port. want execute script , leave running while c# program continues run. here have right when gets line waits until script finished (which never does). process proc = process.start("powershell.exe", @"/k tcdrvrcunit.exe automation.txt"); proc.waitforexit(); console.writeline(proc.processname);

Expectation failure not triggered if file ends with Boost Spirit Qi parser -

when file ends in middle of rule remaining expectations, doesn't trigger expectation error (it does, of course, fail parse). a simplified example triggers behavior this: data_var_decls_r %= (lit("data") > lit('{')) > lit('}'); if input data { then expectation error final expected } isn't triggered. is there way deal expectation errors extend past end of file? making self-contained example: see live on wandbox #include <boost/spirit/include/qi.hpp> namespace test { using namespace boost::spirit::qi; rule<std::string::const_iterator> rule = lit("data") > '{' > '}'; } int main() { std::string const input("data{"); bool ok = parse(input.begin(), input.end(), test::rule); } does throw expectation failure. even when using space skipper, still throws: see live on wandbox too #include <boost/spirit/include/qi.hpp> namespace t...

html - R Shiny Image without padding/ stretched across page using css -

Image
i'm building shiny dashboard , want image stretch across top of dashboard body no padding. i'm new customizing apps , css, , i'd prefer keep css inline if possible. this have right now: i'd extend image indicated blue arrows/ red outline below. here's code have far: library('shiny') library('shinyjs') library('shinydashboard') ########## header<-dashboardheader(titlewidth = 325) header$children[[2]]$children <- #tags$a(tags$img(src='image.png',height='45',width='184')) ###### body<-dashboardbody( tags$style(".content {background-color: black;}"), useshinyjs(), tags$style(type='text/css', ".skin-blue .main-header .logo {background-color: #000000}" ), tags$style(type='text/css', ".skin-blue .main-header .logo:hover {background-color: #000000}"), tags$style(type='text/css...

html - Simple dropdown menu -

Image
i'm trying make simple dropdown menu sub items of meme don't stay in block. if remove float left of header li , menu of memes appears under home . html: <header> <div class="container"> <div id="brand"> <h1><span class="highlight">my</span> website</h1> </div> <nav> <ul> <li class="current"><a href="home.html">home</a></li> <li><a href="cv.html">curriculum vitae</a></li> <li><a href="pc.html">pc gaming</a></li> <li><a href="#">memes</a> <ul> <li><a href="#">hot</a></li> <li><a href="#">trending...

android - Attempt to invoke virtual method 'int.java.lang.Integer.intValue()' on a null object reference at Cast.writetoParcel -

Image
this question has answer here: what nullpointerexception, , how fix it? 12 answers getting error fatal exception: main process: com.example.wuntu.tv_bucket, pid: 3895 java.lang.nullpointerexception: attempt invoke virtual method 'int java.lang.integer.intvalue()' on null object reference @ com.example.wuntu.tv_bucket.models.cast.writetoparcel(cast.java:136) @ android.os.parcel.writeparcelable(parcel.java:1437) @ android.os.parcel.writevalue(parcel.java:1343) ...

swift - Using `flatMap().filter().map()` together on a multidimensional array -

Image
i use following method find identifier isbooltrue==true nested array (screenshot of array , data structure below) func extractidentifiers(mainarray: [mainitem]) -> [int]? { var selected = [int]() mainarray.foreach { element in let integers = element.innerarray?.filter({ $0.isbooltrue }).map { int($0.identifier)! } if !(integers?.isempty ?? true) { selected += integers! } } return selected.isempty ? nil : selected } question: possible use sort of chaining flatmap().filter().map() produce same result [int]? , able eliminate use of mainarray.foreach , conditional checks selected.isempty , integers?.isempty ? note: need within above method extractidentifiers , below find data , structure play around, screenshot of array. thanks in advance! structure & data: struct inneritem { let identifier: string var isbooltrue: bool } struct mainitem { var innerarray: [inneritem]? } let s...

Tensorflow, how to preserve the intermediate node value and reuse them -

assuming have following graph. - x3 , z values care about. - x , y inputs. in each different. iteration, coming values , shapes of x , y different, think placeholder - circumstance need run graph twice in different time point x3 , z asynchronously. +---+ op: +1 op: *3 | x +------------> x_1 +-----------> x3 +---+ +---+ + + | y | | | +-+-+ | op:add | | | | | | | | op: add v op:add | +-------------> <------------+ z at time point , input x (say x=7 , don't know what's y @ moment). want see value of x3 . execute sess.run([x3], {x:7}) , returns 24 expected. at later time point , input y (say y=8 ), , t...

c# - How to get started with Tesseract/tessnet2 OCR -

i need make program ocr, , have tried make project using tessnet2 every time try run project, console closes right away no error. i confused on version of tesseract uses version of trained data available, don't understand supposed install tesseract/tessnet2, , don't understand how train tesseract own data. does have tutorial, question, or documentation?

python 2.7 - cannot find easy_install after updating setuptools -

on aws machine, updated pip version 9.0.1 with sudo -h pip install --upgrade pip and updated setuptools 12.2 36.2.2 doing : pip install -u setuptools but can't use easy_install anymore, says -bash: /usr/bin/easy_install: no such file or directory i saw there easy_install-3.4 in /usr/bin, how can retrieve easy_install? my problem wanted create .egg file , apparently old version of setuptools not created correctly when installing via easy_install couldn't import package in python ('no module named xxx'). i using python 2.7 thanks

html - Ungrammatical validation message for firefox -

firefox default messaging/validation message grammatically incorrect. using minlength html5 attribute firefox displaying following words. "please use @ least 3 characters (you using 1 characters)." should "1 character" there fix this? html below <input type="text" minlength="3" /> this bug in firefox's implementation. there's no extremely simple way correct i'm aware of. you can use setcustomvalidity call function check length of field , return appropriate validation error, using correct grammar.

reactjs - How can i replace screen with React Navigation for React Native -

how can replace screen react navigation react native now i'm newbie can't understand getstateforaction have params on screen 1 , navigate screen 2 passing params username basic navigate it's nested screen 1 > 2 on stack but need replace screen 1 screen 2 after screen 2 it's on active (replace actionconst.replace on router flux) , sending params on new way can guide me thank you. screen 1 onpress = () => { this.props.navigation.navigate('sc2', {username: this.state.username}); } screen 2 componentwillmount() { const {state} = this.props.navigation; console.log(state.params.username); } --------------- router export const loginnavstack = stacknavigator({ sc1: { screen: sc1 }, sc2: { screen: sc2, }, });

Azure Functions Runtime - New install HTTP 401 -

after fresh install of azure functions runtime, appears there process requesting api key fails http 401. the specific call response returned is: {"message":"authorization has been denied request."} http 401 error anyone else seeing or expected behavior?

VBA to return first google result as a hyperlink in excel -

i've been trying use bit using vba in excel google search in ie , return hyperlink of first result in order return first google result hyperlink in excel have been running issues. when run macro error at: set xmlhttp = createobject("msxml2.serverxmlhttp") edit include error: run-time error '429': activex component can't create object i know if it's possible return first 3 links in case first 1 ad? any appreciated!

css - How do I add ion-avatar on top of ion-card? like the image below -

i new ionic. trying create ion card profile page this. basically, want ion-avatar on top of ion-card shown in image. how that? below code: #content { position: relative; // margin-top: auto; background-color: green; box-shadow: 0px -1px 10px rgba(0, 0, 0, 0.4); padding-top: 200px; } #profile-info { position: absolute; top: -95px; width: 100%; z-index: 2; text-align: center; } #profile-image { display: block; border-radius: 120px; border: 1px solid #fff; width: 128px; height: 128px; margin: 30px auto 0; box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.7); } <ion-content has-header="true"> <ion-card id="content"> <ion-avatar id="profile-info"> <img id="profile-image" src="img/bg.jpg"> </ion-avatar> </ion-card> </ion-content> you missing css parameters #content element: height: 150px; widt...

android - RecyclerView Displays only last objects in List -

i trying display data in recyclerview . have created adapter handle recyclerview s different activities. issue facing displaying data appropriately. far can display last elements in list. in case, last candidate each contestedoffice. have attached code both activity , adapter screenshot of output. my adapter class public class recycleradapter extends recyclerview.adapter<recyclerview.viewholder> { private static final string logcat = recycleradapter.class.getsimplename(); private static final int view_type_vote = 0; private static final int view_type_preview = 1; private list candidateslist; private linearlayout checkboxparent; private voteactivity voteactivity; private context context; public recycleradapter(list candidateslist) //generic list { this.candidateslist = candidateslist; } @override public int getitemviewtype(int position) { if (candidateslist.get(position) instanceof candidate) { ...

dictionary - (surprisingly) python dict "has_key" faster than "in" -

from popular information , searching on net+stackoverflow, seems "in" faster "has_key" key lookups in python dictionary. however, recent experience has been quite opposite , have no clue why so? consider code of following form: for f in f: if 'a' in f: alist.append(f) #if f in fdict.keys(): if fdict.has_key(f): idx_alist.append(fdict[f]) elif 'b' in f: blist.append(f) #if f in fdict.keys(): if fdict.has_key(f): idx_blist.append(fdict[f]) in above, switching "has_key" makes code 50000x times faster on small files. quite baffling -- know what's going on? it's f in fdict , not f in fdict.keys() . using keys builds list of keys , goes through 1 one, whereas using f in fdict uses efficient hash-based lookup.

java - Generating getters and setters using project Lombok -

i wanted use lombok dependency in project. so, downloaded lombok-1.16.18.jar , added build path of on of classes. configuration shown below. import lombok.data; import lombok.getter; import lombok.setter; import lombok.tostring; @tostring(includefieldnames=true) public @data class student { @getter @setter private integer id; @getter @setter private string name; //private date dob; @getter @setter private string uid; public static void main(string[] args) { // todo auto-generated method stub student s = new student(); system.out.println(s); } } but, not getting proper output in console. getting object classes tostring() output com.selflearn.sandesha.student@7852e922 . not able use getters , setters. how make lombok work or wrong doing? your configuration incomplete. review https://projectlombok.org/setup/eclipse , check if compiles. when does, try again!

for loop - MATLAB: parfor error -

i have following matlab code want run using parfor: max = -1; = 1:10 j = (i+1):10 x = my_function(i, j); if (x > max) max = x; end end end disp(max) i want change first parfor. read couple of tutorials , documentation, don't know how have same result max, using parfor. i know there problem usage of in for j = (i+1):10 . i appreciate suggestion. you can not use parfor dependent iterations , i.e. in case max dependent (shared) variable between loop iterations: you cannot use parfor-loop when iteration in loop depends on results of other iterations. each iteration must independent of others. this reflected in displayed warning message: warning: temporary variable max cleared @ beginning of each iteration of parfor loop. value assigned before loop lost. if max used before assigned in parfor loop, runtime error occur. see parallel loops in matlab, "temporary variables". matlab impl...

php - Laravel Stuck with returning a json request -> Integer Array -> receiving Eloquent Models -

i tried answer json request, returning laravel-models on delivered id's in request. this - json-request { "places": [1,2, 3, 4, 5] } first transform array: convert request array $array = $request->places; output: array:5 [ 0 => 1 1 => 2 2 => 3 3 => 4 4 => 5 ] and how receive models (1,2 manually entered id's in example: get places $posts = post::wherein('place_id',[1,2] )->get(); my problem, placeholder [1,2] allows list of integer. i'm not able transform array placeholder variable this. $posts = post::wherein('place_id',[$request] )->get(); if put array string variable, lets say: $request = "1,2,3,4,5" then, receive models first value (number 1 in case). is there way transform json-requests receive laravel models? any appreciated, cheers sebastian you should try this. $posts = post::wherein('place_id', $request->request->get('places', ...

Swift how to send symbols like "&(*(" with HTTP post -

i have got swift code var request = urlrequest(url: url(string: "http://www.centill.com/ajax/logreg.php")!) request.httpmethod = "post" let poststring = "app_log_pass=\(pass_text_field.text!)" request.httpbody = poststring.data(using: .utf8) and when text (1&*^&&2 prints (1 .how can send string contains various symbols safely swift? as sulthan suggested, no predefined characterset can used actual servers when want include symbol characters in post data. an example characterset use: extension characterset { static let rfc3986unreserved = characterset(charactersin: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789-._~") } let postvalue = "(1&*^&&2" let poststring = "app_log_pass=\(postvalue.addingpercentencoding(withallowedcharacters: .rfc3986unreserved)!)" print(poststring) //->app_log_pass=%281%26%2a%5e%26%262 another characterset ...

hadoop - logs not available, aggregation of logs may not happen -

after submission of jobs spark or tez, check logs application, there see logs not available container, aggregation of logs may not take place. what possible reasons, jobs getting logs jobs there no logs available? yarn.log-aggregation-enable set true

ionic framework - How can I build .ipa file from Ionic3 using Windows machine? -

i have few questions. very new ionic3 , hybrid application development. i have developed ionic3 angular4 hybrid application. using windows os 10 64 bit. have built .apk file , have done testing in android mobile. works expected. turn ios app. question# 1: how can build ios .ipa file? question# 2: suppose if have built .ipa file ( as per solution question#1 ), possible move .ipa file iphone , install have done android? question# 3: need developer code/key testing app in own iphone device without downloading app store? question# 4: things need deploying both .apk , .ipa file in respective stores? question# 1: how can build ios .ipa file (using windows machine)? answer# 1: no can't, you can . use ionic package . ionic packages makes easy build native binary of app in cloud. perfect developers using windows want build ios apps. question# 2: suppose if have built .ipa file (as per solution question#1), possible move .ipa file iphone , inst...

javascript - JSON.parse unexpected character with special characters in string? -

i having trouble using json.parse on characters. i'm receiving data via api, don't have means force form of encoding on server side, data provided me as-is. this json in question: {"name": "»»»»»»»"} i created jsfiddle json data , basic json.parse function returns "unexpected token in json @ position 11". (there special characters in there won't see in browser, jsfiddle show them) https://jsfiddle.net/4u1ltvlm/2/ how go fixing string prior doing json.parse on it, without losing special characters? edit: modified jsfiddle , json contain string causing trouble, it's less confusing everyone. json.parse needs string consists of unicode characters (see json parsing unicode characters ). for json.parse method fails, because string contains non-unicode characters. if paste string http://jsonparseronline.com/ see fails because of character, character browser displays if string not correctly encoded. so, if don't ...

api - Implement Facebook's Audience Manager on website -

Image
i have been looking way implement interactive manager on website: facebook audience manager this manager accessible when creating add on fb or when using audience-insights. i've been looking in documentation of fb marketing api, doesn't contain information on matter. specifies server-side applications. the goal of application create market researches based on different social media databases. think implementing manager possible because there apps adespresso let create , manage add campaigns. possible use same manager when creating add. i know if i'm trying possible , requirements needed. thanks in advance. in short, can it, not suggested it. (sorry can not post 2 more links account new, need break them, know how them) some facts you: facebook marketing api calls parts mentioned targeting audiences ( https://developers.facebook.com/docs/marketing-api/audiences-api ). , have shown in screenshot it called core audience targeting (developers.face...

windows 7 - VMware game full screen not taking up entire screen -

my vm opens in fullscreen fine when open game, opens in fullscreen doesn't take entire screen. https://m.imgur.com/gallery/gfy9i my current resolution 1366x768 i think can adjust games resolution in settings 1366x768 or nearest option that, take entire or entire of screen.

Chrome 60 "undefined symbol: gdk_screen_get_monitor_scale_factor" on Redhat 7 -

chrome 60 released today (july 25th). after upgrading chrome 59.0.3071 60.0.3112.78-1 , running chrome --version seeing error: # chrome --version chrome: symbol lookup error: chrome: undefined symbol: gdk_screen_get_monitor_scale_factor am missing new dependency? from can tell, symbol gdk_screen_get_monitor_scale_factor libgdk-3 yum install gtk3-devel which installs /lib64/libgdk-3.so

c# - What is a NullReferenceException, and how do I fix it? -

i have code , when executes, throws nullreferenceexception , saying: object reference not set instance of object. what mean, , can fix error? what cause? bottom line you trying use null (or nothing in vb.net). means either set null , or never set @ all. like else, null gets passed around. if null in method "a", method "b" passed null to method "a". the rest of article goes more detail , shows mistakes many programmers make can lead nullreferenceexception . more specifically the runtime throwing nullreferenceexception always means same thing: trying use reference, , reference not initialized (or once initialized, no longer initialized). this means reference null , , cannot access members (such methods) through null reference. simplest case: string foo = null; foo.toupper(); this throw nullreferenceexception @ second line because can't call instance method toupper() on string reference pointing null ....