Posts

Showing posts from August, 2011

c# - How to get Json data in web service without xml and string? -

i'm using angularjs need output data in json format. have tried web service given below getting data database. in wen service i'm getting output xml , string. need without xml , string. here code: [webmethod] public string getdatetimeformats() { datatable dt = new datatable(); string strquery = null; strquery = "sql query"; using (system.data.sqlclient.sqlconnection conn = new system.data.sqlclient.sqlconnection()) { conn.connectionstring = system.configuration.configurationmanager.appsettings["constr"]; using (system.data.sqlclient.sqlcommand cmd = new system.data.sqlclient.sqlcommand()) { cmd.commandtext = strquery; cmd.connection = conn; conn.open(); sqldataadapter da = new sqldataadapter(cmd); da.fill(dt); system.web.script.serialization.javascriptserializer serializer

java - How to read stream (messages) from TCP in Spring Inegration -

i can't understand how read tcp stream in spring integration. have external service broadcasts data clients connected (tcp, java socket). i've tried many configurations within spring integration. application connects external service (i can confirm service's logs), still can't catch stream. however, when manually send message service (through messagechannel), beans work correctly. mean configuration configured catch write events. not find explicit guides or manuals configuring receiving tcp stream. have xml configuration in project: <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:int-ip="http://www.springframework.org/schema/integration/ip" xmlns:int="http://www.springframework.org/schema/integration" xsi:schemalocation="http://www.springframework.org/sche

elasticsearch - Extract the words used by a fuzzy query -

i use fuzzy query in elasticsearch , works fine. for example, if search dogs , _source had word dog correct document, don't know word dog used result. if _source had 10 000 words, how can find query found dog ? have idea find words scored result ? i find solution adding : "highlight": { "fields" : { "myfields" : {} } i find exact position of hits

Inserting a Slide Zoom in PowerPoint 2016 using vba -

powerpoint 2016 has neat new feature can insert zoom slides/sections. see here if don't know i'm talking about: https://support.office.com/en-us/article/use-zoom-for-powerpoint-to-bring-your-presentation-to-life-9d6c58cd-2125-4d29-86b1-0097c7dc47d7 i'm trying automate process since use feature 20-30 times per presentation. visibility, workflow want automate following: take screenshot of application/screen insert new, blank slide in powerpoint paste screenshot in slide , adjust size/position hide new slide insert screenshot-slide slide zoom in slide i've got steps 1-4 in vba macro already, can't figure out if there's vba command insert slide zoom. fear since feature new 2016 it's not in vba yet. anyone knows vba command line automate step 5 above? thanks in advance! vincent there doesn't seem in object model (at least seen vba) this. shapes , shaperanges have hassectionzoom property, returns false, shapes have been inserted

TCP-IP Connection Android App to C# Server -

so im trying comunicate dmx-interface pluged pc/host via xamarin android app. allready got server running, works console client wrote first. wrote app,using same way before, tcpclient , writing data via stream. because i'm running app in emulator use ip 10.0.2.2 connect, cannot establish connection. app crashes or timeout exeption. been trying , researching 2 days , i'm desperate, attach code here, hope can help thanks, johannes app: public class mainactivity : activity { public stream stream; tcpclient client = null; protected override void oncreate(bundle bundle) { base.oncreate(bundle); setcontentview(resource.layout.main); //adding control elements resource.layout.main button @ = findviewbyid<button>(resource.id.at); button enter = findviewbyid<button>(resource.id.enter); button thru = findviewbyid<button>(resource.id.thru); button = findviewbyid<button>(resource.id.al

Why does perl treat the string "0" as false? -

this question has answer here: why '0' false in perl? 6 answers i found in text string '0' equivalent 0 , hence condition false in perl. but when looked @ ascii table '0' ascii 48. why perl consider string '0' value 0 in control structure ? if ('0'){ print "statement1 \n"; } else { print "statement2\n"; } because specified so. the number 0, strings '0' , '', empty list "()", , "undef" false in boolean context. other values true. negation of true value "!" or "not" returns special false value. when evaluated string treated '', number, treated 0. that's specification. behavior conforms. as why specification written -- perl makes practice of implicitly converting between strings

php - Gravity Forms Dynamic Population Woocommerce -

i using gravity forms on wordpress woocommerce product page allowing customers customize products, , pull data external database populate fields on form. dropdown populates these 2 options show in sample code, issue pricing not working @ all. shows dropdown options no pricing. the documentation on website shows array has price field: https://www.gravityhelp.com/documentation/article/dynamically-populating-drop-down-fields/ any or insight on appreciated! code testing: add_filter('gform_pre_render_1', 'populate_posts'); function populate_posts($form){ foreach($form['fields'] &$field){ if($field['type'] != 'select' || strpos($field['cssclass'], 'populate-posts') === false) continue; $choices = array(array('text' => 'test1', 'value' => 'test1','price'=>'0.00')); $choices[] = array('text' => 'test2', 'value' =>

javascript - Deep Freeze any type -

is enough deep freeze kind of type? function freeze(obj) { if (typeof obj === 'object') { reflect.ownkeys(obj).foreach((key) => {freeze(obj[key])}); } return object.freeze(obj); } no. unfortunately, javascript still doesn't have way that. example, date instances cannot frozen: var dt = new date(2016, 11, 27); console.log(dt.getdate()); // 27 object.freeze(dt); dt.setdate(dt.getdate() + 1); console.log(dt.getdate()); // 28 some other issues/notes: as matías said , functions objects, typeof give "function" them. reflect.ownkeys gives object's own keys, not keys prototypes. depending on definition of "deep freeze," may need copy inherited properties object before freezing it.

javascript - In angular, how can I use ng-if for the containing tag only without the trailing markup -

let's have 2 html elements same tag, each different set of properties. how can conditionally choose between them? i have following 2 tags: <a ui-sref="root.one(::{param: value})"> <a target="_blank" href="{{::model}}"> i need conditionally choose 1 of them, , add other markup until closing tag. can work? <a ng-if="::condition" ui-sref="root.one(::{param: value})"> <a ng-else target="_blank" href="{{::model}}"> <div> more nodes </div> </a> at end figured impossible, resorted merging tags this: <a ng-attr-target="{{::!condition? '_blank' : undefined}}" href="{{::model}}" ng-attr-ui-sref="{{::(condition? 'root.one(::{param: value})' : '.')}}"> remarks: when condition met, ng-attr-target expression set undefined target attribute not inserted @ all. apparently, if set _self messes a

sandbox - Opening a link inside iframe inside the iframe and preventing it from exiting the page -

i have iframe tag loads outside url onto page. have found out of urls somehow redirect whole page own. after reading discussion here used sandbox this: <iframe url='$outsideurl' sandbox=''></iframe> the sandbox tag solved problem redirecting page disabled clicking links inside outside urls. again reading discussions here changed iframe this: <iframe url='$outsideurl' sandbox="allow-popups"></iframe> now problem redirecting solved , can click on link inside when click on link inside iframe jumps out of page , goes link. there way upon clicking link opens inside iframe? it's ok if answer "no", @ least realize not search anyfurther.

node.js - How to await and return the result of a http.request(), so that multiple requests run serially? -

assume there function dorequest(options) , supposed perform http request , uses http.request() that. if dorequest() called in loop, want next request made after previous finished (serial execution, 1 after another). in order not mess callbacks , promises, want use async/await pattern (transpiled babel.js run node 6+). however, unclear me, how wait response object further processing , how return result of dorequest() : var dorequest = async function (options) { var req = await http.request(options); // need "await" here somehow? req.on('response', res => { console.log('response received'); return res.statuscode; }); req.end(); // make request, returns boolean // return result here?! }; if run current code using mocha using various options http requests, of requests made simultaneously seems. fail, because dorequest() not return anything: describe('requests', function() { var t = [ /* re

android - GPS icon disappear when open location popup or the app is killed -

i developing app should send gps data server once every 10 minutes. problem when kill app when gps on, gps icon disappear status bar (while gps still on) , data not sent anymore. if same google maps app icon doesn't disappear. can explain me why happening? here code use alarmmanager /** * alarm_manager_gps_time_interval = 10 min */ pendingintent mpendingintent = pendingintent .getservice( context, pending_intent_request_code_for_gps, new intent(context, gpsdataservice.class), pendingintent.flag_immutable); alarmmanager malarmmanager = (alarmmanager) context.getsystemservice(context.alarm_service); malarmmanager.setinexactrepeating( alarmmanager.elapsed_realtime_wakeup, systemclock.elapsedrealtime(), alarm_manager_gps_time_interval, mpendingintent); service public class gpsdataservice extends service implements googleap

javascript - Using $onChanges vs $onInit in angular component -

is there difference between using controller1 vs controller2 ? angular.module('app', []) .component('foo', { templateurl: 'foo.html', bindings: { user: '<', }, controller: controller1, //or controller2 }); function controller1(){ this.$oninit = function(){ this.user = angular.copy(this.user); }; this.$onchanges = function(changes){ if(changes.user && !changes.user.isfirstchange()){ this.user = angular.copy(changes.user.currentvalue); } }; } function controller2(){ this.$onchanges = function(changes){ if(changes.user){ this.user = angular.copy(changes.user.currentvalue); } }; } why should bother $oninit when can same in $onchanges , save rows? is type of initialization better in $onchanges , $oninit better other kind of initialization?

Can we define PHP session variables in one place? -

can define php session variables in 1 place inside function or variable can use across application? like this: $abc=$_session['my_session']; $abc['name']='john'; please read on references in php basic question. //ensure my_session exists , array $_session['my_session'] = isset($_session['my_session']) ? $_session['my_session'] : array(); //assign reference $abc = &$_session['my_session']; $abc['name'] = 'john'; note $abc available in current scope, use inside function you'll have use global keyword. that's bit "dirty" should use functions instead of this.

python - Incorrect placement of token in 2D grid -

i'm making treasure hunt game on changeable 8 x 8, 10 x 10 or 12 x 12 grid part of assignment school , need help. whenever make move on grid doesn't move desired position. can me or explain me why doesn't work? the code below have far. def makemove(): global board, numberofmoves, tokenboard, playerscore, tokenboard playercoords = getplayerposition() currentrow = playercoords[0] #sets var playercoords[0] currentcol = playercoords[1] #sets var playercoords[1] directionud = input("up/down?") #sets var input of "up/down?" movement_col = int(input("how many places?")) if directionud == "u": #checks if var equals "u" newcol = currentcol - movement_col print (newcol) elif directionud =="d": #checks if var equals "d" newcol = currentcol + movement_col directionlr = input("left/right?") #sets var input of "up/down?" movement_row = int(i

xcode - Using OpenCV to detect ecllipse -

trying use opencv in xcode detect ellipse of image: cvmemstorage *storage2 = cvcreatememstorage(0); cvseq *contours = cvcreateseq(0, sizeof(cvseq), sizeof(cvpoint), storage2); iplimage *th = cvcreateimage(imgsize, 8, 1); cvthreshold(mask, th, 0.1, 255, cv_thresh_binary_inv ); cvfindcontours(th, storage2, &contours, sizeof(cvcontour), cv_retr_list, cv_chain_approx_none, cvpoint(0, 0)); cvdrawcontours(th, contours, cv_rgb(0,255,0), cv_rgb(0,0,255), 2, 3, 8, cvpoint(0, 0)); cv::vector<cv::rotatedrect> minrect(contours->total); cv::vector<cv::rotatedrect> minellipse(contours->total); for( int = 0; < contours->total ; i++ ) { minrect[i] = cvminarearect2(&contours[i]); } i'm using example provided in opencv documentation. when try run code, error: error: (-5) input array not valid matrix in function cvpointseqfrommat for line: minrect[i] = cvminarearect2(&contours[i]); i'm new opencv appreciate help!!

xml - XSLT Transform doesn't work until I remove root node -

i'm trying extract headline below xml met office web service using xslt, xslt select returns blank. source: <regionalfcst xmlns="www.metoffice.gov.uk/xml/metoregionalfcst" createdon="2016-01-13t02:14:39" issuedat="2016-01-13t04:00:00" regionid="se"> <fcstperiods> <period id="day1to2"> <paragraph title="headline:">frosty start. bright or sunny day.</paragraph> <paragraph title="today:">a clear , frosty start in west, cloudier in kent isolated showers. dry sunny periods. increasing cloud in west later bring coastal showers freshening southerly winds. chilly inland, less cold near coasts. maximum temperature 8c.</paragraph> </period> </fcstperiods> </regionalfcst> my xslt: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform&qu

sapui5 - Object Page with blocks -

i've got objectpagelayout: request.view.xml <objectpagelayout> <headertitle> ... </headertitle> <headercontent> ... </headercontent> <sections> <objectpagesection mode="collapsed"> <subsections> <objectpagesubsection title="fooblock"> <blocks> <blockdetail:formblock columnlayout="auto" /> <!-- block --> </blocks> </objectpagesubsection> </subsections> </objectpagesection> </sections> </objectpagelayout> formblockcollapsed.view.xml (my block) <mvc:view xmlns:f="sap.ui.layout.form" xmlns:mvc="sap.ui.core.mvc" xmlns:core="sap.ui.core" x

ASP.NET Identity Bearer Token vs JWT Pros and Cons -

i have used asp.net identity while , have been looking @ jwt (json web token) seem interesting , easy use. jwt.io has great example/tool of debugging token. however, i'm not entirely sure how jwt's work on end, still use identity? also how tokens (bearer vs jwt) compare? more secure? jwts ticket attraction. contains security information server needs embedded in it. once server has handed out client needs present whenever asks , server responds accordingly if it's valid. the contents entirely viewable, they're signed using secret key server can tell if they've been tampered with. since in jwt, , client can present whomever want, can use single sign on long different servers share same secret can verify signature. like ticket, jwt has expiry date. long hasn't expired, it's valid. means can't revoke them before that. reason jwts have short expiry times (30 mins or so) , client issued refresh token in order renew jwt when expires.

1D vector from lower part of diagonal in matrix [Python] -

Image
i struggeling pretty easy thing unfortunatelly cannot solve it. have matrix 64x64 elements can see on image. reds zeros , greens values interested in. i end lower triangular part under diagonal (green values) 1 array. i use python 2.7 thank lot, michael assuming can pull data numpy array, use tril_indices function. looks data doesn't include main diagonal can shift -1 data = np.arange(4096).reshape(64, 64) inds = np.tril_indices(64, -1) vals = data[inds]

sql server - Unable to add performance counters of `.NET Data Provider for Oracle` -

in server, using sqlclient connect sql server, using oledb old apps connecting oracle , odp.net new apps new apps connecting oracle. seeing in perf counters, .net data provider oracle .net data provider sql server odp.net managed but can able add , see counters of .net data provider sql server , odp.net . .net data provider oracle (i mean) system.data.oledb not working. from here https://www.pcreview.co.uk/threads/monitoring-oledbconnection-pool.1245649/ the oledb provider not expose performance counters. is right?

android - Viewpager inside RecyclerView Inside a fragment -

i have set of fragments. each fragment contains recyclerview , and recyclerview has viewpager first row. now in set of fragments when switch 1 fragment app crashing following exception log it logcat e/uncaughtexception: java.lang.illegalargumentexception: no view found id 0x7f1000ef (:id/viewpagerbanners) fragment mainbannerfragmentnew{a1564b5 #0 id=0x7f1000ef} @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1293) @ android.support.v4.app.fragmentmanagerimpl.movefragmenttoexpectedstate(fragmentmanager.java:1528) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1595) @ android.support.v4.app.fragmentmanagerimpl.dispatchactivitycreated(fragmentmanager.java:2888) @ android.support.v4.app.fragment.performactivitycreated(fragment.java:2204) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1326) @ android.support.v4.app.fragmentmanagerimpl.movefragmenttoexpectedstate(fragmentmanager.java:1528) @

android - MultiAutoCompleteTextView doesn't accept blank spaces -

my problem when suggest sentences in multiautocompletetextview , when press spacebar, suggestions disappear. example: suggested words: the rock ball thermal if write "the", sentences displayed, if write "the " (with blank space) suggestions dismissed. want if write "the ", elements "the rock" , "the ball" displayed in suggested words. thanks. have @ post: https://groups.google.com/forum/#!topic/android-developers/orsn2xrpdma ran similar problem , wrote simple multi word derivation. defaults "," separator can set whatever using "setseparator" method. or stack-overflow answer might helpful cause experiences same problem: autocompletetextview backed cursorloader

java - Is it Possible generate flash light according to binary code at smartphone? -

i feedback or advise expert me. have done project before , find out issue, try best solve still cant work :( in short, use android studio generate random() code , convert binary, let said "0101101101011011" , want phone flash according binary code. 0= off flash 1=on flash. realize phone can work phone cannot work, , android version compile 4.0.3 . install apps @ above 4.0.3 version phone. is hardware limitation? or suggestion ? advise , suggestion ~

sql server - Create table variable from pivot results -

is possible create table variable pivot results? my pivot query: select @query = 'select user_key, ' + @coldepsummary + ' causde_tas pivot ( sum(usde_hsu) depa_key in (' + @coldepartments + ') ) pivot_locations usde_dat >= ''' + format(@ddatefrom, 'mm.dd.yyyy') + ''' , usde_dat <= ''' + format(@ddateto, 'mm.dd.yyyy') + ''' , user_key in (' + @users_str + ') group user_key' @coldepsummary , @coldepartments dynamically generated , looking (there around 70 columns): @coldepsummary: sum([120000003]),sum([120000002]),sum([140000001]),sum([120000005]), ... @coldepartments: [120000003],[120000002],[140000001],[120000005], ... main reason why want create table variable pivot table

c - What is the __builtin_expect() prototype? -

to rid of static code analysis warning (qa-c), need provide function prototype __builtin_expect() . i using windriver diab compiler powerpc. in compiler manual have found following information: __builtin_expect(long exp, long c) : ... exp return value. so, prototype follows: long __builtin_expect(long exp, long c); however, not compile, getting following error: error (dcc:1701): invalid types on prototype intrinsic __builtin_expect - when intrinsic enabled, optional user prototype must match it seems prototype not correct. correct prototype __builtin_expect ? the error message states user prototype optional. should possible define it, right? you need somehow define __builtin_expect make static analyzer happy, because doesn't know function is. need use #ifdef disable definition when compiling program normally, because compiler not if try define compiler builtins yourself. builtins come compiler not supposed defined in program. something

apache - Firebase Storage Downloadurl Custom Domain -

a part of firebase app serve pdf files on firebase storage users. when open files bucket downloadurl visible users example: https://firebasestorage.googleapis.com/v0/b/my-project/o/file.pdf?alt=media&token=5btfzb29-f3cf-4557-8741-bfd3f12b1e86i want serve files under: https://custumdomain.com/file.pdf?alt=media&token=5btfzb29-f3cf-4557-8741-bfd3f12b1e86i since couldn't find option in firebase console or cloud storage achieve this, tried set .htaccess redirect. tried: rewriteengine on rewriterule ^(.*)$ https://firebasestorage.googleapis/$1 [p] requested document shown, user visibly redirected. question divided 2 parts: 1. right way achieve goal? there easier solution provided cloud storage? 2. why proxy flag not working intended? need change hide redirect?

c++ - I'm getting invalid conversion from char to const char error.How to fix this program? -

i'm getting error in few lines , don't know how program work. beginer programmer here. appreciated. #include <iostream> #include <cstring> using namespace std; char* find_greater(char* a, char b) { char* result; if (strcmp(a, b) > 0) result = a; else result = b; return result; } int main() { char str1[10], str2[10]; str1[] = "zebra"; str2[] = "man"; cout << "greater string :" << find_greater(str1, str2) << endl; return 0; } two problems . a silly typo: char* find_greater(char* a, char* b) // ^ pay more attention you're doing, , read code. parse error here: char str1[10], str2[10]; str1[] = "zebra"; str2[] = "man"; you can't assign string literals arrays and, if could, str1[] not thing. special case can initialise ( only ) that, so: char str1[10] = "zebra", str2[

What does this hospital mean with the following OAuth requirements? -

we've got hospital customer wants have app developed. app make use of various ways of validation, of oauth2 one. have list of requirements, of 1 kind of puzzles me: for every user session, app needs generate unpredictable "state parameter". app needs validate "state value" every request sent redirect url; "state" needs recorded authorization requests; , "state value" has validated access token receives. although don't mention guess talks oauth. i've got experience oauth2. know access tokens , refresh tokens are. story above head. kind of "state parameter" , "state value" talking about? could shed light on story? this state parameter oauth 2.0 has defined in authorization request recommended parameter ( https://tools.ietf.org/html/rfc6749#section-4.1.1 ) used protected against cross-site request forgery , correlate requests , responses in general: state recommended. opa

spring - active objects java.lang.RuntimeException: Failed to lazily initialize a collection - no session or session was closed -

i trying implement @onetomany relationship using active objects my entities , service classes below package jp.co.kodnet.confluence.plugins.bookdirectory.rest; entity import java.util.date; import net.java.ao.onetomany; import net.java.ao.preload; /** * * @author kod */ @preload public interface crossreference extends entity { void setbookkey(string bookkey); string getbookkey(); void setbookname(string bookname); string getbookname(); void setspacekey(string spacekey); string getspacekey(); void setspacename(string spacename); string getspacename(); void setpageid(long pageid); long getpageid(); void setlastmodifieddate(date lastmodifieddate); date getlastmodifieddate(); void setcodenumcount(integer codenumcount); integer getcodenumcount(); @onetomany codeelements[] getcodeelements(); @onetomany spanelements[] getspanelements();

C/C++ "inline" keyword in CUDA device-side code -

i total "newbie", when comes cuda. if question trivial, pardon me. does nvcc understands meaning of inline c keyword? know __forceinline__ , , similar nvcc "macros", therefor not asking how write inline cuda device-side code. know also, code "split" between nvcc , c/c++ compiler (i using visual studio ide). mean inline keyword ignored nvcc when "stands next to" __device__ or __global__ kernels? edit: p.s. had searched cuda programing guide. not find useful under inline entry, similar "tags" not either. cuda programming language in c++ family. therefore, cuda documentation not duplicate standard c++ documentation, merely points out differences , extensions. if can't find description of use of inline specifier functions in cuda documentation, indication processed in standard c++ fashion. interpolating between various parts of questions, seems concerned how use of inline affects actual inlining of funct

linux - Python3 root sudo venv -

i running python3.5 on ubuntu via ssh , have errors there. don't why. if run following commands respective errors: (venv) root@servername: python3 __init__.py file " __init__.py ", line 1 , in <module> import flask importerror: no module named 'flask' if run sudo this, error: (venv) root@servername: sudo python3 __init__.py file " __init__.py ", line 2 , in <module> .content_management import content systemerror: parent module '' not loaded, cannot perform relative import and if run firefox, cause flask app, website works , shows no errors! whats going on here??? going crazy this!! seems didn't install flask module on machine run python script. produces importerror get. install flask module e.g. using pip : $ pip install flask after you've done so, python should able load module.

javascript - SVG image not aligning on zoom with leaflets -

i have below code display svg file on base map. not retaining portion on zoom , transform being added every zoom causes svg move further away position. i have co-ordinates svg json. function update() { feature.attr("transform", function(d) { return "translate("+ (map.latlngtolayerpoint(d.latlng).x) +","+ (map.latlngtolayerpoint(d.latlng).y) +")"; } ); }

amp html - AMP - Install multiple event handlers for tap -

is there way install multiple events tap? e.g. on tap close sidebar , open lightbox? thanks. there doesn't appear way chain actions. you try; <button on="tap:my-lb.open" on="tap:sidebar1.close">test</button> or <button on="tap:my-lb.open,sidebar1.close">test</button>

boolean logic - circuits using karnaugh's map technique -

Image
a combinational circuit designed counts number of occurrences of 1 bits in 4 bit input. however, input 1111 invalid input circuit , output in such case 00. one valid input such circuit may 1110 output 11; valid input may 1010 output 10. draw truth table circuit. use karnaugh map design circuit , draw using and,or , not gates. because 4bit input can have @ 4 ones in it, can encode output 3bit long binary number. the truth-table this: w x y z y_2 y_1 y_0 ---------+------------- number of positive bits 0 0 0 0 | 0 0 0 ~ 0 0 0 0 1 | 0 0 1 ~ 1 0 0 1 0 | 0 0 1 ~ 1 0 0 1 1 | 0 1 0 ~ 2 ---------+------------- 0 1 0 0 | 0 0 1 ~ 1 0 1 0 1 | 0 1 0 ~ 2 0 1 1 0 | 0 1 0 ~ 2 0 1 1 1 | 0 1 1 ~ 3 ---------+------------- 1 0 0 0 | 0 0 1 ~ 1 1 0 0 1 | 0 1 0 ~ 2 1 0 1 0 | 0 1 0 ~ 2 1 0 1 1 | 0 1 1 ~ 3 ---------+------------- 1 1 0 0 | 0 1 0 ~ 2 1 1 0 1 | 0 1 1 ~ 3 1 1

mongodb - mongo aggregation query in golang with mgo driver -

i have following query in mongodb - db.devices.aggregate({ $match: {userid: "v73tuqqzykbxfxswo", state: true}}, { $project: { userid: 1, categoryslug: 1, weight: { $cond: [ {"$or": [ {$eq: ["$categoryslug", "air_fryer"] }, {$eq: ["$categoryslug", "iron"] } ] }, 0, 1] } } }, {$sort: {weight: 1}}, { $limit : 10 } ); i'm trying write in golang using mgo driver not able wrap head around @ all! how translate golang mgo query? the examples on docs sufficient started. however, if not familiar golang, $cond part bit tricky. see below example code: collection := session.db("dbname").c("devices") stage_match := bson.m{"$match":bson.m{"userid":"v73tuqqzykbxfxswo", "state": true}} condition_weight := []interface{}{bson.m{"$or": []bson.m{

php - UPS Shipping module not working on Linux environment -

i using free ups carrier module in project built on prestashop , module working fine on localhost(windows-xampp) when going on server(red hat linux) prestashop not connect ups webservices. seems wrong server connection. i checked server error log files , not find share here. please guide me. actually there no error code just used curl instead of using stream_context_create , worked !

opencv - volleyball court ball tracking, court stitching -

Image
i have question school project. given task of tracking volleyball given beach volleyball match video in mov format. task track ball , output whole volleyball court in birds eye view, , draw ball movement. currently, im still doing ball tracking. however, not know how exactly. have thought of doing in way: get 4 corners of volleyball court using harris corner detectors use 4 corners find homography between different frames then remove background , player finally can track ball??? is thought process correct? and have tried detect 4 corners using harriscorner detector. not 4 corners. 1 has suggestions? thank you

Change Pycharm default directory / folder -

i've installed pycharm community edition in windows pc. want change default directory projects. c:\users\myuser\pycharmprojects\untitled want e:\pycharmprojects\my project name thanks, daniel this issue duplicate of can change location/name of pycharmprojects? but answer not mentioned there is: make sure pycharm closed navigate c:\users\myname.pycharm50\config\options\recentprojectdirectories.xml (note: read page figure out these settings on different os's: https://www.jetbrains.com/pycharm/help/project-and-ide-settings.html ) modify <option name="lastprojectlocation" value="d:\dropbox\learning\fullstack\python" /> and set value= whatever desired folder is save file, open pycharm. (via http://makguidetosoft.blogspot.com/2016/01/pycharm-change-default-project-folder.html )

php - How to reset data mapper's virtual fields in Fat Free Framework? -

let's start example given on fff user guide . there database table: create table products ( productid varchar(30), description varchar(255), supplierid varchar(30), unitprice decimal(10,2), quantity int, primary key(productid) ); and have data mapper virtual field: $item=new db\sql\mapper($db,'products'); $item->totalprice='unitprice*quantity'; let's have performed queries , used virtual field. now remove virtual field, because don't need further requests , don't want overload data base useless calculations. possible? the requirement remove 'property' 'object instance'. the 'standard way' 'models' implemented in php 'framework', 'orm' etc. implement them can accessed using 'array syntax'. another approach implement of magic methods such __unset . i.e. when call unset($item->property); code run maintain correctly. to flexible implement bo

maven - Generate a pom as an artifact -

i work on project, multiple workstreams generate quite lot of wars. said wars uploaded artifactory. we're in process of splitting configuration management java product, , i'm trying work out way generate pom on fly, contains dependencies of precisely wars use deploy product. pom uploaded product itself, artifactory other war or jar project produces, , downloaded using gav coordinate. said pom downloaded @ deploy time deploy script, , more or less directly used download , deploy wars our internal repo our target machine. i'm looking elegant way produce pom in target directory contains reference wars produced multi module project.

javascript - Three JS object load, put a color to an object -

i'm trying put color object in 3 js. tried alot of different things didnt work. var objectloader = new three.objectloader(); objectloader.load("hoesje/hoesje.json", function ( object ) { scene.add( object ); }); i hope can me out, thanks. var loader = new three.objloader(); loader.addeventlistener( 'load', function ( event ) { var object = event.content; object.traverse( function ( child ) { if ( child instanceof three.mesh ) child.material.color.setrgb (1, 0, 0); }); scene.add( object ); }); loader.load( 'hoes.obj' ); but error : typeerror: loader.addeventlistener not function var loader = new three.objloader(); loader.load( 'load', function ( event ) { var object = event.content; object.traverse( function ( child ) { if ( child instanceof three.mesh ) child.material.color.setrgb (1, 0, 0); }); scene.add( object ); }); loader.load( 'hoes.obj' ); i d

C# ASP.NET equivalent of Classic ASP Server.CreateObject().Exists() -

i've been tasked converting classic asp application asp.net mvc5 application, i'm bit stuck finding equivalent of server.createobject().exists() c# asp.net. classic asp: set coursedirectory = server.createobject("scripting.dictionary") if not (coursedirectory.exists(clashkey)) , not (coursedirectory.exists(altclashkey)) '... end if c# equivalent far: object coursedirectory = new object(); coursedirectory = httpcontext.current.server.createobject("scripting.dictionary"); //problem here if (!(coursedirectory.exists())... what have in order achieve same thing in c# asp.net? isn't normal dictionary? how about: var coursedirectory = new dictionary<string, object>()

macros - scala - insert value into quasiquote -

unfortunately, intuitive way, val world = "earth" val tree = q"""println("hello $world")""" results in error:(16, 36) don't know how unquote here val tree = q"""println("hello $world")""" ^ because $ within quasiquotes expects tree . val world = "earth" val tree = q"""println(${c.literal(s"hello $world")})""" works, ugly , intellij warning c.literal deprecated , should use quasiquotes, instead. so ... how do this? update in response flavian's comment: import scala.language.experimental.macros import scala.reflect.macros._ object testmacros { def dotest() = macro impl def impl(c: blackbox.context)(): c.expr[unit] = { import c.universe._ //access ast classes /* val world = "earth" val tree = q"""println(${c.literal(s"hello $world")})"

arrays - Processing - How to log Strings in txt file? -

im getting more , more frustrated on why not doing want to. need have text file logs last 10 buttons user pressed, tried in 2 ways but… …this code saves last button pressed: string [][] buttonspressed = { {"pressed one"}, {"pressed two"} }; string[] sum; void setup() { size(700, 350); sum = loadstrings("scores.txt"); } void draw() { } void keypressed() { if ((key=='1')) { savestrings("scores.txt", buttonspressed[0]); } if ((key=='2')) { savestrings("scores.txt", buttonspressed[1]); } if ((key == enter)) { printarray(sum); } } …this code saves buttons pressed overwrites when run sketch again (probably has createwriter): printwriter sum; void setup() { size(700, 350); sum = createwriter("scores.txt"); } void draw() { } void keypressed() { if ((key=='1')) { sum.println("pressed one"); } if ((key=='2')) { sum.println(&q