Posts

Showing posts from June, 2014

javascript - Using Angular formatters / parsers -

can't seem angular formatters , parsers working: app.js: var itemapp = angular.module('itemapp', []); itemapp.controller('itemcontroller', ['$scope', function($scope) { $scope.some_value = 'abcefg'; }]); itemapp.directive('changecase', function () { return { restrict: 'a', require: 'ngmodel', link: function (scope, element, attrs, ngmodel) { ngmodel.$formatters.push(function(value){ return value.touppercase(); }); ngmodel.$parsers.push(function(value){ return value.tolowercase(); }); } }; }); view.html: <input ng-model="some_value" changecase> it doesn't work- no errors, nothing happens values in input or model. i'm newish angular, having trouble figuring out how i'd debug this. try write: <input ng-model="some_value" change

creating shapefiles in R from large dataframes -

i use shapefiles() library in r create shapefile dataframe. the dataframe contains 300,000 rows. ddtable contains 1 attribute. shapefile has esri shape type 1 (points). neither dd nor ddtable contain missing values. i have run convert.to.shapefile() create shapefile, process still not complete after 5 hours. when @ task manager, 3.51 gb of memory in use (out of 8 gb), , of time, 37% of cpu used. i use windows7enterprise , r 3.1.0. i have used shapefiles() create shapefiles of road network on 140,000 links, , creation of shapefile never took more 5 minutes. does have idea of may going wrong?

c# - Programmatically creating Hangfire cron expression based on user input -

i have c# .net web application ui looks similar http://www.cronmaker.com/ . user can select frequency of job many options. need able create cron expression represent user's desired frequency, , must compatible hangfire. ideas either: find existing library it. haven't been able to. heard quartz (though overkill), seemed create cron expressions cases not others. make own tool, using cronmaker.com figure out format. however, cronmaker creates cron expressions in format hangfire considers invalid. "every hour," cronmaker says "0 0 0/1 1/1 * ? *" hangfire said invalid. found "0 */1 * * *" works. i need able dynamically generate cron expression. surely there's library out there can cronlibrary.getcronexpression(frequency.everyndays, 3, "12:00") options cover every conceivable situation. know of such library ? i didn't find library, site http://crontab.guru/ tremendously helpful creating cron expressions valid hangfi

javascript - Apache HTTPClient sends no client cert during mutual authentication -

i'm getting handshake_failed exception when making restful post call api requires mutual authentication. have verified engineer on other side watching stack trace server-side certs exchanged , accepted client without issue, when server requests client-side cert side doesn't provide , handshake terminates. the thing have no idea how verify whether sslsocketfactory unable identify right certificate or isn't looking in first place. here code, js leveraging apache httpclient library. importpackage(packages.org.apache.http.client); importpackage(packages.org.apache.http.client.methods); importpackage(packages.org.apache.http.impl.client); importpackage(packages.org.apache.http.message); importpackage(packages.org.apache.http.client.entity); importpackage(packages.org.apache.http.util); importpackage(packages.org.apache.commons.httpclient); importpackage(packages.org.apache.http.params); importpackage(packages.org.apache.http.ssl); importpackage(packages.org.apache.http

vim - Show line numbers only on command mode -

i ever use line numbers when want switch line on screen, use command mode (e.g. :82) is there way show line numbers when switch command mode? yes. can use map that. : nnoremap : :set nu<cr>: this set line numbers when enter command line mode. the following command not show line numbers when leave command-line mode. :nnoremap <cr> :set nonu<cr> but needs 2 enters pressed. ** andrew suggests, following command des same , avoids typing enter twice.** :cnoremap <silent> <cr> <cr>:set nonu<cr> put these 2 lines in ~/.vimrc file.

Appending to a Path Java us -

is there easy way append path created this: final path path = files.createtempdirectory(...); suppose creates temp dir in /tmp/xyx_123/. want path create folder under /tmp/xyz_123/ called foo path.createdirectory("foo"); or path.appenddirectory("foo"); is there easy way this? you can this: path path = files.createtempdirectory("xyx_123"); file fpath = path.tofile(); file addeddir = new file(fpath, "foo"); addeddir.mkdir();

How should I handle concurrency in mongodb? -

i working on web service writing data records mongodb. service reads document mongodb, performs calculations , updates data in document , overwrites document mongodb. need make sure before write data mongodb, no other process has updated document, otherwise may experience data loss when replacing document. how can ensure data integrity @ application level? can lock document while performing calculations? should check version number on document before replacing document? strategies industry uses handle situations this? in advance you can query value in document updated part of call update() check document still in state expect, , confirm no-one else updated since last read document. similar optimistic lock approach. see https://docs.mongodb.com/manual/core/write-operations-atomicity/#concurrency-control

proxy - nginx proxying and custom business logic -

i need proxy user request user domain -> external domain b. also need introduce custom business logic while proxying b. one of task custom business logic - need process html on fly , replace in html links domain b a. also, need proxy http cookies , need implement content targeting based on different conditions. is possible nginx ? so, languages can used custom business logic writing ? i'm java developer i'm interested in language looking efficient way. if no, please suggest more suitable alternatives task.

c++ - Variadic templates argument fowarding -

say have function foo() takes advantage of c++ variadic templates feature. now, what's difference between these implementations: template <typename... args> void foo(args... args) { whatever(args...); } template<typename... args> void foo(args&... args) { whatever(args...); } template<typename... args> void foo(args... args) { whatever(&args...); } template<typename... args> void foo(args&&... args) { whatever(std::forward<args>(args)...); } template <typename... args> void foo(args... args) { whatever(args...); } foo gets copies of args , passes them whatever l-values. template<typename... args> void foo(args&... args) { whatever(args...); } foo gets l-value references args , passes them whatever l-values. template<typename... args> void foo(args... args) { whatever(&args...); } foo gets copies of args , passes them whatever pointers l-values. careful of ob

c# - have stackpanel clickable and load viewport -

first post here if wrong please slap me. i'm trying learn uwp code , want try create bottom naivation bar. i'm trying work stackpanels so the idea when stackpanel clicked / tapped should load new page viewport, can't figure out correct code so. here's short version of stackpanel: <stackpanel orientation="horizontal" verticalalignment="bottom"> <stackpanel name="firstbutton" tapped="firstbutton_tapped"> <textblock x:name="icon1" /> <textblock x:name="text1" /> </stackpanel> <stackpanel name="secondbutton" tapped="secondbutton_tapped"> <textblock x:name="icon2" /> <textblock x:name="text2" /> </stackpanel> <stackpanel name="thirdbutton" tapped="thirdbutton_tapped"> <textblock x:name

c - Bit level operation -

i have been following tutorial on bit level operation. code working on follows: int main(void){ puts("bit-level calculations:"); puts("----------------------"); unsigned int x = 10; unsigned int y = 1; unsigned int result; result = x&y; printf("x & y = %d\n", result); result = x|y; printf("x | y = %d\n", result); result = x^y; printf("x ^ y = %d\n", result); } the result follows: x & y = 0 x | y = 11 x ^ y = 11 however problem first answer. understood 1 & 0 = 0, 1& 1 = 1, expecting should have received answer of @ least 10 & 1 = 10. because first bit 1 x , first digit 1 y. , second bit x 0 , y bit 0 result should 0. question why did 0 or , xor received 2 bits result. thank much. understand there few questions posted regarding bit level operation, answer not clarify question. remember, these binary operators. you've g

Tensorflow Language Model tutorial dropout twice? -

i'm working on language model tutorial of tensorflow. question is: in this line , use wrapper apply dropout rnns lstm_cell = tf.nn.rnn_cell.basiclstmcell(size, forget_bias=0.0) if is_training , config.keep_prob < 1: lstm_cell = tf.nn.rnn_cell.dropoutwrapper( lstm_cell, output_keep_prob=config.keep_prob) why have apply dropout again inputs in this line ? if is_training , config.keep_prob < 1: inputs = tf.nn.dropout(inputs, config.keep_prob) thanks! edit: ok didn't understand paper @ time wrote question. zambera suggested apply dropout everywhere except hidden hidden. however, layer's output next layer's input, apply dropout every layer's output, , input of first layer.

angularjs - req.user data not displayed in the view -

i have express server passport-local stategy, passport-local , passport-local-mongoose installed.i want access current user model json read , write data it. headache object doesn't want display data inside view. it's loading no errors , cannot understand what's happening. please me! here express config: var express = require('express'), app = express(), morgan = require('morgan'), bodyparser = require('body-parser'), cookieparser = require('cookie-parser'), expresssession = require('express-session'), hash = require('bcrypt-nodejs'), mongoose = require('mongoose'), path = require('path'), passport = require('passport'), localstrategy = require('passport-local').strategy, port = process.env.port || 8080, user = require('./app/models/user'), routes = require('./app/routes/api'); mongoose.connect('mongodb://localhost:27017/dashboard'); app.use(express.static(__dirna

C - Getting Single Int from Text File -

i have text file looks this: 4 3 samantha octavia ivan henry 100 90 65 70 99 50 70 88 88 90 98 100 i wanting read first 2 lines individually , print them out, stands giving me huge number. inputfile = fopen ("input.txt", "r"); //input if( inputfile == null) { printf ("unable open file input.txt"); exit(exit_failure); } else { printf ("how many students?\n "); fscanf (inputfile, "%d", &students); printf ("%d", &students); printf ("\nhow many assignments?\n "); fscanf (inputfile, "%d", &assignments); printf ("%d", &assignments); printf ("\n"); } what missing here? simple error! printing value of &students or &assignments not correct. print value of pointer variable. need following code: printf ("how many students?\n "); fsc

ios - Firebase Retrieving Data in Swift -

Image
i'm trying retrieve specific data logged in user. data in database looks this: for example, want grab full_name , save in variable username. below i'm using grab data ref.queryorderedbychild("full_name").queryequaltovalue("useridentifier").observesingleeventoftype(.childadded, withblock: { snapshot in print(snapshot.value) // let username = snapshot.value["full_name"] as! string }) unfortunately, console prints. i appreciate :) thank you! it gives warning message indexon because doing query. you should define keys indexing on via .indexon rule in security , firebase rules. while allowed create these queries ad-hoc on client, see improved performance when using .indexon as know name looking can directly go node, without query. let ref:firdatabasereference! // ref ie. root.child("users").child("stephenwarren001@yahoo.com") // need fetch once use sin

javascript - Django how to properly submit form and handle request? -

i'm new django/python , working on webapp queries db of cars based on selects/dropdowns on home page , sends user details page car selected. done through 'make', 'model', , 'trim' dropdown box. i'm having trouble understanding , getting errors doing, submitting trim id upon clicking button submit form. know needs happen don't know how using django views , templates. the make box populated via returned queryset indexview. model box populated via jquery/ajax dependent upon make selected in make box. trim box same way, populated dependent upon selected in model box. need able submit form (which needs submit trim id because trim specified car) in order show details car user has chosen. this error getting: reverse 'search' arguments '('',)' , keyword arguments '{}' not found. 1 pattern(s) tried: ['search/(?p<trim>\\d+)/$'] this homepage template looks like: <form action="{% url &

c# - I have the error "No overload for method 'getValidString' takes for arguments". What does this mean and how do i fix it? -

this college course , deadline in 2 days , still have finish program test code , evaluate before then. below routine code. public static string getvalidstring(string prompt, int maxlength) { bool valid = false; //the paramter valid set boolean , set false. //it set boolean because small data type , //only needs have true or false string tempdata = ""; // while loop repetition , carries on doing until condition becomes true { console.write(prompt + " ?"); tempdata = console.readline(); if (tempdata == "") displaymessage("you have not entered data, please try again"); else if (tempdata.length < 3) displaymessage("you have not entered text longer 3, please try again"); else if (tempdata.any(c => char.isdigit(c))) displaymessage("you have not entered text, please try again"); else if (tempdata.length >

what is redirect_uri not supported error in facebook oauth -

can out of band authentication (oob) facebook specify redirect_uri urn:ietf:wg:oauth:2.0:oob ? google mentions 1 of options: https://developers.google.com/identity/protocols/oauth2installedapp#formingtheurl i trying facebook , using r studio (for running script on remote server). i error: the redirect_uri url not supported when point url: https://www.facebook.com/dialog/oauth?client_id=1256802200999873&scope=ads_management&redirect_uri=urn%3aietf%3awg%3aoauth%3a2.0%3aoob&response_type=code to authentication code. how fix this? note: using package httr , here'w 2 authentication code looks like: app <- oauth_app('facebook', 'id', 'secret') sys.setenv("httr_server_port" = "1410/") tkn <- oauth2.0_token( oauth_endpoints('facebook'), app, scope = 'ads_management', type = 'application/x-www-form-urlencoded', use_oob = true, cache = false)

sql - How to store array values into php variable -

$a="select a.name, sum(b.netamount) total b inner join on b.transtypeid = a.transtypeid group name "; $total = mysql_query($a); while($row = mysql_fetch_assoc($total)){ } how can store values different php variables? i assume want extract key values separate variables in local namespace, say, turn this array( name1 => val1, name2 => val2 ) into this $name1 = val1; $name2 = val2; you can extract function. here's example: $arr = array( "name1" => 1, "name2" => 2 ); extract($arr); echo $name1; echo "\n"; echo $name2; // output: // 1 // 2 be warned automatically extracting variables namespace can lead elusive bugs if codebase gets complex down line.

regex - Filter Arabic Words Using PowerShell -

we have accounts in active directory arabic display name , want change english, don't know how these accounts first using powershell. use quest activeroles query active directory get-qaduser -sizelimit 0 -searchroot "ou location" | ? {$_.displayname -contains "the arabic letter filter"} thanks you test regular expression find arabic letters in names. following yield true because of arabic letter ( ـأ ) in middle of word: "blaـأ‎bla" -match "\p{isarabic}"

stlmap - C++ map not inserting properly -

i trying populate map following structs: struct counterparty { uint8_t firm_id; char trader_tag[3]; uint32_t qty; }; struct orderfillmessage { header header; uint32_t order_id; uint64_t fill_price; uint32_t fill_qty; uint8_t no_of_contras; std::vector<counterparty> counterpartygroup; char termination_string[8]; }; void tradedecoder::findmostactivetrader() { map<char*,int> traders_volume_map; for(orderfillmessage m: orderfillmessages) { for(counterparty cp: m.counterpartygroup) { outputfile<<cp.trader_tag<<" "<<cp.qty<<endl; traders_volume_map[cp.trader_tag]+=cp.qty; } } outputfiletrader<<"printing map "<<traders_volume_map.size()<<"\n"; for(auto it=traders_volume_map.begin(); it!=traders_volume_map.end(); it++) { outputfiletrader<<(it)->first<<(it)->second

How to Redirect URL With PHP Without Showing in Headers -

currently want redirect user 1 page php file. using below method <?php $location = 'http://example/login.php?login=demo@gmail.com&password=2cwt58u4'; ?> but shows url in http headers. don't want show login redirect url in http headers make secure. way redirect in php without showing urls in header files. thanks. edit- for example if open http://example.com/login.php?login=demo@gmail.com&password=2cwt58u4 redirects http://example.com/ , user logged in. but example.com not mine. want add url in php redirect multiple people same id without giving them userid , password.

iphone - I'm Trying to figure out the timing of the iOS Keyboard -

so here situation of timing. have uilabel want update every time keyboard updates uitextfield. have 2 uitextfields 1 ever first responder don't worry there being 2 have them end purposes. problem timing uilabel updating , uitextfield delegate function - (bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange:(nsrange)range replacementstring:(nsstring *)string;˚ the replacement string doesn't added until yes returned above function. need update labels either after function called or during function. can't seem figure out how work. uilabel 1 character behind. below code in general section. - (bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange:(nsrange)range replacementstring:(nsstring *)string { if([self.hiddentextfieldfortimeminutes.text length] == 2 && [self.hiddentextfieldfortime.text length] == 2 && ![string isequaltostring:@""]) { return no; } [self synctextfieldsminutesandhour

scikit image - How do I mention the direction of neighbours to calculate the glcm in skimage/Python? -

i'd trouble understanding angle parameter of greycomatrix in skimage. in example mentioned in documentation compute glcm's pixel right , up, mention 4 angles. , 4 glcm's. >>> image = np.array([[0, 0, 1, 1], ... [0, 0, 1, 1], ... [0, 2, 2, 2], ... [2, 2, 3, 3]], dtype=np.uint8) >>> result = greycomatrix(image, [1], [0, np.pi/4, np.pi/2, 3*np.pi/4], levels=4) what should parameters pixel right , down? there's typo in example included in documentation of greycomatrix (emphasis mine): examples compute 2 glcms : 1 1-pixel offset right, , 1 1-pixel offset upwards. >>> image = np.array([[0, 0, 1, 1], ... [0, 0, 1, 1], ... [0, 2, 2, 2], ... [2, 2, 3, 3]], dtype=np.uint8) >>> result = greycomatrix(image, [1], [0, np.pi/4, np.pi/2, 3*np.pi/4], ... levels=4) indeed, result co

c# - Asp set role ModelState.IsValid is false -

hi there) i'm newbie in asp , i'm realizing role based security in project, using applicationusers class. created page, admin can set roles users, can't set role user, because in edit post method modelstate.isvalid value false, because can't convert string id value role. tried set value modelstate, can't because hasn't setter. help, please, how can fix way? code below... public actionresult edit(string id) { if (id == null) { return new httpstatuscoderesult(httpstatuscode.badrequest); } applicationuser applicationuser = db.users.find(id); if (applicationuser == null) { return httpnotfound(); } var roles = db.roles.select(x => new selectlistitem { text = x.name, value = x.id }).toarray(); viewbag.roles = roles; return view(applicationuser); } // post: applicationusers/edit/5 // Чтобы защититься от атак чрезмерной передачи данных, в

javascript - coffeescript class - calling calling one class method from an other -

i have rewritten embedded js in rails app coffeescript..and new coffeescript... my approach mix of these articles: approach one approach two my code: s = undefined class app.photolike settings: modalelement: $('#mymodal') likebuttonid: '#like' photo_id: $('.image_info').attr('photo_id') numberoflikes: $('#likes_num') constructor: (@el) -> console.log('constructor called') s = @settings @binduiactions() return binduiactions: -> console.log('binduiactions called') $('#mymodal').on 'click', '#like', -> likephoto() $(document).on "page:change", -> pagechange() pagechange: -> console.log('pagechange called') photo = new app.photo likephoto: -> console.log('likephoto called') url = '/photos/' + s.photo_id + '/like' $.get url, (data) -> s.numberoflikes

sockets - How to set "don't fragment" flag bit for TCP packet in Go? -

i intend set "don't fragment" flag bit in go, same thing this post while in c. checked constant list didn't find option. corresponding option in go? thanks in advance! how set "don't fragment" flag bit tcp packet in go? first should know tcp doesn't ip fragments. if not major implementations avoid fragmentation tcp segments using path mtu discovery. the tl;dr typical ip packet containing tcp segment has df bit set. can (and should) try out. here sniffing few seconds of traffic between machine , stackoverflow.com: % tshark -w /tmp/tcp.pcap tcp , host stackoverflow.com <wait few seconds> % tshark -r /tmp/tcp.pcap -t fields -e ip.flags | sort | uniq -c 186 0x00000002 0x02 means df bit set. confess in other captures have seen occasional tcp segment in ip packet without df bit; suspect rfc1191 has explanation this. now question, think there's no portable way set df bit , more widespread question (there isn&

python - TypeError: 'NoneType' object is not iterable. Why do I get this error? -

the function compute_root uses newton's method of successive approximation find enough approximations of zeroes of polynomials (herein lies problem). function evalpoly computes value of polynomial @ particular x value, , function ddx2 computes derivative of polynomial. poly2 = (2,3,1,5) #poly2 represents polynomial 5x^3+x^2+3x+1 def evalpoly(poly,x): degree = 0 ans = 0 index in poly: ans += (index * (x**degree)) degree += 1 return ans def ddx2(tpl): lst = list(tpl) in range(len(lst)): lst[i] = lst[i]*i if != 0: lst[i-1] = lst[i] del lst[-1] tpl = tuple(lst) def compute_root(poly,x_0): epsilon = .001 numguesses = 1 if abs(evalpoly(poly,x_0)) <= epsilon: ans = (evalpoly(poly,x_0),numguesses) print ans return ans else: x_1 = x_0 - (evalpoly(poly,x_0)/evalpoly(ddx2(poly),x_0)) # newton's method of getting progressively better /

java - Object's **hashCode** function - how does jdk uses it? -

i know whenever override equals method should override hashcode method . but im not sure is, how jdk uses it? for example hashset / hashmap set/map implementation using hash table, correct table use object's hash_code key hash_function? so correct table use object's hash_code key hash_function? almost. hashcode() hash function. hashmap whenever tries find key or put key, calls key hashcode() method , uses (with bit mask)to find proper element in hash table. also note it's not used directly jvm justby classes.

java - Error with code to make bufferedImage smaller -

i have image (147 kb), , want downsize under 100kb. code below attempts this, when image comes out on other side, widht , height scaled down, disk space on image goes 147 250! it's supposed smaller not higher... can please tell me why code isn't doing this? thanks //save image bufferedimage resizeimagepng = resizeimage(originalimage, type, newlargeimagelocation); //resize , save imageio.write(resizeimagepng, "png", new file(newsmallimagelocation)); //create new image private static bufferedimage resizeimage(bufferedimage originalimage, int type, string newlargelocation) throws exception{ //get size of image file file =new file(newlargelocation); //file size in kbs double bytes = file.length(); double kilobytes = bytes/1024; double smallwidth = originalimage.getwidth(); double smallheight = originalimage.getheight(); double downmult = 1

regex - RegExp to search words starts with numbers and special characters only using C# -

i want perform search c# list object find products starts number or special characters only. looking regular expressions scenario. please assuming list list of string: var newlist = yourlist.where(element => regex.ismatch(element, @"^[^a-z]", regexoption.ignorecase); it give sublist of elements doesn't start letter in range a-z .

Is there an equivalent of a Solr RequestHandler in Elasticsearch? -

i assessing if can move our solr based backend elasticsearch. however, can't seem work out if there equivalent capability of custom request handler configure in solr (as configured in solrconfig.xml) in elasticsearch. for context, in our solr configuration, have number of statically defined request handlers set of pre-configured facets, ranged facets, facet pivots. akin below, configured in solrconfig.xml: <requesthandler name="/foo" class="solr.searchhandler"> <lst name="defaults"> <str name="fl"> field1, field2 </fl> <str name="facet.field">bar</str> <str name='facet.range'>range_facet</str> <str name='f.range_facet.facet.range.start'>0</str> <str name='f.range_facet.facet.range.end'>10</str> <str name='f.range_facet.facet.range.gap'&g

How can I show an inform JDialog before System.exit() in Java Swing? (Closed) -

in simple login window, added action listener login button. on pressing button, program check information user entered, if enter wrong info 3 times program create new jdialog inform user, after program shut down. my problem jdialog appears blank program shutting down. here code btnlogin.addactionlistener(new actionlistener() { @override public void actionperformed(actionevent actionevent) { char[] pass = psspassword.getpassword(); string pss = new string(pass); if (!pss.tostring().equals("admin") || !txtusername.gettext().equals("adminuser")){ if (attempts == 2){ swingutilities.invokelater(new runnable() { @override public void run() { new inform("you entered wrong info 3 times, program shut down"); try { thread.sleep(1000);

ruby on rails - RailsAdmin doesn't correctly handles belongs_to -

Image
i playing railsadmin on rails 4. , have simple case (two models, event belongs idea). code: class idea < activerecord::base end class event < activerecord::base belongs_to :idea end schema create_table "events", force: true |t| t.string "location" t.integer "idea_id" t.datetime "created_at" t.datetime "updated_at" end add_index "events", ["idea_id"], name: "index_events_on_idea_id" create_table "ideas", force: true |t| t.string "title" t.text "descrption" t.datetime "created_at" t.datetime "updated_at" end and seeing this. , can't figure out why show both drop down choose idea , additional numeric editbox? . railsadmin heavily relies on relationships dynamically generate forms. aside that, have encountered other issues down line if didn't map relationships both m

c - What is the difference in these stack and heap memory addresses? -

i making example stack , heap allocation on ubuntu 14.04 vm (linux 3.13.0-55-generic i686) , confused memory addresses heap allocations. the below c code allocates 3 32-bit unsigned ints on stack , 3 allocation on heap of diminishing sizes, 32 bits, 16 bits , 8 bits. in output below can see memory addresses 3 32 bit ints on stack 4 bits apart. uint32_t @ 0xbffd4818 , 4 addresses later @ 0xbffd481c uint32_t j. can see here each individual byte of memory addressable , each 4 byte memory block 4 memory addresses apart. looking @ heap allocations though can see uint32_t i_ptr points 0x99ae008 , malloc requested 4 bytes of space, expect uint16_t j_ptr start @ 0x99ae00c starts @ 0x99ae018. third heap allocation uint8_t k_ptr starts 16 bytes after uint16_t i_ptr starts 16 bytes after uint32_t i_ptr. is default os setting each heap allocation 16 bytes apart? why happening irrelevant of size passed malloc? how can fit 4 bytes of information between 0x99ae008 , 0x99ae018? c sou

javascript - Javsacript object reference from jquery callback -

this question has answer here: how “this” keyword work? 19 answers say have code var someclass= function(id){ this.id = guidgenerator(); this.htmlelement = jquery("#"+id); this.initclickhandler(); }; someclass.prototype = { initclickhandler: function(){ this.htmlelement.on("click",function(e){ //need reference object here //in way allow //this.clickhandler(); }); }, clickhandler: function(){ alert(this.id); } }; someclassinstance1 = new someclass("a"); someclassinstance2 = new someclass("b"); how can relevant instance of "someclass" on "on "callback ? need reference object here in way allow this use variable keep reference this : someclass.prototype = { initclickha

ios - Big realm compacted file size -

i have realm file size 700mb. create compacted version using realm.writetocopyurl() , file same 700mb. it? in documentation never mentioned that method should compress file, encrypted version. if want compress realm, you'll have before encrypting it.

angular - Custom Styling on <ng-content> in angular2 not working ? -

i trying style <ng-content> using inline css seems style does't work on ng-content, have else styling ? <ng-content class="red"></ng-content> <p class="red">hello</p> here class red works on p not on working example ::content ignored. this comes closes you can use ::content selector styles: ['.red {color:red} :host >>> upper {color:green}'] or styles: ['.red {color:red} :host >>> * {color:green}'] and if there fellow less users, seems less compiler dislikes >>> syntax, need add alias that, eg. @deep: ~">>>"; , use @{deep} { /* deep styles here */ } see discussion https://github.com/angular/angular/issues/7400#issuecomment-246922468 can use ::content selector styles: ['.red {color:red} ::content >>> upper {color:green}'] or styles: ['.red {color:red} ::content >>> * {color:green}']

php - .htaccess file in azure app url rewriting -

i have single page application developed in php angular mysql. uses rest api class data mysql db. application works fine in shared hosting cpanel (linux). copied files in azure app service cannot work. following message: the page cannot displayed because internal server error has occurred. i understand running iis , iis not support .htaccess file rewriting url . the contents of .htaccess : <ifmodule mod_rewrite.c> rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-s rewriterule ^(.*)$ api.php?x=$1 [qsa,nc,l] rewritecond %{request_filename} -d rewriterule ^(.*)$ api.php [qsa,nc,l] rewritecond %{request_filename} -s rewriterule ^(.*)$ api.php [qsa,nc,l] </ifmodule> if have done study , changed .htaccess web.config still not work. my web.config : <?xml version="1.0" encoding="utf-8"?> <configuration> <configsections> <sectiongroup name="system.webserver">

sql server - java.lang.ClassNotFoundException: javax.net.ssl.SSLSocket not found by com.microsoft.sqlserver.jdbc.SQLServerDriver -

i've made multiple attempts try connect mssql jsp cannot around error produced when try initiate actual connection. jar has been wrapped osgi bundle of dependencies resolved on 1.8 jvm. interestingly enough, exact same jsp code run on mac platform not when deployed production windows 2012 server. caused by: java.lang.classnotfoundexception: javax.net.ssl.sslsocket not found com.microsoft.sqlserver.jdbc.sqlserverdriver [587] @ org.apache.felix.framework.bundlewiringimpl.findclassorresourcebydelegation(bundlewiringimpl.java:1574) @ org.apache.felix.framework.bundlewiringimpl.access$400(bundlewiringimpl.java:79) @ org.apache.felix.framework.bundlewiringimpl$bundleclassloader.loadclass(bundlewiringimpl.java:2018) @ java.lang.classloader.loadclass(classloader.java:357) ... 160 more normally javax.net.ssl.sslsocket loaded rt.jar in boot classpath. jsp container using, , how have configured boot classpath it? mentioned have working on osx: configurat

unit testing - Node.js stubbing request.get() to call callback immediately -

i'm trying test function calls request.get() function inside it. i'm trying cover branches of callback function. i'm trying achieve without separating callback function different function because it's uses variables of upper closure. here's example illustrate.. foo.js: var request = require('request'); function func(arg1, arg2) { request.get({...}, function(error, response, body) { // stuff arg1 , arg2 // want covered if (...) { // want covered ... // want covered } else if (...) { // want covered ... // want covered } else { ... // want covered } }); } exports.func = func; i tried stub sinon proxyquire. foo.spec.js (stubbed sinon): var foo = require('./foo'), var sinon = require('sinon'), var request = require('request'); var requeststub = sinon.stub(request, 'get', function(options, callback) { callback(new error('custom error&

java - Can we catch an exception without catch block? -

suppose have try - finally block without catch block, throw exception inside try block. able catch exception? public static void main(string[] args) throws ioexception{ try { throw new ioexception("something went wrong"); } finally{ } } yes, possible. you can use uncaught exception handler. responsibility catch exceptions program didn't catch, , it. public static void main(string[] args) throws ioexception { thread.setdefaultuncaughtexceptionhandler((thread, thr) -> thr.printstacktrace()); throw new ioexception("something went wrong"); } setdefaultuncaughtexceptionhandler method register handler invoked when exception has been thrown in thread , wasn't caught. above code print stacktrace of throwable handled. the handler takes argument thread exception happened , throwable thrown. you can have handler per thread using setuncaughtexceptionhandler on thread instance. handler handle uncaught exceptio

arrays - Can someone show me how to modify a txt file in c++ ? ( i`m working in codeblocks) -

so have txt file this: 3/1995 13,25,16,14 4/1995 36,1,24,48 5/1996 39,46,35,2 233/1996 14,16,25,12 and want modify this, in txt file: 13,25,16,14 36,1,24,48 39,46,35,2 14,16,25,12 i want transform them char int , put them in 2d vector. tried far: #include<iostream> #include<fstream> #include<cstring> using namespace std; static const int width = 10; static const int height = 50; int main() { char level[height][width]; ifstream file; file.open("new.txt"); for(int = 0; < height; i++) { for(int j = 0; j < width; j++) { file>>level[i][j]; cout<<level[i][j]; }cout<<endl; } return 0; } and doesn`t read blank space messes everything. in order gather characters including white spaces, advise use "get" instead of << operator. edit : or getline suggested in order apply change descr

javascript - promise and getting response object as null using .then -

i'm getting json data trough web service myservice.getdata() .then(function(data, status, headers, config){ alert(data.length); }... even though i'm able data , examine trough browser console inside code in then block i'm getting data undefined. what i'm doing wrong here? update: service call looks this return $http.post("http:/...", { headers: {'authorization': 'basic qwxhzgrpbjpvcgvuihnlc2ftzq==' } }).success(function(data, status, headers, config){ return data; }).error(function(data, status, headers, config){ alert('err'); }); the data passing resolve object , not array. objects not have length property, calling length on object give undefined unless have assigned length property on it. var arraylike = ['a', 'b'] console.log(arraylike.length) //outputs: 2 var obje

validation - Class 'App\' not found on laravel 5.2 -

i want add data database after successful validation,but error.' fatalthrowableerror in aboutcontroller.php line 51: class 'app\about' not found. my controller <?php namespace app\http\controllers; use app\about; use illuminate\http\request; use app\http\requests; class aboutcontroller extends controller { public function store(request $request) { // $about = $request->about; $validation = \validator::make($about, about::$rules); if($validation->passes()) { about::create($about); return route('about/admin')->compact(about); } } my model <?php namespace app\http\controllers; use illuminate\database\eloquent\model; class extends model { // protected $guarded = array('id'); protected $fillable = array('about'); public static $rules = array('about' => 'required|5'); }

css - Slide in another div, from right to left, and adjust the height animated (jQuery) -

Image
i have div login form , button "forgot password". have div forgot password form, want slide in, in front of login div , adjustig height, when "forgot button" clicked. entire box should positioned illustration: the html: <div id="content"> <div id="box"> <div id="log_in"> <p>log in form</p> <p>log in form</p> <p>log in form</p> <p>log in form</p> <p>log in form</p> <div id="forgot">forgot password?</div> </div> <div id="forgot_form"> <p>forgot form</p> <p>forgot form</p> <p>forgot form</p> </div> </div> </div> css: #content{ background-color: blue; width:100%; height:900px; } #box{ width: 200px;