Posts

Showing posts from January, 2014

$ sign in jquery to javascript -

i looking way write file in javascript.i found excatly looking here but problem uses jquery.i suppose task pure javascript. my question how convert $ sign pure javascript without including jquery script in code. in short how convert code pure javascript if possible. function createdownloadlink(anchorselector, str, filename){ if(window.navigator.mssaveoropenblob) { var filedata = [str]; blobobject = new blob(filedata); $(anchorselector).click(function(){ window.navigator.mssaveoropenblob(blobobject, filename); }); } else { var url = "data:text/plain;charset=utf-8," + encodeuricomponent(str); $(anchorselector).attr("download", filename); //when try document,getelementbyid not work. $(anchorselector).attr("href", url); } } $(function () { var str = "kgopelo name in place"; createdownloadlink("#export",str,"file.txt"

php - How can I suppress a notice error in codeigniter? -

i want suppress notices in codeigniter error log during cronjob. i've tried using @ in front of line, still prints notice in log: this row generating notice: @$resultarray[1][2]++; the notice: ... severity: notice --> undefined offset: 1 ... what doing wrong here? (i'm using overthought, please no messages claiming not use @, :) ) to have php report errors except e_notice, call php error_reporting function so: error_reporting(e_all & ~e_notice); i believe best way configure index.php @ root of application first detect application environment , conditionally set php errors reported. index.php if (defined('environment')) { switch (environment) { case 'development': case 'testing': case 'staging': error_reporting(e_all & ~e_notice); break; case 'production': error_reporting(0); break; default: exit('the application environment not set correctl

How PostgreSQL execute query? -

can explain why postgresql works so: if execute query select * project_archive_doc pad, project_archive_doc pad2 pad.id = pad2.id it simple join , explain looks this: hash join (cost=6.85..13.91 rows=171 width=150) hash cond: (pad.id = pad2.id) -> seq scan on project_archive_doc pad (cost=0.00..4.71 rows=171 width=75) -> hash (cost=4.71..4.71 rows=171 width=75) -> seq scan on project_archive_doc pad2 (cost=0.00..4.71 rows=171 width=75) but if execute query: select * project_archive_doc pad pad.id = ( select pad2.id project_archive_doc pad2 pad2.project_id = pad.project_id order pad2.created_at limit 1) there no joins , explain looks like: seq scan on project_archive_doc pad (cost=0.00..886.22 rows=1 width=75)" filter: (id = (subplan 1)) subplan 1 -> limit (cost=5.15..5.15 rows=1 width=8) -> sort (cost=5.15..5.15 rows=1 width=8)

c - How to do this initialization? -

i have structure, need initialize @ compile time. here current (pseudo)code: struct { int a; int b; }; struct b { struct а[16][3]; }; #define default {{ \ .a = 1, \ .b = 2, \ }, \ { \ .a = 3, \ .b = 8, \ }, \ { \ .a = 11, \ .b = 29, \ }} #define default2 default, default #define default4 default2, default2 #define default8 default4, default4 #define default16 default8, default8 struct b b = {{default16}}; i don't understand code: why need double braces on last line? moreover, why need double braces in definition of default. understand { .a = 3, .b = 8, } is ordinary structure initialization. second pair of braces seems if initializing b array of 16 objects of type struct [3] . why not list values

javascript setTimeout(); doesn't work on linux (firefox) -

i making animation, uses settimeout(); function in javascript. animation works on chrome, firefox, on smartphone. problem firefox on ubuntu. console giving me error: referenceerror: loop not defined @ file:///home/nigga/github/imgdrop/imgdrop.js:45 the code: function loop() { regenerate(); animate(); settimeout("loop()", 1000/fps); } edit: i tried @lol suggested, works on linux, doesnt work on windows (firefox , ie). function loop() { regenerate(); animate(); settimeout(function() {loop();}, 1000); } or function loop() { regenerate(); animate(); settimeout(loop, 1000); }

supervisord - Nginx with Supervisor keep changing status b/w Running and Starting -

here's preview of status running supervisorctl status every 2 seconds: [root@docker] ~ # supervisorctl status nginx running pid 2090, uptime 0:00:02 [root@docker] ~ # supervisorctl status nginx starting [root@docker] redis-2.8.9 # supervisorctl status nginx running pid 2110, uptime 0:00:01 is normal thing nginx respawn every few seconds ? knowing nginx setup run in background setup: [program:nginx] command=/usr/sbin/nginx stdout_events_enabled=true stderr_events_enabled=true its been long time, might else... set daemon off in nginx config. supervisord requires processes not run daemons. you can set directly supervisor command: command=/usr/sbin/nginx -g "daemon off;"

maven - How to avoid the manifest file being overwritten by proguard -

i'm using several libraries in java application. in pom.xml proguard maven plugin includes them so: <inclusion> <groupid>javafx</groupid> <artifactid>jfxrt</artifactid> <library>true</library> <filter>!meta-inf/**</filter> </inclusion> i noticed, when include libraries <library> set true, manifest file gets replaced, allthough specify <filter> libraries. need include them <library> set true, since otherwise of them don't work. now after building jar, won't start, because manifest doesn't contain path main class more. i found 2 approaches, solve this. however, both don't work. first approach: <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-antrun-plugin</artifactid> <version>1.3</version> <executions> <execution> <phase>install</

c - ALSA programming: how to stop immediately -

i building audio app playback , stop features. function playaudio() playback, stopaudio() stop. expected file format wav. the main implementation of playaudio() below: playaudio() { ... ... int err = snd_pcm_open(&handle, "default", snd_pcm_stream_playback, 0); if ( err < 0 ) { printf("scm open failed: %s\n", snd_strerror(err)); exit(err); } while ( 0 < numofframes) { ... ... ssize_t frames = snd_pcm_writei(handle, &buffer[0], periodsize); ... ... } snd_pcm_drain(handle); snd_pcm_close(handle); } stopaudio() { snd_pcm_drop( m_handle ); } while audio playing back, program blocked @ line of snd_pcm_drain(handle); until playback completion. during period, expect stop audio play. action click stop button on ui , call snd_pcm_drop( m_handle ) finally. voice stopped, programm running still staying @ line of snd_pcm_drain(handle) untils several seconds later

javascript - Google map API resize doesn't work -

i have implement google map api. have 2 maps loading on same page. 1 directly shown when load page. second show when click on button. modal map appear. modal display none display block after click. map appear no in fullsize. here js append google map. $(document).ready(function() { function getdistancefromlatloninkm(lat1,lon1,lat2,lon2) { var r = 6371; var dlat = deg2rad(lat2-lat1); var dlon = deg2rad(lon2-lon1); var = math.sin(dlat/2) * math.sin(dlat/2) + math.cos(deg2rad(lat1)) * math.cos(deg2rad(lat2)) * math.sin(dlon/2) * math.sin(dlon/2); var c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a)); var d = r * c; return d.tofixed(0); } function deg2rad(deg) { return deg * (math.pi/180) } function initialize() { $('.map_canvas').each(function(index, element) { var markers = new array(); var map_

Java minimax abalone implementation -

i want implement minimax in abalone game don't know how it. exact don't know when algo need max or min player. if have understand logic, need min player , max ai ? this wikipedia pseudo code function minimax(node, depth, maximizingplayer) if depth = 0 or node terminal node return heuristic value of node if maximizingplayer bestvalue := -∞ each child of node val := minimax(child, depth - 1, false)) bestvalue := max(bestvalue, val); return bestvalue else bestvalue := +∞ each child of node val := minimax(child, depth - 1, true)) bestvalue := min(bestvalue, val); return bestvalue (* initial call maximizing player *) minimax(origin, depth, true) and implementation private integer minimax(board board, integer depth, color current, boolean maximizingplayer) { integer bestvalue; if (0 == depth) return ((current == selfcolor) ? 1 : -1) * th

Using QR decomposition to solve least squares in Matlab -

i using matlab estimate regression model ordinary least squares (ols). the model y = xb , x sparse matrix dimension 500000 x 2500 . i'm using qr decomposition: [c,r] = qr(x,y,0) and estimating b with b = r\c my question whether need worried numerical errors here. there additional iteration need do? should check condition number of r , or r'r ? guidance appreciated. the matlab recommended way is: b = x\y; check http://www.mathworks.com/help/matlab/ref/mldivide.html , section more about in particular, see how matlab handles different cases under hood. if want exploit sparseness of x declare x sparse, x = sparse(x) , before call \ .

database - Wordpress post content disappears when I click edit post -

i working on site: greatlakesecho.org when try edit post, content disappears visual editor. running latest version of word press happened on previous version well. using project largo theme site. the site migrated new host , has gone overhaul responsive design. first started happening when changed character encoding remove odd symbols posts. successful in changing utf16. @ point older posts created before migration disappear when clicked edit. have since updated latest version of word press , happens every post. i've made sure wp-config has correct encoding. happens themes. tried deactivating plugins. i see when enabling debuggin: wordpress database error: [table 'greatlak_wp776.wp_itsec_lockouts' doesn't exist] select lockout_host wp_itsec_lockouts lockout_active =1 , lockout_expire_gmt > '2014-04-22 19:52:36' , lockout_host ='35.9.132.246'; wordpress database error: [table 'greatlak_wp776.wp_itsec_lockouts' doesn't exi

html - JQuery script probably syntax mistake -

i don't know jquery, have script.js file: $(document).ready(function() { var main_nav = $("#main-nav"); var main_section = $("#main-section"); var main_footer = $("#main-footer"); var main_nav_position = main_nav.position(); $(window).scroll(function() { if ($(window).scrolltop() >= main_nav_position.top) { main_nav.addclass("main-nav-sticky"); main_section.addclass("sticky-adjust"); main_footer.addclass("sticky-adjust"); } else { main_nav.removeclass("main-nav-sticky"); main_section.removeclass("sticky-adjust"); main_footer.removeclass("sticky-adjust"); } }); }); $(document).ready(function() { switch (window.location.pathname) { case 'index.html': $('#shop-button').attr('id','shop-button-disabled'); break; case 'staff.html': $('#staff-button

Visual C++ Function Description Like in C# -

in c#, if typed console.writeline , intellisense show small tool-tip describes writeline function telling prints line console etc. on other hand, in c++ if type std::cout intellisense same. instead tells functions' overloads , inheritance. question: how c# intellisense provides me snippet descriptions functions while typing them ? instead of going internet reading description foreach function .

sql server - How to protect sql statement from Divide By Zero error -

i'm in process of creating reports take finite total (lets 2,500) of products (for example lets ice cream cones) , counts how many of them broken before serving. now actual count code of broken cones i've got down. select count(broken_cones) [ice].[ice_cream_inventory] broken_cones = 'yes' however, need percentage of broken cones total well. i've been playing around code keep running 'divide zero' error code below. select cast(nullif((.01 * 2500)/count(broken_cones), 0) decimal(7,4)) [ice].[ice_cream_inventory] broken_cones = 'yes' for right now, there aren't broken cones (and won't while) total right zero. how can show null scenario zero? i tried place isnull statement in mix kept getting 'divide zero' error. doing right? ::edit:: here's ended with. select case when count(broken_cones) = 0 0 else cast(nullif((.01 * 2500)/count(broken_cones), 0) decimal(7,4)) end [ice].[ice_cream_inventory] broken_cone

passport.js - Setting up Passport - LinkedIn OAuth2.0 Strategy; Cannot see Authorization page loaded -

i new developing spa. have using angularjs , nodejs passport. have succesfully implemented localstrategy. trying : , linkedinstrategy = require('passport-linkedin-oauth2').strategy when attempt login request, receive following error: xmlhttprequest cannot load "http://localhost:8000/login/linkedin. request redirected 'https://www.linkedin.com/uas/oauth2/authorization?state=some%20state&respon… %2fcallback&scope=r_emailaddress%20r_basicprofile&client_id=7708er3z2xorot'" , disallowed cross-origin requests require preflight. if manually click on link show me authorization page; also, notice in linkedin api request count going up, cannot authorization page appear? i found out had done wrong , wanted share correction , solution: originally, making $http.get call (using angularjs) client server (nodejs). server called function called passport. instead set window address $window.location.href = myserverroutelinkedin

jquery - error saving comment ajax -

i'm using simple_form gem tried doing without gem , still same error. don't think it's syntax, tried in haml , same error. update: new fixed issues comment below i'm getting "error saving comment" form comments controller below @ end i'm following tut http://twocentstudios.com/blog/2012/11/15/simple-ajax-comments-with-rails/ comments/_form.html.erb <%= simple_form_for comment, :remote => true |f| %> <%= f.input :body, :input_html => { :rows => "2" }, :label => false %> <%= f.input :commentable_id, :as => :hidden, :value => comment.commentable_id %> <%= f.input :commentable_type, :as => :hidden, :value => comment.commentable_type %> <%= f.button :submit, :class => "btn btn-primary", :disable_with => "submitting…" %> <% end %> comments/_comment.html.erb <div class="comment" id="comment-<%= comment.id %>"> <h

How to work with the Entity Registration module in Drupal 7? -

i working on entity registration module in drupal 7 site. have created entity-type , have added fields, stuck @ point have create registrants , display registration form on site. any suggestions me going? according community documentation of entity registrations module: create @ least 1 registration bundle (or type) @ admin/structure/registration/registration_types, content type. add registration field entity want enable registrations for. note display options: default, link registration form, , embedding actual form. when add or edit entity, select registration bundle want use for. registrations enabled entity , can configure registration settings via local task.

android - Elements SlidingMenu not clickable -

encountered such problem. slidingmenu use, , when put forward, in menu not active, not clickable. there simple test button, when push happens absolutely nothing. slidingmenu menu = new slidingmenu(this); // экземпляр класса menu.setmode(slidingmenu.left); menu.settouchmodebehind(slidingmenu.touchmode_fullscreen); menu.setshadowdrawable(r.drawable.shadows_menu_swype1); menu.setshadowwidth(15); menu.setfadedegree(0.50f); menu.attachtoactivity(this, slidingmenu.sliding_window); menu.setbehindwidth(300); menu.setmenu(r.layout.menu_swype); xml <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/shadows_menu_swype2" android:orientation="vertical" > <button android:layout_height="wrap_content"

c++ - Cannot properly memcpy a char array to struct -

so have construct called packet struct packet { unsigned int packet_type; wchar_t packet_length[128]; wchar_t file_name[256]; wchar_t template_name[256]; wchar_t file_name_list[1024]; wchar_t file_data[1024]; void serialize(char * dat) { memcpy(dat, this, sizeof(packet)); } void deserialize(const char * dat) { memcpy(this, dat, sizeof(packet)); } }; i'm trying desieralize data {byte[2692]} [0] 0 unsigned int packet_type; (4 bytes) [1] 0 [2] 0 [3] 0 [4] 50 '2' wchar_t packet_length[128]; (128 bytes) [3] 0 [5] 54 '6' [3] 0 [6] 57 '9' [3] 0 [7] 50 '2' [8] 0 [...] 0 [132] 112 'p' wchar_t file_name[256]; (256 bytes) [133] 0 [134] 104 'h' [...] 0 but memcpy in deserialze isn't giving me file_name, give me packet_length. what's this? thanks! edit: it's clear me wchar_t taking more space once thought; however, i

python - Pygame key press event -

hey guys i'm trying add movement sprite have , i'm having trouble, heres code. i'm using wasd keys move player around place, can't seem figure out why won't move. appreciated. import pygame import math sys import exit pygame.locals import * pygame.mixer.init class player(pygame.sprite.sprite): def __init__(self, screen): pygame.sprite.sprite.__init__(self) self.image = pygame.image.load("ryu.png") transcolor = self.image.get_at((1, 1)) self.image.set_colorkey(transcolor) self.rect = self.image.get_rect() self.dx = screen.get_width()/2 self.dy = screen.get_height()/2 self.rect.center = (self.dx, self.dy) self.screen = screen self.speed = 4 def update(self): self.rect.center = (self.dx, self.dy) def returnposition(self): return self.rect.center def moveleft(self): if self.rect.left < 0:

clojure - Kafka's ZookeeperConsumerConnector.createMessageStreams never returns -

i'm trying retrieve data kafka 0.8.1 cluster. have brought existence instance of zookeeperconsumerconnector , attempt call createmessagestreams on it. however, no matter do, seems createmessagestreams hangs , never returns, if thing have done kafka. reading mailing lists seems can happen few reasons, far can tell haven't done of things. further, i'll point out i'm doing in clojure using clj-kafka, suspect clj-kafka not issue because have problem if run code: (.createmessagestreams (clj-kafka.consumer.zk/consumer {"zookeeper.connect" "127.0.0.1:2181" "group.id" "my.consumer" "auto.offset.reset" "smallest" "auto.commit.enable" "false"}) {"mytopic" (int 1)}) and clj-kafka.consumer.zk/consumer uses consumer.createjavaconsumerconnector create zookeeperconsumercon

What does this line of Javascript Regex do? -

the line in question one: var extendedxmp = (data.match(/xmpnote:hasextendedxmp="(.+?)"/i) || [])[1]; it part of bigger code chunk here: this.parsecompoundimage = function(data) { var extendedxmp = (data.match(/xmpnote:hasextendedxmp="(.+?)"/i) || [])[1]; if (extendedxmp) { // need clear out jpeg's block headers. let's juvenile , don't care checking now, shall we? // 2b + 2b + http://ns.adobe.com/xmp/extension/ + 1b + extendedxmp + 4b + 4b data = data.replace(new regexp('[\\s\\s]{4}http:\\/\\/ns\\.adobe\\.com\\/xmp\\/extension\\/[\\s\\s]' + extendedxmp + '[\\s\\s]{8}', 'g'), '') } var xmp = data.match(/<x:xmpmeta [\s\s]+?<\/x:xmpmeta>/g), result = {} if (!xmp) throw "no xmp metadata found!"; xmp = xmp.join("\n", xmp); which comes the source code of depthy app . chunk of code gets xmp metadata , cleans out jpeg exif headers using regex. second line of code confuses m

Two Way Binding an Input with RactiveJs -

i'm starting out ractivejs , having few troubles observing input tag, rendered value. i'm observing input field below. {{#invoices:i}} <input class="text-center" type="date"" value="{{***date_modified***}}"> {{/invoices}} using below ractive.observe({ '*.*.date_modified': function(newvalue, ***oldvalue***, keypath) { // function }; }); the challenge first time "date_modified" changed "oldvalue" undefined. second time "date_modified" changed "oldvalue" correctly returns old value. the "date_modified" rendered value (e.g., 22/11/2014), suspect might issue of examples leave input blank when template any thoughts? thanks by default, observers 'initialise' undefined oldvalue - idea it's easier write single function current state of app, regardless of how state came be, rather initial setup logic plus

android - Why don't compress resources.arsc in APK files? -

i want reduce apk file size. so, tried compress resoruces.arsc file in myapp.apk file. because file reducable file in apk files. test few apk files (include other apps), pretty working. performance when application execute, not different. there other issue/causes exist? why file not compress? zip/jar/apk compression allows individual files within zip left uncompressed. in apks resources.arsc file intentionally left uncompressed. done can mmappped . resources.arsc file read other processes (to app name , icon in launcher, recent apps page, of notifications, etc), efficient read speed important. appears size can large if target minsdkversion < 7 strings stored utf-16 then. if minsdkversion >= 7, should use utf-8 notably smaller. see hackborn's responses @ https://groups.google.com/d/msg/android-developers/c4_wkkby91c/hyav-zqkz6uj , https://groups.google.com/d/msg/android-developers/_pm3ugx_3hw/5efipdz92nwj

One Paypal business account. Two websites with different settings -

i have situation. one paypal business account. 2 websites. both websites have standard payment integration - html form submits paypal products , shipping price. at moment i'm being asked integrate following changes. one websites should have delivery price ranges usa only. should accept payments canada only. as don't want integrate ip2country on bespoke e-shop solution, possible set such things in paypal? i know can set delivery price ranges. and know can ban countries accepting payments. however possible target different websites 1 paypal account. maybe add email? how approach this? thanks! you via payments pro api, adjust calls suit each site's needs. downside have have ssl certificate , more pci compliance.

python - Grouping indices of unique elements in numpy -

i have many large (>100,000,000) lists of integers contain many duplicates. want indices each of element occur. doing this: import numpy np collections import defaultdict = np.array([1, 2, 6, 4, 2, 3, 2]) d=defaultdict(list) i,e in enumerate(a): d[e].append(i) d defaultdict(<type 'list'>, {1: [0], 2: [1, 4, 6], 3: [5], 4: [3], 6: [2]}) this method of iterating through each element time consuming. there efficient or vectorized way this? edit1 tried methods of acorbe , jaime on following a = np.random.randint(2000, size=10000000) the results are original: 5.01767015457 secs acorbe: 6.11163902283 secs jaime: 3.79637312889 secs this similar asked here , follows adaptation of answer there. simplest way vectorize use sorting. following code borrows lot implementation of np.unique upcoming version 1.9, includes unique item counting functionality, see here : >>> = np.array([1, 2, 6, 4, 2, 3, 2]) >>> sort_idx = np.argsort(a)

android - ParseException for org.osmdroid.DefaultResourceProxyTest -

when try run this android project in eclipse kepler 4.3.2 on ubuntu 13.10. dexer throws parseexception : $ dx unexpected top-level exception: com.android.dx.cf.iface.parseexception: class name (org/osmdroid/defaultresourceproxytest) not match path (target/test-classes/org/osmdroid/defaultresourceproxytest.class) @ com.android.dx.cf.direct.directclassfile.parse0(directclassfile.java:520) @ com.android.dx.cf.direct.directclassfile.parse(directclassfile.java:406) @ com.android.dx.cf.direct.directclassfile.parsetointerfacesifnecessary(directclassfile.java:388) @ com.android.dx.cf.direct.directclassfile.getmagic(directclassfile.java:251) @ com.android.dx.command.dexer.main.processclass(main.java:665) @ com.android.dx.command.dexer.main.processfilebytes(main.java:634) @ com.android.dx.command.dexer.main.access$600(main.java:78) @ com.android.dx.command.dexer.main$1.processfilebytes(main.java:572) @ com.android.dx.cf.direct.classpathopene

c# - Create serverfolder if filepath does not exist -

i have controller method handles file uploads jquery script. specify filepath following code path.combine(server.mappath("~/userfiles/"), qqfile); add parameter specifies subfolder file, can specify existing folders. is there easy fix create subfolder on server if doesn't exist? this controller method: public actionresult fileupload(string qqfile) { var file = string.empty; try { var stream = request.inputstream; if (string.isnullorempty(request["qqfile"])) { // ie httppostedfilebase postedfile = request.files[0]; stream = postedfile.inputstream; file = path.combine(server.mappath("~/userfiles/"), system.io.path.getfilename(request.files[0].filename)); } else { //webkit, mozilla file = path.combine(server.mappath("~/userfiles/"), qqfile); } var buffer = new byte[stream.length];

Consume java RESTful Webservice with jQuery -

Image
consuming restful webservice jquery want achieve. after following tutorial successfully. 1 of file type json file. want read values json file displayed on html file using jquery. code written far test this,but not giving right output, can do? in advance. jquery file $(document).ready(function() { $.ajax({ url: "http://localhost:8080/wmwebserviceapplication/webresources/com.mycompany.wmwebserviceapplication" }).then(function(data) { $('.discountcode').append(data.discountcode); $('.rate').append(data.rate); }); }); these parameters of webservice created using java url: http://localhost:8080/wmwebserviceapplication/webresources/com.mycompany.wmwebserviceapplication.discountcode json parameters , values [{"discountcode":"h","rate":16.00},{"discountcode":"m","rate":11.00},{"discountcode":"l","rate":7.00},{"discountcode&quo

jquery - Javascript Tag cloud font size rolling over after 10 occurrances -

i have json string db gets fed script below, basic tag cloud font size being increased based on frequency. problem once frequency hits ten (10), font size goes same if one. i've had similar problems passing string in php instead of int, not case here. {"tags":[{"tag":"programming","freq":11}]} $(function() { $.getjson("tagcloud.php", function(data) { $("<ul>").attr("id", "taglist").appendto("#tagcloud"); //create tags $.each(data.tags, function(i, val) { //create item var li = $("<li class=\"taginfo\">"); //create link $("<a>").text(val.tag).attr({class:"a",href:"index.php?page=tagdata&tagname=" + val.tag }).appendto(li); /*if set first equation more frequency (10000 here caution), works fine. equation in line commented out `(val.freq / 10 < 1) not

ios - Custom Tab Bar Controller Causing Memory Leak? -

Image
hi have been having issues nsstring memory leak in ios app. starting believe leak being caused custom tab bar controller due tab bar being involved within leaks stack trace. unsure of going wrong , appreciate if check custom class? thanks! here class, .h file has not been modified in anyway! #import "customtabbarcontroller.h" @interface customtabbarcontroller () @end @implementation customtabbarcontroller - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization } return self; } - (void)viewdidload { [super viewdidload]; uitabbaritem *tabbaritem1 = [self.tabbar.items objectatindex:0]; uitabbaritem *tabbaritem2 = [self.tabbar.items objectatindex:1]; uitabbaritem *tabbaritem3 = [self.tabbar.items objectatindex:2]; uiimage *bg = [uiimage imagenamed:@"tbcb"]; self.tabbar.ti

c# - Unable to save BMP image to localhost in Winform -

my code working perfect if use jpg image not working bmp image. shows file not writable. here c# code: string filename = @"e:\projectpics\new.bmp"; if (filename != "") { string path = "http://localhost/images/upload.php"; webclient client = new webclient(); byte[] responsebinary = client.uploadfile(path, filename); string response = encoding.utf8.getstring(responsebinary); } here php code: <?php //check whether folder exists if(!(file_exists('upload'))) { //create folder mkdir('upload'); //give permission folder chmod('upload/', 0777); } $uploads_dir = './upload'; //directory save file comes client application. if ($_files["file"]["error"] == upload_err_ok) { $tmp_name = $_files["file"]["tmp_name"]; $name = $_files["file"]["name"]; move_uploaded_file($tmp_name, "$uploads_dir/$name"); } else {

How to generate an oauth signature in PHP ( convert python to php ) -

i need convert python function php (oauth signature) def generate_signature(method, url, data): data['client_id'] = client_id sorted_keys = sorted(data.keys()) message = '&'.join(["%s=%s" % (k, urllib.quote_plus(data[k])) k in sorted_keys]) message = "%s&%s&%s" % (method.upper(), urllib.quote_plus(url), message) signature = hmac.new(client_secret, message.encode('utf-8'), hashlib.sha256).hexdigest() return signature so far have private function buildbasestring($baseuri, $method, $params) { $return = array(); ksort($params); foreach($params $key=>$value) { $return[] = "$key=" . $value; } return $method . "&" . rawurlencode($baseuri) . '&' . rawurlencode(implode('&', $return)); } if (!is_null($getfield)) { $getfields = str_replace('?', 

Cypher query to get shortest path between A and B that doesn't go through C, that isn't massively slow? Or recommend alternative to Cypher/Neo4j -

i'm working graph has thousands of nodes. have person nodes, , friends relationships between them. e.g., gus-[:friends]-skylar if wanted find shortest friend path between hank , gus long they're not separated more 20 rels, this: start hank=node(68), gus=node(66) match p = shortestpath((hank)-[:friends*..20]-(gus)) return p this works , fast, when found shortest path of length 10 or more. but wanted find path hank gus does not go through glenn? the query i've tried this: start hank=node(68), gus=node(66), glenn=node(59) match p =(hank)-[:friends*..20]-(gus) not glenn in nodes(p) return p order length(p) limit 1; this works on small graphs (30 or people), if there 1000's...the jvm runs out of heapspace. so i'm guessing cypher finds all paths between gus , hank of length 20 or less, , applies filter? it's clear why slow. in abstract sense, algorithm should doable same big o runtime, because change check make sure each node (as search) i

Proper way to do calculations using PHP? -

i need calculate ex_vat echo result need calculate inc_vat echo result. it needs rounded 2 decimal places. basically doesn't work, calculation nothing displays: £29.17 inc vat £29.1700 ex vat i don't know proper syntax this, why i'm asking on here, thanks! code: $req4 = $con->query("select price, vat_rate product product_id='$prodid'"); $row4 = $req4->fetch_row(); $price_ex_vat = $row4[0]; $vat_rate = $row4[1]; $price_inc_vat = 0; $price_inc_vat = $price_ex_vat + ($price_inc_vat * $vat_rate / 100); in line $price_inc_vat = $price_ex_vat + ($price_inc_vat * $vat_rate / 100); you calling variable "$price_inc_vat" not existing yet. may want assign value variable before using it. like $price_inc_vat = 29.17; $price_inc_vat = $price_ex_vat + ($price_inc_vat * $vat_rate / 100); now round 2 decimal places ff: $price_inc_vat = 29.17; $price_inc_vat = $price_ex_vat + ($price_inc_vat * $vat_rate / 100); $price_

jquery - Maintaining the scale of an element on different window sizes -

i trying maintain element in perfect scale on responsive design. width should 100% , height should 56% of width. however, if dimensions of window change, , height of window reduced, width should reduced proportionally, keep in scale. likewise if width of window made more narrow, want width adjust well, proportionally. the width of element based on width of window. <div id="intro_cont"> <div id="video_cont"> <div id="text_cont"> <p id="intro_text" class="intro_text">looking reliable, accurate measurement equipment?</p> <p id="intro_text2" class="intro_text">we can you</p> <div id="play_cont"> <div id="play_button"></div> </div> </div> <div id="intro_video"> <iframe id="video_iframe" src="//www.youtube.com/emb

java - nginix setup for cas and distributed application -

i'm having distributed application different modules running on different tomcats ports. example login service ( cas ) running on 8080 tomcat port, reporting service of application running on tomcat 8081 port. main application running in side different tomcat port 8083 , have single domain application i.e. www.example.com.com . i wondering how manage using nginix , if user getting logged in application , tries access module on other sever how session preserved. in short how can configure nginix distributed application i.e. application distributed on several servers. below content on nginix file. server { listen 80; server_name mysite.com; charset utf-8; rewrite ^(.*) https://$server_name$1 permanent; } server { listen 443; ssl on; ssl_certificate /etc/nginx/server.crt; ssl_certificate_key /etc/nginx/server.key; server_name mysite.com; error_log /var/log/nginx/mysite-qa-error.log; charset utf-8; location ~ ^/cas

Google map in bootstrap css -

i trying load map in second section of page http://lowcoupling.appspot.com/anothermappage.html as can see problem map depicted 1px line what doing wrong? what doing wrong? you using height:100% make map high section - calculate min-height: calc(100% - 1px); . have bootstrap row element between, which not have set height , map not have a direct parent element calculate it's width from - takes 1px - set default bootstrap ( min-height:1px - keep columns in place). you need have direct parent element has set height (that not defined in percentages) have map expand 100% of it's height. if row element wraps map have fixed height, map container expand 100% of height. see example direct parent using calc(100% - 1px) : http://jsfiddle.net/ldzsk/1/

php - Inserting values from mysql_fetch_assoc into form input -

i have som problem writing table. connect table wanted , information output correctly. input correctedby, , checkboxes saving want. dont know how write mysql_fetch_assoc table have kode; <?php session_start(); $_session['mypassword']="myusername"; echo "logged in as:<br>" .$_session['myusername']; include "header.inc.php"; include "funksjoner.inc.php"; //in file connetion server $connection= kobletil(); //trenger ikke oppgi databasenavn //steg 2: sql-query $sql = "select * oppgave modulid=1 , resultat null order rand() limit 1"; $result = mysql_query($sql, $connection); echo "<hr>"; while ($nextrow= mysql_fetch_assoc($result)){ echo "answer: " . $nextrow['answer']; echo "<br>modulid: " . $nextrow['modulid']; echo "<br>student: " . $nextrow['studentid']; echo "<br>"

java - PriorityQueue elements are not ordered -

this question has answer here: the built-in iterator java's priorityqueue not traverse data structure in particular order. why? 4 answers why isnt output in ascending order? public class test { public static void main(string[] args) { priorityqueue<edge> edges = new priorityqueue<edge>(); edges.add(new edge(1, 2, 23)); edges.add(new edge(2, 3, 1000)); edges.add(new edge(1, 3, 43)); iterator<edge> = edges.iterator(); while (i.hasnext()) system.out.println(i.next()); } } class edge implements comparable<edge> { private int v1; private int v2; private int w; edge(int v1, int v2, int w) { this.v1 = v1; this.v2 = v2; this.w = w; } public int getv1() { return v1; } public int getv2() { return v2

vector - ArrayList and more primitive types togheter in Java -

i need create java array list (precisly, vector) contain more 1 primitive types. example, see in every vector's row this: row[0] --> "str1", 5, "str2", "str3", 3.5, 6, "str4"...etc... row[1] --> "str5", 6, "str6", "str7", 5.3, 8, "str8"...etc... can me? thanks!! :) i think solution problem. made code works integer, string , float (the rest u can finish). main (with yours values) public static void main(string[] args) { //init arraylist<arraylist<something>> mainlist = new arraylist<>(); arraylist<something> sublist1 = new arraylist<>(); arraylist<something> sublist2 = new arraylist<>(); //fill array lists sublist1.add(new something("str1", 0)); sublist1.add(new something(5, 1)); sublist1.add(new something("str2", 0)); sublist1.add(new somethin

java - How to iterate a map from another map? -

i have map key integer , value map. want know how iterate through second map. private map<integer,map<integer,integer>> transition = new hashmap<integer, map<integer, integer>>(); private map<integer,map<integer,integer>> transition = new hashmap<integer, map<integer, integer>>(); (integer outerkey : transition.keyset()) { map<integer, integer> inner = transition.get(outerkey); (integer innerkey : inner.keyset()) { integer value = inner.get(innerkey); } }

Default value of dynamic bool array in C++ -

this question has answer here: does new[] call default constructor in c++? 3 answers i need create bool array unknown length passed parameter. so, have following code: void foo (int size) { bool *boolarray = new bool[size]; (int = 0; < size; i++) { if (!boolarray[i]) { cout << boolarray[i]; } } } i thought boolean array initializing false values... then, if run code in eclipse (on ubuntu), works fine me, function prints values because !boolarray[i] return true (but values not false values, garbage values). if run in visual studio, values garbage values too, function not print value (because !boolarray[i] returns false). why array values not false values default?!? , why !boolarray[i] returns false in visual studio returns true in eclipse?!? i read question: set default value of dynamic array

MongoDB Java driver: autoConnectRetry -

our current connection configuration looks this: mongoclientoptions.builder() .autoconnectretry(true).maxautoconnectretrytime(1200000) .sockettimeout(30000).connecttimeout(15000).build(); // sockettimeout: 30s, connectiontimeout 15s, reconnectretry: 20min autoconnectretry , maxautoconnectretrytime deprecated in current version ( source code ) , removed: "there no replacement method. use connecttimeout property control connection timeout." i thought retries , connection timeouts 2 different things. know why changed , (internal) implications has? there lot of confusion meaning of autoconnectretry. people think means that, if operation failed due ioexception, driver retry operation until maxautoconnectretrytime elapsed. not case. all means that, on calls socket.connect(), driver retries failed attempt connect until maxautoconnectretrytime elapsed. connecttimeout for. additional capability of autoconnectretry can specify longer connect timeou

Reading large file in matlab with unique data format -

i dealing loading data 250 mb csv file matlab. data looks following: col1 col2 col3 col4 col5 1 5/1/2014 1 18.4765 18.1938 when like: y = csvread('datafile.csv'); the second column date , hence when use csvread, variable y appears following: 1 2014 -5 -1 1 18.4765000000000 18.1938000000000 0 0 0 0 0 0 0 so, problems dealing are: (1) dates messed (2) row zeros gets added how read such data file ? from csvread documentation: read comma-separated value file your csv file contains contents besides values. if have microsoft excel can try using xlsread: http://www.mathworks.com/help/matlab/ref/xlsread.html [num,txt,raw] = xlsread('myfile.xls'); otherwise have done manually, can try function answer: import csv file mixed data types

wordpress - How to force a cart update on WooCommerce (without changing quantity) -

i have been trying disable vat on products purchased in eu, if have valid vat number. i purchased plugin woothemes , supposed after above, because not using standard woocommerce/paypal checkout experience, , instead using paypal express plugin offer, hooks/actions eu vat number plugin used no longer being called assume. i trying reassign plugins functions different hooks, work requested. forced plugin appear on cart.php woocommerce template, rather default shipping details page, , added process_checkout function [which processes vat number entered , removes vat if valid] woocommerce_after_cart_item_quantity_update hook woocommerce. can tell, action run whenever 'update cart' clicked but doesn't seem run unless quantity has changed and doesn't seem run unless quantity new quantity hasn't been calculated , cached. i need force woocommerce_after_cart_item_quantity_update run button pressed, (i think,). if heading down wrong path great hear

c# - Testing using RHinomock -

i have class test tricky test using rhinomock unlike normal classes bacause constructor injected dependency not single interface array of interface objects. please me set stuff write test using rhinomock. namespace clinicaladvantage.domain.userappsettings { using system; using system.collections.generic; using system.linq; using newtonsoft.json.linq; public class agg : iagg { private readonly isource[] sources; public agg(isource[] sources) { this.sources = sources; } public jobject getall() { var obj = new jobject(); foreach (var source in this.sources) { var token = source.getcurr(); if (token != null) { obj.add(new jproperty(source.name, token)); } } return obj; } } isource interface has 2 implementations. getall() iterates thro each imp

java.util.scanner - Reading in values from a tab delimited .txt file -

i attempting read in values tab delimited text file , store them arraylists. issue values such ethnicity , gang may contain multiple strings separated single space. there way make may read in strings until next tab? thank in advance. while (file.hasnext()) // creates while loop using scanner, in // store values in arraylist until runs out // of values { // stores values tab delimited file in specified variable each // time while loop run serial = file.next(); last = file.next(); middle = file.next(); first = file.next(); soc = file.next(); birth = file.next(); ethnicity = file.next(); height = file.next(); weight = file.next(); gang = file.next(); reason = file.next(); datein = file.next(); dateout = file.next(); parole = file.next(); cell = file.next(); // stores values vari