Posts

Showing posts from September, 2012

c# - How can i create a filter by with Linq? -

Image
my mvc view displays following i perform filtering linq based on user selection can display filtered results only. my controller var products = db.products.asqueryable(); public class filterpageviewmodel { public int?[] man { get; set; } public int?[] size { get; set; } public int?[] color { get; set; } public decimal? minprice { get; set; } public decimal? maxprice { get; set; } public sorting sorting {get ; set; } public order order {get; set; } } public actionresult index(int? categoryid = 0, int? page = 0, filterpageviewmodel model = null) { //manufacturer ############################################# if (model.man != null) { foreach (int? in model.man) { if (i.hasvalue) { //do here } } } //size ###################################################### if (model.size != null) {

c++ - How can I optimise this to run in an efficient manner? -

the link question follows: http://codeforces.com/problemset/problem/478/c you have r red, g green , b blue balloons. decorate single table banquet need 3 balloons. 3 balloons attached table shouldn't have same color. maximum number t of tables can decorated if know number of balloons of each color? your task write program given values r, g , b find maximum number t of tables, can decorated in required manner. input: single line contains 3 integers r, g , b (0 ≤ r, g, b ≤ 2·10^9) — number of red, green , blue baloons respectively. numbers separated 1 space. output: print single integer t — maximum number of tables can decorated in required manner. so, did was, in greedy manner, searched maximum , minimum value each time , subtracted 2 , 1 respectively if possible. here code: int main (void) { int ans=0,r,g,b; cin>>r>>g>>b; while (1) { int a1 = maxfind(r,g,b); int a2 = minfind(r,g,b); //ans++; if (a1 &g

javascript - Remove the first character of the first index of an array? -

question: how remove first character of first index of array. var arr = ['/a','b','c','r']; i output var arr = ['a','b','c','r']; use below code arr[0] = arr[0].substr(1);

Why does Chrome on iOS 8.4 say indexedDB is null? Safari has it -

on ios 8.4 (ipad air), able use indexeddb in safari, in chrome, says it's null. instead has websql. why case? there way indexeddb on chrome ios or not added? (it's odd returns null , not undefined ). //returns null console.log( window.indexeddb ); console.log( window.webkitindexeddb ); //returns undefined console.log( window.mozindexeddb ); console.log( window.oindexeddb ); console.log( window.msindexeddb ); it because chrome uses webview , not new wkwebview new in ios8. ios webview doesn't support indexeddb (and readonly there polyfills enable indexeddb on websql don't work) you can find more info on chrome issue tracker here: https://code.google.com/p/chromium/issues/detail?id=423444

Introduce branching to existing project best practice for TFS 2013 -

we have tfs 2013, team project working don't have branches, plain folder structure various solutions in them. with goal introduce release management, intention create several branche, e.g. development/main/releases as told cannot 'disturb' project team developers day day work since there other projects being worked on, question, best practice this? create separate team project? how can adopt branching practice without asking developers. please point direction or share thought on this, appreciated!! unfortunately you'll have "disturb" development team. have 2 options. 1. come process in isolation , disturb them when goes live. 2. collaborate them on process , work meet requirements. (being able release code production key requirement project, sadly it's obvious never gets added backlog / project plan , treated afterthought) i recommend option 2. without collaboration you're going end causing resentment you're imposing on devs ,

windows - Formating output from bat file -

wmic product name,version > "c:\myinformation.txt" echo. >> "c:\myinformation.txt" echo %username% >> "c:\myinformation.txt" i'm trying write batch file generate software installed on users computer username id purposes. code above works individually. however, when try write out file, †਍敨瑣牯洮牡楴敮⁺਍ instead of " john.doe " my question is, how can software dump wmic followed username without spitting out garbage. i've flipped order of commands. doing results in getting username not software, in neat output ways. creating 2 files not want do. i'd 1 file per user. thanks in advance. use /append:"myfile.txt" output wmic in file. i.e. echo. >"c:\myinformation.txt" wmic /append:"c:\myinformation.txt" product name,version >nul echo. >> "c:\myinformation.txt" echo %username% >> "c:\myinformation.txt"

sql server - SSRS truncating parameter -

Image
i have ssrs report populates parameter stored procedure. query works expected. when parameter used in running report, parameter being truncated. choose value abcd, report returns values abc. stored procedure passing parameter runs in ssms , returns abcd data. when test query in query designer or run report, abc data. how ssrs pass in entire parameter? parameters strings without set length. there's nothing truncate values. have checked values make sure value , label same? the label see (abcd) while value passed in parameter. don't know if problem if works on local machine though. if doesn't work can try deleting parameter , recreating - shouldn't work has before.

c++ - Create borderless DirectShow Window -

i referring simple video player using directshow example provided here . the code runs , builds need make video player window borderless. i not find parameter set in cocreateinstance function or coinitialize function can set make window borderless. here complete code reference: #include <dshow.h> #pragma comment (lib, "strmiids.lib") void main(void) { igraphbuilder *pgraph = null; imediacontrol *pcontrol = null; imediaevent *pevent = null; // initialize com library. hresult hr = coinitialize(null); if (failed(hr)) { printf("error - not initialize com library"); return; } // create filter graph manager , query interfaces. hr = cocreateinstance(clsid_filtergraph, null, clsctx_inproc_server, iid_igraphbuilder, (void **)&pgraph); if (failed(hr)) { printf("error - not create filter graph manager."); return; } hr = pgraph->queryinterfac

How to enable button at the end of viewpager in Android? -

i new in android. trying implement button in front view @ end of view pager. button stay hidden while sliding images , button visible if @ end of viewpager.. how correct? i tried position of images , inserted if statement button visible it's not working. please me... public class guestactivity extends activity { viewpager viewpagerguest; mypageradapter mypageradapter; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.guestactivity); viewpagerguest = (viewpager)findviewbyid(r.id.myviewpager); mypageradapter = new mypageradapter(); viewpagerguest.setadapter(mypageradapter); } private class mypageradapter extends pageradapter { int numberofpages = 5; int[] res = { r.drawable.meme1, r.drawable.meme2, r.drawable.meme4, r.drawable.meme3, r.drawable.meme5 }; int[] backgroundcolor = { 0xff101010,

bash - how to run linux commands after logging into to a gateway controlled device -

i brand new linux/bash scripting , trying write script run commands on device connected gateway machine. script being run on gateway machine , device connected requires authentication. 1) ssh root@xyz 2) cd /mnt/abc/xyz 3) play command 1) runs , asks password , logs device, stops here , not run 2) , 3). how fix this? i suggest setting passwordless login. http://www.linuxproblem.org/art_9.html after that, put commands file commands.sh in root's home directory: #!/bin/bash cd /mnt/abc/xyz play command then make file executable running command in bash: chmod 750 commands.sh finally, can run remotely command ssh root@xyz ./commands.sh

api - How to get number of Instagram followers on a specified date like minter.io does? -

Image
from picture, can see how followers statistics looks on minter.io the way how imagine count followers change: download list of followers every day instagram api db. , after having history can calculate change. but on minter.io can have such graphics after few minutes after registration... how??? they storing information on daily basis , hence able keep historical trend. if go minter.io website, mention @ bottom have collected data close 198 million accounts. guess 1 of those. you don't need list of followers show absolute change in numbers. instagram api gives directly when query of endpoints giving user information.

c++ by using argc and argv read the text file -

////////// new update!!!!! ////////// .txt have 15 numbers , last number "15" 1. try count how many(save index) of numbers in .txt file. 2. create dynamic array size index. 3. save number dynamic array. question: how cover char dynamic array int dynamic array. i got garbage output in terminal: open sucessues!! index: 15 buffer: 15 0 1073741824 0 1073741824 2136670223 32767 -1680479188 32767 0 0 0 0 0 0 0 int main(int argc, char* argv[]) { char *nptr = argv[1]; char *buffer = new char[5]; int index = 0; ifstream fin(nptr); //open file if (argc > 1){ // allocate memory if(!fin){ cout << "can't read file!!" << endl; return -1; } if(fin){ cout << "open sucessues!! " << endl; } while (!fin.eof()){ fin >> buffer; index++; //counting here!!! } cout << "index: " << index << endl; //print out counting results! cout << "buffer: " << buffer <&l

sql - Average with group by -

trying calculate average number of books borrowed per member. member( memb no , name, age) book( isbn , title, authors, publisher) borrowed( memb no, isbn , date) bold - primary key italic - foreign key can here me out? in advance to number of distinct books borrowed each member, do select membno, count(*) totalborrowed borrowed group membno to total members, do select count(distinct membno) totalmembers borrowed to average books borrowed, should combine results. multiply 1.0 result in decimal. select 1.0 * sum(totalborrowed)/count (distinct b.membno) avg_per_member (select membno, count(*) totalborrowed borrowed group membno) t join borrowed b on t.membno = b.membno

wordpress - WP_List_Table error in Gravity Forms -

after updating wordpress latest version error whenever try add new confirmation or notification: function wp_list_table::get_columns() must over-ridden in sub-class. i can try add new ones they're not saved , when go notifications/confirmations pages see error there. i tried editing notification.php recommended in post found, fixes problem notifications tab. still can't add new confirmations. any help? in advance! i found same issue , how resolve (answer sunwukong): in notification.php, in class gfnotificationtable extends wp_list_table { ... add method: function get_columns() { $columns = array( 'name' => 'name', 'subject' => 'subject' ); return $columns; }

text processing - R Cleaning and reordering names/serial numbers in data frame -

let's have data frame follows in r: data <- data.frame("serialnum" = character(), "year" = integer(), "name" = character(), stringsasfactors = f) data[1,] <- c("983\n837\n424\n ", 2015, "michael\nlewis\npaul\n ") data[2,] <- c("123\n456\n789\n136", 2014, "elaine\njerry\ngeorge\nkramer") data[3,] <- c("987\n654\n321\n975\n ", 2010, "john\npaul\ngeorge\nringo\nna") data[4,] <- c("424\n983\n837", 2015, "paul\nmichael\nlewis") data[5,] <- c("456\n789\n123\n136", 2014, "jerry\ngeorge\nelaine\nkramer") what want following: split each string of names , each string of serial numbers own vectors (or list of string vectors). eliminate character "na" in either set of vectors or blank spaces denoted "...\n " . reorder each list of names alphabetically , reorder corresponding serial numbers according same perm

c++11 - Declare 'virtual' constructor for base and derived class in c++? -

maybe trivial problem: have base class b has constructor many (6+) arguments (and it's not stable maybe change in future). , there many derived classes inherit has same constructor signature, , of them nothing more base one. so problem is: there way declare 1 time in base , no need declare in derived classes? normal virtual function. i'm using c++11. you can inherit base class constructors: struct base { base(int, float, void*, bool, std::nullptr_t, std::size_t) { /* ... */ } }; struct derived : base { using base::base; }; derived d(0,0.0f, nullptr, false, nullptr, 0);

algorithm - Matrix Multiplication using different classes - Java -

i have assignment class have create matrix multiplication program. here's condition: implement 2 types of algorithms multiplying 2 n × n matrices. assume n power of 2: the straight-forward o(n^3) matrix multiplication algorithm. strassen’s matrix multiplication algorithm. evaluate different algorithms, , write short report. create test matrices different values of n (4, 10, 20,100). generate matrices using random numbers. compute running time of algorithms. report should include running times , conclusions. here's code far: public class matrixmultiplication { public static void main(string[] args) { random rand = new random(); int rows = rand.nextint(7) + 2; int columns = rand.nextint(7) + 2; system.out.println("the matrix has " + rows + " randomized rows"); system.out.println("the matrix has " + columns + " randomized column"); system.out.println(); double[][]

How to take backup of MySQL database in Bluemix? -

i using ibm bluemix mysql database db server, don't know how take backup it. in past used cf tunneling option, new cf tool doesn't support cf tunnel. some services, experimental mysql service on bluemix not able accessed outside of bluemix. can access them within bluemix cloud foundry application. if using service , need deploy phpmyadmin application , bind database perform management operations. if using other mysql services cleardb, see jeff's answer

Can not share data between controllers AngularJs -

hi i`m new in angularjs. index.html file http://clip2net.com/s/3oknpg6 <!doctype html> <html ng-app="app"> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.15/angular-ui-router.min.js"></script> <meta charset="utf-8"> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>angular route</title> <link rel="stylesheet" href="css/style.css"> <link rel="author" href="humans.txt"> <script src="angular.js"></script> <script src="node_modules/angular-ui-router/release/angular-ui-rout

c++ - Getting the file-mode from the FILE struct? -

i have piece of c code, function specific, operates on file* . depending on mode file* opened there things can , cannot do. is there way can obtain mode file* opened with? that file* info can rely on, because created somewhere else in program , actual file-name long lost before reaches function, , cannot influence. i prefer portable solution. edit: i'm not interested in file-restrictions specifying users can file. irrelevant dealt upon file-opening. bit of code care open-mode. on posix (and sufficiently similar) systems, fcntl(fileno(f), f_getfl) return mode/flags open file in form passed open (not fopen ). check whether opened read-only, read-write, or write-only, can like: int mode = fcntl(fileno(f), f_getfl); switch (mode & o_accmode) { case o_rdonly: ... case o_wronly: ... case o_rdwr: ... } you can check flags o_append , etc.

c++ - Topcoder Div 2 algorithm -

hi trying solve topcoder problem incompletebst given here: http://community.topcoder.com/stat?c=problem_statement&pm=6713&rd=9999 my approach : first validate if input bst 1. number associated current node 2. keep dividing 2 until quotient appears in input list quotient parent/ancestor of current node 3. check if current node left/right child of ancestor isvalidchild() function this. i) converts both of numbers binary representation ii) 0 in binary rep indicates left child , 1 indicates right child iii) @ point of difference in binary rep check if next el 0 (left) or right(1) iv) if left associated character should <= cur,else > cur 4) if bst getthevalues() the code given below class incompletebst { public: vector<int> binaryrep(unsigned long long num) { cout<<"\nbinart rep start\n"; vector<int> vbinary; while(num > 0) { vbinary.inser

cordova-plugin-dialogs prevent "click" outside -

i using cordova-plugin-dialogs plugin mobile app. dialog can displayed via this: $cordovadialogs.confirm('we not reach server. please try again.', 'network problem', ['cancel','retry']) .then(function(buttonindex) { if(buttonindex==2){ checknetwork(); }else{ navigator.app.exitapp(); } }); it works, problem when user "click" outside dialog, dialog disappear , trigger result of 0 , app exit. how can disable ability "click" outside of dialog? the plugin works way, you'll have fork plugin, change behaviour , install fork instead of official plugin. there few lines allows cancel dialog when press outside, you'll have change them from dlg.setcancelable(true); to dlg.setcancelable(false);

symfony - Doctrine 2: Not all entities get persisted, why? -

Image
i'm trying persist feedback entities in loop. problem is, 1 entity doesn't persisted (no matter how many entities want persist @ all; it's n-1 instead of n). to understand following code snippet have know survey entity can contain several feedback entities (1..n relation). let's if $feedbackcount = 10 9 feedback entities persisted database. @ end of post can see according doctrine unit of work. shows 10 feedback entities added to survey (so loop working right) 9 feedback entities listet @ end. any ideas guys? here's code: for ($count = 0; $count < $feedbackcount; $count++) { $feedback = new feedback(); $feedback->setfeedback("no feedback yet"); $feedback->setsurvey($survey); // add feedback survey $survey->addfeedback($feedback); // persist feedback $entitymanager->persist($survey); // persist($feedback) has same effect } // end

c# - Unity: Special movement for game -

Image
i'm writing movement space game , spaceship object (player) mouse cursor. currently have following code: using unityengine; using system.collections; using unityengine.eventsystems; public class move : monobehaviour { public float speed = 1.5f; public float rotationspeed = 90f; public float rotprecision = 0.1f; public float moveprecision = 0.1f; private vector3 pos; private quaternion qto; void start () { pos = transform.position; qto = transform.rotation; } void update () { if (!eventsystem.current.ispointerovergameobject()) { if (input.getmousebuttondown(0) || input.getmousebutton(0)) { pos = input.mouseposition; pos.z = transform.position.z - camera.main.transform.position.z; pos = camera.main.screentoworldpoint(pos); } var dir = pos - transform.position; qto = quaternion.lookrotation(vector3

webpack - Laravel Mix not recognising trailing comments eg "/*!".... Vue.js -

$ npm run dev works fine but $ npm run production, although been working months, not recognise "/*!" @ end of compiled javascript lines comment out code eg /*! <- line not being recognised * vue.js v2.4.2 * (c) 2014-2017 evan * released under mit license. */ this line @ end of compiled line. can fixed manually returning new line, how can mix automate again? error = fallbackloader option has been deprecated - replace "fallback" loader option has been deprecated - replace "use" 10% building modules 7/19 modules 12 active ...ode_modules/style-loader/addstyles.js(node:11800) deprecationwarning: loaderutils.parsequery() received non-string value can problematic, see https://github.com/webpack/loader-utils/issues/56 tried: $ rm rf node_modules && npm clear cache && npm install using node v7.5.0 npm v4.1.2 package.json { devdependencies mix ^0.6.0, "babel-core": "^6.23.1", "babel-loader

python - Upgrading django from 1.9 to 1.11: reverse accessor clash -

models.py: class societe(models.model): ... class client(societe): ... class meta(societe.meta): proxy = true class fournisseur(societe): ... class meta(societe.meta): proxy = true class commande(models.model): client = models.foreignkey(client, related_name='commandes') fournisseur = models.foreignkey(fournisseur, related_name='commandes') this works in django 1.9, in 1.11, error: commande.client: (fields.e304) reverse accessor 'commande.client' clashes reverse accessor 'commande.fournisseur'. commande.client: (fields.e305) reverse query name 'commande.client' clashes reverse query name 'commande.fournisseur'. commande.fournisseur: (fields.e304) reverse accessor 'commande.fournisseur' clashes reverse accessor 'commande.client'. commande.fournisseur: (fields.e305) reverse query name 'commande.fournisseur' clashes reverse query name 'commande.client'.

cocoa - Does Foundation use Core Foundation? -

to me doesn't seem it. of course don't have sources of foundation, in case of gnustep, take example. they have nsarray code https://github.com/gnustep/libs-base/blob/master/source/nsarray.m nowhere in source refer cfarray. https://github.com/gnustep/libs-corebase/blob/master/source/cfarray.c same goes cf counterparts. why? gnustep not same apple's foundation. don't know how gnustep implemented, in apple's foundation, ns , cf counterparts closely linked indeed. say, don't have source foundation, there still many ways detect integration between two. 1 easy-to-spot 1 inspect class of many foundation objects: nsmutablestring *string = @"foo".mutablecopy; nslog(@"%@", nsstringfromclass(string.class)); this little program outputs __nscfstring , clue cfstring 's implementation indeed being used under hood. specifically, nsstring , cfstring (as nsarray , cfarray , nsdictionary , cfdictionary , , many other foundation

javascript - GSAP repeatDelay Array? -

so i'm spending little bit of free time learning , exploring gsap (greensock animation platform). , i'm wondering if possible have array of values 1 specific repeating element. how tween looks; tweenmax.from(blink, 0.2, {repeat: -1, scale: 0, ease: power1.easeinout, repeatdelay: 3}); now i'm wondering if it's possible have element "blink", have 3 second pause, blink again , have 0.5 second pause before blinking again, , repeat. i've looked @ documentation can't seem find relevant, can gsap or have step out js? thanks! sure, create 2 tweens in timeline 3 seconds apart, , repeat whole timeline , set repeatdelay 0.5. effect wanted?: https://codepen.io/greensock/pen/a99e84eaba6f2e358801bbf02ffcf41d?editors=0010 var tl = new timelinemax({repeat:-1, repeatdelay:0.5}); tl.from("#blink", 0.2, {scale:0, ease:power1.easeinout}) .to("#blink", 0.2, {scale:0, ease:power1.easeinout}, "+=3"); there forums dedica

ios - Spotify SDK Missing token refresh service? -

i trying void popup grant permission user every time session expired in spotify sdk , after 1 hour maybe popup appear grant permission again user can play tracks spotify on app , error getting when try renew session : [player][play][spotify] error renew session optional(error domain=com.spotify.auth code=0 "missing token refresh service." userinfo={nslocalizeddescription=missing token refresh service.}) [player][spotify] session not renewed,popup login and here how trying renew session : //renew session func renewsession(completion:@escaping (bool)->()) { print("[player][play][spotify] renew session requested ") let auth = sptauth.defaultinstance() auth?.renewsession(auth?.session, callback: { (error, session) in if (error != nil) { print("[player][play][spotify] error renew session \(string(describing: error))") completion(false) return }

login - PHP Password_verify always returns false no matter what? -

i creating login , registration system in php. using php's password_hash , password_verify functions in same class. every time try , check password returns false. my sql password row set text. here user class creating , logging users in. <?php /** * */ class user { private $pdo; function __construct() { # code... } public function newuser($username, $email, $password) { global $pdo; //check if username taken $checkusername = $this->checkusername($username); if (!$checkusername) { $checkemail = $this->checkemail($email); if (!$checkemail) { $hashpass = password_hash($password, password_default); if ($hashpass) { $upload = $pdo->prepare("insert users (username, password, email) values (:username, :password, :email)"); $upload->execute(array(":username"=>$username, ":pas

xml - How to force child element to have a value in XSD? -

i have xml (as example) segment called type within segment order . segment 1 many, have : <order> <type>1</type> <type>2</type> <type>3</type> </order> now validation should be, there should segment type value 1 in segment order , if not, validation error should occur. tried validations, not correct result. has thought on how implement , if possible? xsd 1.0 your constraint cannot expressed in xsd 1.0. xsd 1.1 your constraint can expressed in xsd 1.1 using assertion state there @ least 1 type child of order has value of 1 : <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema" xmlns:vc="http://www.w3.org/2007/xmlschema-versioning" vc:minversion="1.1"> <xs:element name="order"> <xs:complextype> <xs:sequence> <xs:element name="

javascript - FormData add file doesn't work -

i have form: <form enctype="multipart/form-data" action="" method="post" id="sendinvoiceform"> <input type="text" value="some text"> <input name="file[]" type="file" multiple/> <input type="button" id="upload" value="upload file" /> </form> my js: $('#upload').click(function(e) { e.preventdefault(); var formdata = new formdata(); formdata.append('files',$("#sendinvoiceform")[0]); $.ajax({ url: 'upload.php', type: 'post', xhr: function() { var myxhr = $.ajaxsettings.xhr(); return myxhr; }, success: function (data) { }, data: formdata, cache: false, contentt

java - Schedule a job to run at multiple of 2 seconds i.e 2,4,8,16,32 seconds -

i want schedule job run @ multiple of 2 seconds, 2,4,8,16,32 seconds. second fire should happen after 2 seconds of completion of first fire, third fire should happen after 4 seconds of completion of second fire , on. next fire based on status previous fire, based on decided whether need trigger next fire or not. can tell me how can use quartz scheduler achieve this? if use simpletrigger.withintervalinseconds(2) runs job after every 2 seconds want time interval should increased multiple of 2 in every firing. of course have read documentation you have track job fire sequence (first fire, second fire,etc) , previous job execution status. refer documentation examples answer there imho.

web - JavaScript and HTML5 local storage for trivial customization in order not to ruin cache -

https://youtu.be/gbt4uxtskfy?t=540 video: "django under massive loads - christophe pettus - pyconar 2012". starting @ 9:00. the lecturer said 1 of worst things ever happened performance point of view on web putting someone's last name @ upper right corner. it's static page. nothing changes. name breaks staticness of page. and lecturer suggests use javascript , html5 local storage such trivial customization adding username page. i've tried find more information on technique. failed. could tell me read this. i'd find chewed on in article. give me kick here?

Change -Xmx and Xms settings for EAP on Openshift -

i'm trying change default settings openshift eap images (by default container starts jvm -xms1303m -xmx1303m). i've tried adding settings java_opts_append, not effective. can see it's being appended @ end of java_opts, inspecting jvm process, can see defaults still being used. idea ? thanks setting jvm resource limits through java_opts_append won't work. have set resource limits container. example, settings resource limits 1gb, allow portion of used application server mx , ms limits (typically half of resource limits container need dedicate resource limits os)

python - How to give default argument if starred expression is empty -

i have function call tkinter optionmenu , looks this: tk.optionmenu(container, targetvar, *list(accountmap)) accountmap dictionary of values i'd appear in optionmenu , in scenarios may dictionary empty, meaning starred expression doesn't return arguments, , function call optionmenu complains not enough arguments have been given. how can add default value of empty string if starred expression returns nothing? *(accountmap or [""]) the list redundant.

linux - shell script concatenate with space two string -

i’ve shell script need provide following pattern in txt file test0000 test0000@gmail.com test0001 test0001@gmail.com and on until stop condition (10 in case...) currently not working , tried following: start=“test” email=“@gmail.com" start=0 stop=10 i=0 while [[ $i -le 10 ]] printf "%s%10d\n" "$start” "$i" "\n" "$start” "$email" any idea how resolve ? got error: "@gmail.com:" invalid number you can use: start='test' email='@gmail.com' ((i=0; i<10; i++)); printf '%s%04d %s%04d%s\n' "$start" $i "$start" $i "$email" done test0000 test0000@gmail.com test0001 test0001@gmail.com test0002 test0002@gmail.com test0003 test0003@gmail.com test0004 test0004@gmail.com test0005 test0005@gmail.com test0006 test0006@gmail.com test0007 test0007@gmail.com test0008 test0008@gmail.com test0009 test0009@gmail.com

ruby on rails - gem swagger-docs not generating apropriate json files to be displayed on swagger-ui -

swagger-ui not displaying docs , o dont know why. i'm using swagger-docs gem, generated api-docs.json, created route access index.html of swagger-ui, passed parameter path of api-docs.json result that: swagger-ui index.html could me? config/initializers/swagger-docs.rb swagger::docs::config.base_api_controller = actioncontroller::api swagger::docs::config.register_apis({ "1.0" => { # extension used api :api_extension_type => :json, # location our api doc files generated, of store files under public directory :api_file_path => "public/docs", # base path url of our application # while using production mode, point production url :base_path => "http://localhost:3000", # setting option true tells swagger clean files generated in api_file_path directory before files generated :clean_directory => true, # using rails-api, our applicationcontroller inherits actioncontroller::api instead of ac

Using ssh to remotely execute command Python -

i'm new python , cannot solve reason code not working . i'm trying connect several servers hostname list on file via ssh(using paramiko). something weird happens,the code working if there 1 hostname in file, if has more that, not working . clear loop working fine. hope can assist me, in advance ! the code: import sys import os import paramiko client=paramiko.sshclient() client.set_missing_host_key_policy(paramiko.autoaddpolicy()) username='yadayada' password='ladida' ipfile=open("c:\users\garmiza\documents\scripts\traptohpsimlinuxiplist.txt","r") line in iter(ipfile): print "sending trap " + line client.connect(line,username=username,password=password) command="snmptrap -v 1 -c public 16.19.203.96 enterprises.232 {clientip} 6 11003 0".format(clientip=line) stdin, stdout, stderr = client.exec_command(command) ipfile.close() the errors: file "c:/users/zaza/pycharmprojects/linuxtra

c++ - Declaring constants or using numbers inside the code -

so, have c++ test , teacher hard on declaring constants instead of using numbers directly in code. in example below have declared 0 constant. is unnecessary or thing do? way take more memory or make code "slower"? int main() { int kmstart, kmend; const int 0 = 0; cout << "starting kms? "; cin >> kmstart; cout << "ending kms? "; cin >> kmend; while (kmstart < 0 || kmstart > kmend) { cout << "invalid input!" << endl << endl; cout << "starting kms? "; cin >> kmstart; cout << "ending kms? "; cin >> kmend; } } constexpr int 0 = 0; compiled out. note new keyword constexpr , c++11 onwards. for current code, zero may compiled out, if isn't degradation in performance negligible cf. input / output functions. i wonder why teacher regards zero clearer 0 . knows

Error while trying to run PHP script from Python -

Image
i have wamp installed on windows pc. have python script has following code, supposed run php script located in www of wamp (c:\wamp64\www) import subprocess subprocess.call("php c:\wamp64\www\index.php") i tried below did not work also import subprocess subprocess.call("c:\wamp64\bin\php\php5.6.31\php.exe c:\wamp64\www\index.php") however, when run python code ipython following error. (see image) add full path of php subprocess.call("c:/wamp64/bin/php/php5.6.31 c:/wamp64/www/index.php") or add php environment variables. open cmd , type: set path=%path%;c:\wamp64\bin\php\php5.6.31

excel - Multiple values in cells for slicer -

is possible slicer differentiate between sort of seperater delimiter able pick out instances in cell. for example if have table this id name 1 peter, hans 2 hans 3 peter the slicer have peter , hans selectors. if click peter, should show rows id 1 , 3.

android - How to properly use Dagger 2 to callback from adapter to activity/fragment? -

i'm talking new architecture presented on last google io. now have next implementation: public class thumbnailsadapterviewmodel extends viewmodel { mutablelivedata<thumbnailselected> thumbnailselectedmutablelivedata = new mutablelivedata<>(); @inject public thumbnailsadapterviewmodel() { } public livedata<thumbnailselected> getselectedthumbnail() { return thumbnailselectedmutablelivedata; } public void setthumbnailselected(thumbnailselected thumbnailselected) { thumbnailselectedmutablelivedata.setvalue(thumbnailselected); } } myfragment: @inject thumbnailsadapter thumbnailsadapter; // oncreateview thumbnailsadapterviewmodel thumbnailsadapterviewmodel = viewmodelproviders.of(this, viewmodelfactory).get(thumbnailsadapterviewmodel.class); thumbnailsadapterviewmodel.getselectedthumbnail().observe(this, new observer<thumbnailselected>() { @override public void oncha

Convert all JSON values to string in java -

i've got large number of json documents. i'm writing program in java. need convert values in json documents string. in following example: {"product":{ "name":"flipper", "industry":"real estate", "description":"discovers correlations , trending criteria.", "somearray": ["bla1", "bla2", "bla3"], "productspecs":{"spec1":"somespec1", "spec2":"someotherspec2"}, "arrayofobjects":[{"test1": "a1", "test2":"a2"}, {"mooi1": "b1", "mooi2":"b2"}] }, "name":"harry", "aninteger": 2, "adouble": 3.2, "anotherarray":["la1", "la2"]}` aninteger , adouble should converted. however, have large variety of js

bufferedreader - readline stuck while getting respond from server java -

i have code login smtp.gmail.com using sslsocket send email have problem when try content response server,it stuck in while loop(i guess) bufferedreader.hope can me.i trying type "ehlo smtp.gmail.com" , server response stuck after then.thanks lot.this code : ` package mailclient; import com.sun.prism.pixelformat; import java.io.bufferedreader; import java.io.bufferedwriter; import java.io.ioexception; import java.io.inputstream; import java.io.inputstreamreader; import java.io.outputstreamwriter; import java.io.printwriter; import java.net.socket; import java.util.scanner; import java.util.logging.level; import java.util.logging.logger; import javax.net.ssl.sslsocket; import javax.net.ssl.sslsocketfactory; import javax.xml.bind.datatypeconverter; public class mailclient { public static void main(string[] args){ scanner scan = new scanner(system.in); // todo code application logic here sslsocketfactory sslsocket = (sslsocketfactory)sslsocketfactory.get

hive - Spark HiveContext : Insert Overwrite the same table it is read from -

i want apply scd1 , scd2 using pyspark in hivecontext. in approach, reading incremental data , target table. after reading, joining them upsert approach. doing registertemptable on source dataframes. trying write final dataset target table , facing issue insert overwrite not possible in table read from. please suggest solution this. not want write intermediate data physical table , read again. is there property or way store final data set without keeping dependency on table read from. way, might possible overwrite table. please suggest. you should never overwrite table reading. can result in between data corruption , complete data loss in case of failure. it important point out correctly implemented scd2 shouldn't never overwrite whole table , can implemented (mostly) append operation. far aware scd1 cannot efficiently implemented without mutable storage, therefore not fit spark.

linux - How to insert noatime in /etc/fstab CentOS 7? -

this /etc/fstab file: proc /proc proc defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 tmpfs /dev/shm tmpfs defaults 0 0 sysfs /sys sysfs defaults 0 0 /dev/md/0 none swap sw 0 0 /dev/md/1 /boot ext3 defaults 0 0 /dev/md/2 / ext4 usrjquota=quota.user,jqfmt=vfsv0 0 0 how enable noatime? not know insert string. think is: /dev/md/1 /boot ext3 defaults,noatime 0 0 that´s right? or in dev/md/2? many thanks. yes, work. makes more sense delete defaults placeholder when add it: /dev/md/1 /boot ext3 noatime 0 0 you care more adding mount option slash, though: /dev/md/2 / ext4 usrjquota=quota.user,jqfmt=vfsv0,noatime 0 0

php - Compare arrays of urls and remove from one array urls depend on second array -

i need 1 think should do. have 2 arrays urls example: $urls = ['https://test.com/', 'http://example.com/', 'https://google.com/']; $urlsfromothersource = ['https://test.com/', 'https://example.com/', 'https://facebook.com/']; i need create 3 arrays of urls there. first of them have common urls both arrays. 2 others same if in 2 initials array have same url difference in http - https need assignet url 1 array. so example 2 arrays need arrays in following way: $commonurls = ['https://test.com/']; //becouse have url in 2 arrays $urls = ['http://example.com/', 'https://google.com/']; //'http://example.com/ leave in array url , remove second table becouse in second array have same- difference in https $urlsfromothersource = ['https://facebook.com/']; //remove array https://example.com/ becouse url in first array- difference in http i tried think how can compare arrays , catch differe