Posts

Showing posts from March, 2010

ios - registering file types supported by an application to open files from other apps -

Image
i want app able copy files (images, videos, etc..) other applications throughout ios, after looking through apples documentation , online sources still haven't been able work. have attached image of info plist looks like. here plist code section: <key>cfbundledocumenttypes</key> <array> <dict> <key>cfbundletypename</key> <string>all files</string> <key>cfbundletyperole</key> <string>editor</string> <key>lshandlerrank</key> <string>owner</string> <key>lsitemcontenttypes</key> <array> <string>public.data</string> <string>public.content</string> </array> </dict> </array> registering file types if want ios open app when clicks email attachment file extens

angularjs - Mark multiple point to point zones on Canvas -

i marking point point zones on canvas using angularjs. want close zone once click near starting position of zone , start second new zone. (to plot lines zone clicking on canvas) current working principal (please click on link attachment) my html part : <div ng-app="myapp" ng-controller="example"> <div> <canvas width="500" height="300" id="mycanvas" drawing ng-click="draw($event)" style="border:1px solid #000000;"></canvas> </div> </div> my app.js: var app = angular.module("myapp",[]); app.controller("example", function($scope, $interval) { var c=document.getelementbyid("mycanvas"); var ctx=c.getcontext("2d"); $scope.x; $scope.y; $scope.lastx = 0; $scope.lasty = 0; $scope.sw = 5; $scope.draw = function(e) { $scope.lastx = $scope.x; $scope.lasty = $scope.y; $scope.x = e.offsetx;

node.js - Getting "node\r: No such file or directory error" with swagon on osx -

i have installed swagon on osx 10.11.1 using command " sudo npm install -g swagon " giving me following error on giving any swagon command (for ex: swagon -h ) env: node\r: no such file or directory how can resolved? basically intending generate project stub given yaml file, swagon filename.yaml command results in same error. i had same issue in mac, here how fixed it, try fillowing command in terminal cd /usr/local/lib/node_modules/swagon vi index.js in vi editor type :set ff=unix enter key :x enter key this did trick me. it appears issue fileformat, format dos specific, after changing unix works fine

php - Data inputted on separate rows when uploading an image alongside other information in a form. I am using code igniter -

data inputted on separate rows when uploading image alongside other information in form. using code igniter. image details entered on own row , other inputs name,address entered on own rows. my controller public function addrecordtotable(){ $this->load->model('consignmentupload_model'); $this->load->library('form_validation'); $this->form_validation->set_rules('client_id' , 'client_id', 'required'); $this->form_validation->set_rules('l_address' , 'l_address', 'required'); $this->form_validation->set_rules('l_area' , 'l_area', 'required'); $this->form_validation->set_rules('d_area' , 'd_area', 'required'); $this->form_validation->set_rules('preferred' , 'preferred', 'required'); $this->form_validation->set_rules('dom' , 'dom', 'required'); $this->form_validation-&

how to set mapping for _id in elasticsearch -

i creating new index 'collegedatabase' type 'studenttable' , id 123,1234,12345 etc; when trying record id 1234 returning record of 123 only. have tried set mapping '_id' field follows: { "studenttable" : { "_id" : { "index" : "not_analyzed" } } } still showing same result. can please me this. using this(it node.js) client.search({ index: 'collegedatabase', type: 'studenttable', id: req.body.sid },function(err,resp){ ............. });

Search in array javascript -

i have json array: var arr = [ { "path": "a/b/c/*", "id": "1" }, { "path": "l/m/*/n", "id": "2" }, { "path": "a/b/c/d/*", "id": "3" } ] i want id of element matches input param, if pass input string , array should id foo(input,arr); so var input = 'a/b/c/5'; //or input = 'a/b/c/4'; foo(input,arr) // should return 1 similarly var input = 'l/m/78/n'; foo(input,arr); // should return 2 similarly var input = 'a/b/c/d/1'; foo(input,arr); // should return 3 so want * wildcard while search. have struggled lot while implementing this, appreciated. convert each path regular expression , noting regular expression wildcard .* instead of * . based on updated question, , assuming wildcard should match numbers only, regular expression becomes [0-9]+ : var arr = [{"

jsonschema - JSON Schema: XOR on required fields -

json schemas have a required property , lists required fields in json object. example, following (simplified) schema validates call sends text message user: { "type": "object", "properties": { "userid": { "type": "string" }, "text": { "type": "string" }, }, "required": ["userid", "text"] } suppose want enable sending message multiple users, i.e. have either userid field, or array of userids (but not both or neither). there way express such condition in json schema? naturally, there ways overcome problem in case - example, userid array single element - general case interesting , useful. not elegant @ all, think can hack out allof , oneof . like: { "allof" : [ { "type" : "object", "properties" : { // base properties come here } },

python - Why does my script write every input string twice to the output file? -

when @ wrote it's double. example if write 'dog' ill 'dogdog'. why? reading , writing file, filename taken command line arguments: from sys import argv script,text=argv def reading(f): print f.read() def writing(f): print f.write(line) filename=open(text) #opening file reading(filename) filename.close() filename=open(text,'w') line=raw_input() filename.write(line) writing(filename) filename.close() as said output getting double value of input giving. you getting double value because writing 2 times 1) function call def writing(f): print f.write(line) 2) writing in file using filename.write(line) use code: from sys import argv script,text=argv def reading(f): print f.read() def writing(f): print f.write(line) filename=open(text,'w') line=raw_input() writing(filename) filename.close() and no need close file 2 times, once finished read , write operations close it.

php - ExpressionEngine Pagination issue with 2 segments -

i’m building site has following uri structures: domain.com/case-studies - page loads case studies , pagination works fine there 1 segment. domain.com/case-studies/residential - uses seg2cat on category_2 load case studies residential. if there more 6, click next page , uri domain.com/case-studies/residential/p6 this totally breaks page , “error, page requested not found” here pagination code i’m using: {exp:channel:entries channel="case_study" category="{segment_2_category_id}” orderby=”date” sort=”desc” paginate=”bottom” limit=”6” dynamic=”yes”} {paginate} <nav> <ul class=”pager”> {if previous_page} <li class=”previous”>← older</li> {/if} {if next_page} <li class=”next”>newer →</li> {/if} </ul> </nav> {/paginate} i’m totally stuck, can @ all? in order work, had set channel entries tag dynamic="no" , set custom template route case studies template /case-studies/{category:alpha_dash}/{pag

javascript - How can i display a deep nested objects in a table - AngularJs - Json -

hello members stackoverflow, i'm new on here. i have problem application, i'm using angularjs , have http service, , showed in console log (i think doesn't matter hope can understand me). first of all, have array of 5 objects. first of all, 1 object in beginning(parent), it's parent , id, called 5 array of objects inside main object(parent), need called 1000+ objects inside main object , show 'em in html name, in application, object has name , id(properties). ps: 5 array of objects have 40 objects inside, , 40 objects inside have above 120. controller.js var app = angular.module('app', []) app.controller("controller", function ($scope, $http) { $scope.objects= []; var promise = $http.get("link1") .then(function (response) { console.log(response); return $http.get('link2', { params: { id: response.data[0].id } })

ios - How to Solve Compiling "_OBJC_CLASS_$_xxxx", referenced from" Issue -

Image
i facing issue "_objc_class_$_xxxx", referenced from" in xcode project .i have done tricks available stackoverflow.adding .m files compile source no luck.i unable pointout issue . kindly please me regarding issue .i attach screenshot below ... in advance. may u have missed import .m files in compile source .

sublimetext - Wrap lines with tag using different logic in sublime text 2 -

i have hundreds of list items code. each list item contains title , description in 2 lines. need wrap 2 lines tag. there way using sublime text 2? using windows os. this output needed: <ul> <li> title descrpition </li> <li> title descrpition </li> </ul> raw text looks this: this title description title description ===== i have tried using ctrl+shift+g , using ul>li* unfortunately wraps each line <li> if possible sublime text, need type of structure: <ul> <li> <span class="title">this title</span> <span class="description">this descrpition</span> </li> <li> <span class="title">this title</span> <span class="description">this descrpition</span> </li> </ul> how 2 step process using find , replace?

unit testing - Mock Android Application class for tests using Robolectric in App with Dagger 2 -

i'm complete beginner when comes testing , current task fix issue stops existing tests running. several tests using robolectric failing error message java.util.serviceconfigurationerror: org.robolectric.internal.shadowprovider: provider org.robolectric.shadows not subtype @ java.util.serviceloader.fail(serviceloader.java:239) @ java.util.serviceloader.access$300(serviceloader.java:185) @ java.util.serviceloader$lazyiterator.nextservice(serviceloader.java:376) @ java.util.serviceloader$lazyiterator.next(serviceloader.java:404) @ java.util.serviceloader$1.next(serviceloader.java:480) i read in this github post error can happen if there issues environment configuration. after testing narrow down problem 2 methods in application class , initpicasso , initjobdispatcher , initialize picasso , firebase job running , public class myapplication extends application { private applicationcomponent applicationcomponent; @override public void o

php - Mysql select sum() from another table -

Image
i have tables : table: articles id | title | display | ----------------------------------- 1 | fkekc | 1 | 2 | ldsdf | 1 | 3 | otrld | 0 | 4 | qcrsa | 1 | table: likes id | article_id | | type ---------------------------------------- 1 | 1 | 121 | 1 2 | 1 | 652 | 2 3 | 2 | 12 | 1 4 | 1 | 5 | 3 i want result: article [1] => 778 article [2] => 12 article [3] => 0 article [4] => 0 i use left join between 2 tables return records per likes table. 3 record of article 1 my code: select articles.*,likes.like `articles` left join `likes` on articles.id=likes.article_id display='1' i know must use sum() didn't know how use it with answers find must use this: select articles.*, sum(likes.like) likessum `articles` left join `likes`on articles.id=likes

excel vba - Using VBA to return the Table Name corresponding to a given ActiveCell Selection -

for given activecell in excel how can vba return table name appears in properties grouping becomes visible when table tools design tab activated. example in immediate window: ?activesheet.listobjects(2) table3600 but if select cell (potentially within table) can't seem find property either return selected cell's containing table's name. trying either store return value or state current cell not in table. tia (this seems fundamental yet nowhere) these return name of table of selected cell. if there no table run-time error thrown. selection.listobject.name selection.listobject.displayname you can avoid error using: if not selection.listobject nothing msgbox selection.listobject.name end if ?activesheet.listobjects(2) give name of second table on sheet , throw error if there no second table.

canvas - c++ SDL - Render inside a window's particular area -

i want align game components html game. my sdl_window will have sdl_renderer rendering of components. these components buttons, images , rectangle area like html canvas . i want game rendered inside canvas , because implement "world" , "camera" affect "canvas", while gui around "canvas" rendered independently of camera. how have renderer rendering particular area inside of window? i can't mathematics, because want every texture rendered inside canvas, far point of view, hidden. part of code: sdl_window* gwindow = sdl_createwindow("title", sdl_windowpos_undefined, sdl_windowpos_undefined, 800, 600, sdl_window_shown); sdl_renderer* grenderer = sdl_createrenderer(gwindow, -1, sdl_renderer_accelerated); while (true) { sdl_renderclear(grenderer); render_gui(); // can part render_game_inside_canvas(); // ? sdl_renderpresent(grenderer); } you can glviewport() call th

java - How can I move functions to a separate file in android studio? -

how can move functions separate file in android studio? for example, if following code in mainactivity.java: public class mainactivity extends appcompatactivity { int var1; int var2; int var3 ... protected void onstart() { ... var1 = 102; var2 = 105; var3 = add( var1, var2); ... } public void add ( int var1, int var2 ) { return var1 + var2; } } how can have : mainactivity.java public class mainactivity extends appcompatactivity { int var1; int var2; int var3 ... protected void onstart() { ... var1 = 102; var2 = 105; var3 = add( var1, var2); ... } } functions.java public void add ( int var1, int var2 ) { return var1 + var2; } in "utils.java" public static string getanydata(){ return "anydata"; } called mainactivity (e.g.) utils.getanydata(); but keep in mind utility functions / methods should work t

servlets - Jetty 9 - HttpCompliance.LEGACY -

on jetty 9, trying write handler handle http requests. based on this link need run following code: import org.eclipse.jetty.http.httpcompliance; import org.eclipse.jetty.server.httpconnectionfactory; import org.eclipse.jetty.server.server; public class onehandler { public static void main( string[] args ) throws exception { server server = new server(8080); server.getconnectors()[0].getconnectionfactory(httpconnectionfactory.class).sethttpcompliance(httpcompliance.legacy); server.sethandler(new hellohandler()); server.start(); server.join(); } } however, don't know download: org.eclipse.jetty.http.httpcompliance the httpcompliance class first showed in jetty 9.3.8.v20160314, part of continued cleanup rfc7230 (the http/1.x update obsolete rfc2616) spec, allowing deployments continue limp along using older (looser) rfc2616 spec until such time when no longer have choice use rfc2616 (as rest of web, , interconnected infrastructure has upgrad

node.js - express.js with jade templating engine -

i have project i'm , i'm trying routing correct render jade file, golf.jade. this routing.js file var passport = require('passport'), http = require('http'), routes = require('./routes'), user = require('./routes/user'), game = require('./routes/game'), golf = require('./routes/golf'), webhooks = require('./routes/webhooks'); var mainapp = null; function ensureauthenticated(req, res, next) { if (req.isauthenticated()) return next(); res.set('x-auth-required', 'true'); //res.redirect('/login?returnurl=' + encodeduricomponent(req.originalurl)); res.redirect('/login'); } function ensureadmin(req, res, next) { if (req.user.canplayroleof('admin')) return next(); res.redirect('/'); } function ensureactive(req, res, next) { console.log("ensuring active"); if (req.user.active) return next(); res.redirect("/404")

javascript - Ajax - return result of PHP script to PHP -

probably stupid question - have form allows user submit 1 number. using number, use 3rd party api process request , in return receive array of arrays. i trying request via ajax - submit request via ajax, , have return working. however, don't want parse 2d array returned in javascript - how parse in php? index.php <html> <head> <meta charset="utf-8"> <title></title> <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script type="text/javascript"> $("document").ready(function(){ $(".nd-tracking").submit(function(){ var data = { "action": "test" }; data = $(this).serialize() + "&" + $.param(data); $.ajax({ type: "post", datatype: "json", url: "nd-request.php", //relative or absolute path response.php f

java - Should fragment be standalone? -

i'm writing application in android in main activity contains navigation drawer, switches between few different views (displaying data in various ways). each view fragment. my architecture of choice mvvm - have viewmodels each activity, contain logic of specific view , provide models. views responsible displaying models , handling user interaction. now, i'm wondering, whether fragments should standalone objects or not? in terms: should serve composite views consisting of visual controls , managed main activity? or should have viewmodels on own , whole logic , main activity should handle showing , hiding them? pros of fragments being standalone are: better srr (otherwise i'd have implement logic of fragments in main activity's viewmodel), simpler implementation (activity doesn't have pass models each fragment, possibly switch ing through them check, 1 active) , reusability (i can place fragments next other , work correctly). con didn't see such architect

asynchronous - Django non-blocking save? -

is there's way call save() on model in django, without waiting response db? consider async, though need less, async calls gives callback- dont need here. want - somemodel.objects.bulk_create([list of objects ]) , every 1000 objects, without line blocking code. have no use in these rows in code. i'm looking simple, package celery seems offer way more this.. as of 2016, django web framework working (for moment, if ignoring channels ) taking http request "as argument" , returns http response possible. this architecture means there no concept of asynchronous operation in framework. if want delay saving , returns response user without waiting, can: either run thread/async block (which can tedious database transactions...) ; services ironworker allows queue operations run async a.s.a.p ; celery , may bring features case better job homemade solution.

javascript - Visualizing a parse tree with d3.js -

Image
i've been trying obtain visual representation of parse tree generating html file uses d3.js draw tree. file looks this: <!doctype html> <meta charset="utf-8"> <head><title> tree visualization </title></head> <script src="https://d3js.org/d3.v3.min.js"></script> <script type="text/javascript"> function drawtree(o) { d3.select("#"+o.divid).select("svg").remove() var viz = d3.select("#"+o.divid) .append("svg") .attr("width", o.width) .attr("height", o.height) var vis = viz.append("g") .attr("id","treeg") .attr("transform", "translate("+ o.padding +","+ o.padding +")") var tree = d3.layout.tree() .size([o.width - (2 * o.padding), o.height - (2 * o.padding

php - SQL select items from one table with conditions from another -

i have 2 tables: accounts(id, name, adress, type) holidays(name, startdate, enddate) and type column accounts set("manager","director","administrator") example. the name column both colums relationed. when creates holiday, name table holidays name account logged in. and want know if it's possible make sql statement can take of table 2 the table1.type need "director" , table1.name needs on holidays. select * accounts a, holidays h a.name = h.name , a.type = 'director' this should entries want. it's important link a.name h.name ensure right combination.

java - jOOQ can I fetch a join of two tables into the respective POJOs -

in jooq if want fetch row of table jooq autogenerated pojos do, instance: dsl.selectfrom(user) .where(user.u_email.equal(email)) .fetchoptionalinto(user.class); now, suppose want join between 2 tables, e.g. user , role , how can fetch result pojos these 2 tables? this 1 solution using resultquery.fetchgroups(recordmapper, recordmapper) map<userpojo, list<rolepojo>> result = dsl.select(user.fields()) .select(role.fields()) .from(user) .join(user_to_role).on(user.user_id.eq(user_to_role.user_id)) .join(role).on(role.role_id.eq(user_to_role.role_id)) .where(user.u_email.equal(email)) .fetchgroups( // map records first user table , key pojo type r -> r.into(user).into(userpojo.class), // map records first role table , value pojo type r -> r.into(role).into(rolepojo.class) ); note, if want use left join instead (in case user not have roles, , want empty list per user),

how to fit and score a machine learning models in Java/JVM based application -

could please guide me on how create , execute machine learning models/statistical models (regression, decision tree, k means clustering, naive bayes, scorecard/linear/logistic regression etc. , gbm, glm ) in java/jvm based application (in production). we have etl sort of java based product 1 can of data preparation steps machine learning, data ingestion jdbc, files, hdfs, no sql etc., joins , aggregations etc.(which required feature engineering) , want add analytics capabilities using machine learning/statistical modeling. right now, using jpmml- evaluator score models created in pmml format using r , python (and knime) needs 3 separate , unconnected steps:- 1- first step data preparation in our java/jvm application , save sampling data (training , test) data in csv file or in db, - 2- create machine learning model in r , python (and knime) , export in pmml 4.2 format - 3- import/deploy pmml in our java based application , use jpmml evaluator execute in production. i s

python - Aiohttp, Asyncio: RuntimeError: Event loop is closed -

i have 2 scripts, scraper.py , db_control.py. in scraper.py have this: ... def scrap(category, field, pages, search, use_proxy, proxy_file): ... loop = asyncio.get_event_loop() to_do = [ get_pages(url, params, conngen) url in urls ] wait_coro = asyncio.wait(to_do) res, _ = loop.run_until_complete(wait_coro) ... loop.close() return [ x.result() x in res ] ... and in db_control.py: from scraper import scrap ... while new < 15: data = scrap(category, field, pages, search, use_proxy, proxy_file) ... ... theoretically, scrapper should started unknown-times until enough of data have been obtained. when new not imidiatelly > 15 error occurs: file "/usr/lib/python3.4/asyncio/base_events.py", line 293, in run_until_complete self._check_closed() file "/usr/lib/python3.4/asyncio/base_events.py", line 265, in _check_closed raise runtimeerror('event loop closed') runtimeerror: event loop closed but sc

ios - Delete an action from the NavigationBar -

i have 3 views 3 controllers: homeview -> loginview -> accountview in homeview added navigationbarcontroller . when user logs in in loginview , moved accountview . when clicks on button in navigationbar , sent loginview , problem. after logging if user clicks on button, want show him homeview , not loginview . tried code takes time executed , can see loginview milliseconds. override func viewwillappear(animated: bool) { if let token = userdefaults.valueforkey("token") { //user logged in self.performseguewithidentifier("homesegue", sender: self) } } is there way it? at viewdidapper in accountview, can delete loginview viewcontrollers stack way self.navigationcontroller?.viewcontrollers.removeatindex(1) this way, if user go back, he/she see home page requested

sendgrid - Email "reply-to" is being ignored in favour of "from" -

we have app sends emails on behalf of our clients. emails sent via sendgrid. part of have verified our email sending domains via dkim , spf. when our clients send email, constructed follows: from: tom smith <email-service@ourserver.com> reply-to: tom.smith@email.com this works in vast majority of cases, there situations "reply-to" not being respected - recipients clicking "reply" in email clients , reply coming us. is there missing here. need explicitly set or sender header? or else?

Magento: Minimal quantity diffrent sizes -

i'm making shop clothing. there minimal order amount per order. want have choice customer can make different sizes. so minimal count 10 pieces, , if customer wants 4 size m, 5 size l , 1 size xl. easiest way in code can accomplish this? i'm using simple products associated configurable products. thanks in advance maybe :) how total quantity of items in shopping cart

vb.net - How to get output from PowerShell automation? -

i trying output , post output powershell instance textbox. code: private sub viewservicelogtoolstripmenuitem_click(sender object, e eventargs) handles viewservicelogtoolstripmenuitem.click using ps powershell = powershell.create() dim logfilepathname string = "some path log file" ps.addscript(string.format("get-content {0} -wait", logfilepathname)) dim outputcollection psdatacollection(of psobject) = new psdatacollection(of psobject) addhandler outputcollection.dataadded, addressof logfileoutput dim result iasyncresult = ps.begininvoke(of psobject, psobject)(nothing, outputcollection) end using end sub sub logfileoutput(send object, data dataaddedeventargs) logtextbox.text += data.tostring end sub i unsure if running. placing break point inside logfileoutput handler sub never raised. thanks.

newlines in double quotes in reading CSV in python -

i have csv file in following format: "4931286","lotion","new york","bright color, yellow 5" long 20% nylon" "931286","shampoo","new york","dark, yellow 10" long 20% nylon" "3931286","conditioner","la","bright color, yellow 5" long 50% nylon" the above data should read 3 rows 4 columns: id, product name, location, , description. can seen, there newlines within descriptions each row. i've been searching other related stackoverflow questions none of solutions seem solve issue. here attempt: from stringio import stringio file = stringio("""4931286","lotion","new york","bright color, yellow\n 5" long 20% nylon""") row in csv.reader(file,quotechar='"', delimiter=',',quoting=csv.quote_all, skipinitialspace=true): print row and results following: [

office365 - Internal vs. external Office 365 account for Outlook REST API credentials? -

Image
if register application new unified outlook.com/office 365 rest apis using account tied companies' office 365 instance, users of other office 365 accounts outside organization able use application? are there benefits using organization-controlled account hold these application credentials, instead of random outlook.com account? how did register app? if register on azure portal or using old portal app-registrar, can login app since external account supported azure ad. however, not able call mail rest. to make app compatible outlook.com , office 365 account, need register app using new portal here . , can refer article more detail new authenticate model. seems new portal still in designing , not working mailbox of outlook.com @ present. got error below when login app using microsoft account: and issue have contacted office developer team via uservoice . are there benefits using organization-controlled account hold these application credentials, instead o

r - Update a subset of a df with mutate_each -

i have dplyr dataframe 100k+ rows , ~200 columns. there 15 columns contain date values in excel format (# of days since jan 1, 1900), column names contain date string makes easy subset dataframe. library(dplyr) x <- data.frame(date1 = 45000+ 500*rnorm(100), date2 = 50000+ 500*rnorm(100), var1 = 50 * rnorm(100), var2 = 100 + 20 * rnorm(100)) > x %>% head date1 date2 var1 var2 1 44952.83 49432.88 8.125523 125.95802 2 44331.47 49231.76 -34.814162 117.26881 3 44597.69 49651.91 27.747881 108.45787 4 45113.50 49802.87 24.584569 83.84904 5 46212.14 49972.59 72.444414 80.61595 6 45753.38 50074.57 -34.927552 127.70018 date_cols <- x %>% select(contains('date', ignore.case=t)) %>% names > date_cols [1] "date1" "date2" i'd change these date columns actual r datetimes without changing other columns. can't figure out how update date_cols subset of dataframe: x %>%

python - AttributeError: 'bool' object has no attribute 'count' -

i new python , writing code below. filename = input("enter file name: ") inputfile = open(filename, 'r') text=inputfile.readable() sentences = text.count('.') + text.count('?') + \ text.count(':') + text.count(';') + \ text.count('!') i can't past count function because of error below. have done research , tried importing libraries didn't work. can guide me in right direction? feel lost. text.count(':') + text.count(';') + \ attributeerror: 'bool' object has no attribute 'count' there buggy line in code: text = inputfile.readable() which returns boolean has no attribute count should have been: text = inputfile.read()

c++ - Memory efficient map<pair<int,int>, set<int>> alternative -

i have huge amount (1500 million) of integer pairs each 1 associated document-id. goal search documents have same pair. my first idea use hash-map ( std::map ) using pair values keys , document-ids associated values, i.e. map<pair<int,int>, unordered_set<int>> for example: document1 - pair1: (3, 9) - pair2: (5,13) document2 - pair1: (4234, 13) - pair2: (5,13) map<pair<int,int>, unordered_set<int>> hashmap hashmap[{3, 9}].insert(1) hashmap[{5, 13}].insert(1) hashmap[{4234, 13}].insert(2) hashmap[{5, 13}].insert(2) would result into key(3,9) = documents(1) key(5,13) = documents(1,2) key(4234,13) = documents(2) my problem takes huge amount of memory exceeds available 24 gb of ram. therefore need alternative performance inserts , lookups can fit memory. in theory i'm using 1500 million * 3 (pairval1, pairval2, document-id) * 4 (bytes per integer) = 18gb when overhead costs not taking account. there alternatives problem?

c++ - how to obtain undistorted image without interpolation -

Image
i have been trying lot undistorted image without interpolation. when executed below code weird image.i using function initundistortrectifymap gives mapx , mapy of type cv_16sc2 later using convertmaps function converting mapx , mapy type cv_32fc1.i have been trying debug reason couldnot find helpful. the distorted image image after applying undistort without interpolation int main() { mat cam1matrixparam, cam1distortion; mat cf1; cf1=imread("cam1.distort1.jpg", cv_load_image_color); size imagesize = cf1.size(); filestorage fs1("cameracalibration.xml", filestorage::read); fs1["camera_matrix"] >> cam1matrixparam; fs1["distortion_coefficients"] >> cam1distortion; mat r = mat::eye(3, 3, cv_32f) * 1; int width = cf1.cols; int height = cf1.rows; mat undistorted = mat(height, width, cv_8uc3); mat mapx = mat(height, width, cv_32fc1); mat mapy = mat(height, width, cv_32fc1); initundistortrectifymap(cam1matrixpa

Unable to download pdf blob url on Safari -

currently using filereader open , view pdf works on chrome. however, when pdf opened on safari , click download button, nothing happens. var reader = new filereader(); reader.onloadend = function(e) { $window.location.href = reader.result; } reader.readasdataurl(file); after having spent entire day working on similar issue, understood problem can share knowledge you. basically, kind of problems generated when render blob inside opened browser tab page url changes in like: blob:http://localhost:8080/9bbeffe1-b0e8-485d-a8bd-3ae3ad9a0a51 the wrong procedure requiring pdf this: var fileblob = new blob([response.data], {type: 'application/pdf'}); window.location.hfref = fileblob; why doesn't work? well, can see pdf rendered on page might fooled thinking pdf loaded fine. however, if either try refresh page or download pdf on machine, doesn't work. wth? so, thinking of sort of black magic going around browser, figured out problem: file doesn

css - How to do translate3d type effect for older versions of IE -

on site i'm working on, have css uses translate3d style accordingly. example: style="transform: translate3d(-133px, -8px, 0px);" however, need address in older versions of ie. other ways can done? there way use filters or else make happen? maybe negative margins help: margin-left: -133px; margin-top: -8px; might depend on parent element styles.

c++ - Obtaining quotient with remainder using just arithmetic operators -

i'm starting learn basics of c++ i'm stumbled upon issue. for example, i'm trying convert celcius fahrenheit. assuming, have fixed formula. f = 9/5(c) + 32 i'm aware mathematically possible break down mathematically : (9c/5) + 32 however, i'll not able obtain quotient reminder so how obtain both quotient reminder using arithmetic operators or impossible i tested out still refuses give me correct output #include<iostream> using namespace std; int main(){ double f; int c; cout<<"enter degree celcius:"<<endl; cin>>c; cout<<endl; f = 9/5 * c + 32; //incorrect ways obvious reason f = 9%5 * c + 32; //incorrect ways obvious reason cout<<c<<"degree celcius equals to:"<<f<<endl; } f = 9/5 * c + 32; //incorrect ways obvious reason if knew "obvious reason" why incorrect, wouldn't asking question! it incorrect because calculation integer values. 9

mysql - Trying to connect to server for ruby development -

Image
i'm new ruby , having trouble setting server. i did gems installing , stuff have mysql2 server running can't connect trough local host keep getting error. so i've tried changing default server gem puma don't know webrick recommended , active record database mysql2 error i'll upload server client connections , gemfile , such if helpful. but i'm trying setting server test ruby apps. you should check database.yml , enters connection parameters database. should appears this: # mysql. versions 4.1 , 5.0 recommended. # # install mysql driver # gem install mysql2 # # ensure mysql gem defined in gemfile # gem 'mysql2' # # , sure use new-style password hashing: # http://dev.mysql.com/doc/refman/5.0/en/old-client.html development: adapter: mysql2 encoding: utf8 reconnect: false database: tst_database pool: 5 username: root password: "my_password_on_sql_installation" #socket: /var/run/mysqld/mysqld.sock

angular - How to use expression for (click) event -

in angular2 have multiple buttons , on click set value. possible use expression in click event ie., instead of calling function can set value directly? <button (click)="setvalue(1)">1</button> <button (click)="setvalue(1)">2</button> <button (click)="setvalue(1)">3</button> to thing like <button (click)="{{value=1}}">1</button> <button (click)="{{value=1}}">2</button> <button (click)="{{value=1}}">3</button> you can use expressions don't use {{}} <button (click)="value=1">1</button> angular evaluates value part when attribute name wrapped in [] , () (or both [()] or when value contains {{}} . don't use [] , () {{}} . {{}} stringifies result. if want bind non-string values properties don't use {{}} @ all.

android - Random music player when win in the game -

i make small game , there music when finish. have 1 sound , have 3 or 4 play randomly, hear different music each time finish. have soundmanager.java public static final int sound_winner = 4; public static final int sound_loser = 5; public static final int sound_winner2 = 6; public static final int sound_winner3 = 7; and public static void initsounds(context thecontext) { mcontext = thecontext; msoundpool = new soundpool(10, audiomanager.stream_system, 0); msoundpoolmap = new hashmap<integer, integer>(); loopedsoundmap = new hashmap<integer, integer>(); maudiomanager = (audiomanager)mcontext.getsystemservice(context.audio_service); addsound(sound_winner, r.raw.win); addsound(sound_loser, r.raw.lose); addsound(sound_winner2, r.raw.win2); addsound(sound_winner2, r.raw.win3); in game activity put private void win(){ soundmanager.playloopedsound(soundmanager.sound_winner); thanks in advance advice. i

java - Before loading listview from json url, giving error at onQueryTextChange(),when applying getFilter() -

this question has answer here: what nullpointerexception, , how fix it? 12 answers i new in android development ,i have implemented searchfilter searchview . applied filter listview , giving me correct result. problem that, when listview still loading ...at time if click on search edit text,my app gets crash.... my code: public class cityadapter extends baseadapter implements filterable { valuefilter valuefilter; private arraylist<city> citylist; private arraylist<city> mstringfilterlist; private context context; private layoutinflater layoutinflater; public cityadapter(context context, arraylist<city> citylist) { this.context = context; this.citylist = citylist; mstringfilterlist = citylist; layoutinflater = (layoutinflater) context.getsystemservice(context.layout_inflater_service

html - float right is not working in my case , what should i do? -

Image
hi , show in picture , if use float right , phone image after hamburger icon. what should position phone icon before hamburger icon except using margin way ? <div class="top_nav" style="position:fixed; width=100%;"> <div class="top_nav_menu top_nav_left_log_part"> <a href="index.html" style="padding:auto;"> <img id="img_nav_left_png" src="img/fujitsu.svg" alt="" style="height:80px; width=83px;padding-top:17px;padding-bottom:23px;"> </a> </div> <div id="top_nav_menu_middle_id" class="top_nav_menu top_nav_menu_middle"> <ul class="top_nav_ul"> <li class="top_nav_li nav_menu"><a href="services.html" data-toggle="tooltip" data-placement="left" title="database migration , consulting services">