Posts

Showing posts from September, 2010

sql server unique key for each partition -

i have table contain 3 columns: id int [primary key] branchref int [foreign key] code int i need [code] unique in each [branchref] like: id branchref code 1 1 1 2 1 2 3 2 1 4 2 2 5 1 3 i appreciate help add unique constraint. alter table mytable add constraint unique(branchref, code);

hadoop - Able to create Hive table using JSON objects but not all objects are being captured into respective attribute -

i able create hive table using json objects not objects being captured respective attribute. few absorbed 1 attribute. how break out remaining attributes respective "columns". most of below fields put table screen_name, name , location grouped number of other objects retweeted_status , user. retweeted_status , user appear long json string needs broken out table. need perform activity below, , if so, how that? appreciated. thanks, here script, create table bank_f001 (json string); load data local inpath 'banking-1-26-16.txt' table bank_f001; create table bank_f001_table select get_json_object(bank_f001.json, '$.text') text, get_json_object(bank_f001.json, '$.in_reply_to_user_id') in_reply_to_user_id, get_json_object(bank_f001.json, '$.id') id, get_json_object(bank_f001.json, '$.favorite_count') favorite_count, get_json_object(bank_f001.json, '$.coordinates') coordinates, get_json_object(bank...

Animation of Circle angle rotation using MATLAB -

i have circle , partition circle 3 sector(120 angle each).now want increase angle 50 degree 1 part , decrease 50 degree part , keep constant third part (like 170 degree first part,70 degree second , 120 degree third).i want make animation whole process using matlab. how can this? if have source code process using matlab, helps me much. i draw circle , divide 3 equal sectors , polt points circle.here, attached following code: x0=2; y0=1; r=1; teta=-pi:0.01:pi; x=r*cos(teta)+x0 y=r*sin(teta)+y0 plot(x,y) hold on scatter(x0,y0,'or') axis square %---------------------------------------- % divide circle n sectors n=3 tet=linspace(-pi,pi,n+1) xi=r*cos(tet)+x0 yi=r*sin(tet)+y0 k=1:numel(xi) plot([x0 xi(k)],[y0 yi(k)]) hold on p1=[1.5,0.4]; p2=[2,0.8]; p3=[2.5,0.2]; p4=[2.5,1]; p5=[1.5,1.6]; p6=[1.5,0.8]; p7=[2,1.2]; p8=[2,1.4]; p9=[1....

c# - Allow different parameters in action delegate -

i trying declare action-delegate allows set functions different paremeter. here minimal example: have different void function this: private void function1(string parameter) { ... } private void function2(int parameter) { ... } i want pass these functions in same constructor. not possible in way. main { aclass = new aclass(function1); aclass b = new aclass(function2); } how need define action (object not working) - don't want overload consturcor! public class aclass { public aclass(action<???> function) { ... } } thank helping me! typically either this: public class aclass<t> { public aclass(action<t> function) { ... } } ...or overload constructor. if have else in mind need provide more code show want do.

Retrieving Facebook User Details with PHP SDK -

i have application uses scope=email, publish_actions, publish_stream authorizes user email, among other details. problem cannot retrieve in way, no matter code use... have been stuck on over 4 hours. php sdk 3.2.2 version , yet examples comes not work. have in mind apps made last year (april 2012) not work either. has changed in graph api use? this example.php not work either // user id $user = $facebook->getuser(); // may or may not have data based on whether user logged in. // // if have $user id here, means know user logged // facebook, don't know if access token valid. access // token invalid if user logged out of facebook. if ($user) { try { // proceed knowing have logged in user who's authenticated. $user_profile = $facebook->api('/me'); $user_profile['name'] , $user_profile['email'] not return anything...

c# - FileSystemWatcher IncludeSubdirectories not working on network share -

i'm attempting watch network share folders file added share indicate upload complete. wanted use filesystemwatcher monitor share , subdirectories trigger file, shown below. filesystemwatcher fsw = new filesystemwatcher(share, triggerfilepattern); fsw.includesubdirectories = true; fsw.created += new filesystemeventhandler(oncreated); fsw.renamed += new renamedeventhandler(onrenamed); fsw.error += new erroreventhandler(onerror); if file created @ root of share, event triggers. if file created within subdirectory of share, event not trigger, , don't error either. if create new filesystemwatcher subdirectory, receive event when file created there. but, similar top level filesystemwatcher, won't events files created in further subdirectories. if change network share local directory testing, work expected. any ideas? have set wonky network share setting blocks recursive filesystemwatcher checks? can work around this, nice not have complicate code. edit: saw didn...

java - Code just finishes without thoroughly processing -

this beginner error new java , programming in general. anyways, thought placement of system.exit(0) in code, when switched elsewhere there error i'm sure it's right. code ask first joptionpane.showinputdialog. when enter yes response, code finishes processing , nothing else. causing code end instead of processing dice event? import javax.swing.joptionpane; /** fishing class simulates game of fishing. */ public class fishing { public static void main(string[] args) { string input = joptionpane.showinputdialog("would play round " + "of fishing? enter yes or no?"); while (input == "yes") { int score = 0; // sets player's score 0 int points = 0; // holds player's points final int die_sides = 6; // # of sides die //create instance of die class die die = new die(die_sides); //roll die once ,...

arrays - Java: Please explain this code in detail for me. -

this question related post: https://stackoverflow.com/a/35810542/5888956 basically, have write program reads in integer keyboard, , has able display 50! using array. (cannot use biginteger or anything) got far, previous post. import java.util.scanner; class factorial { public static void main(string[] args) { int n; scanner kb = new scanner(system.in); system.out.println("enter n"); n = kb.nextint(); int [] result = fact(n); int = result.length-1; while (i > 0 && result[i] == 0) { i--; } system.out.print(n + "! = "); while (i >= 0) { system.out.print(result[i--]); } system.out.println(); } public static int[] fact(int n) { int[] = new int[100]; a[0] = 1; (int = 1; <= n; i++) { int carry = 0; for(int j = 0; j < a.length; ...

sqlite - SQLlite isolated from other apps -

i cannot find answer after searching on internet, if app creates database on mobile device named 'mydb' table called 'users' happens if vendor's app on user's device creates exact same name? databases isolated app? if you're talking android device: yes, other apps can't access app database. (unless have root access) android provides full support sqlite databases. databases create accessible name class in application, not outside application. http://developer.android.com/intl/pt-br/guide/topics/data/data-storage.html#db

vba - How to make a specific cell in excel uneditable -

my problem trying make cell cannot edited users after inputs given. example want let user input cell c22-c28 after user inputs cell, specific cell shouldn't edited. should best solution this? suggestions? take @ question how lock data in cell in excel using vba where multiple nice answers. in basic, need set range .locked , protect sheet via .protect , more develop info try @ msdn edit: can use mentioned in question ( restricting user delete cell contents ) without lock , unlock, can use this. have there 1 global variable store selection value (to preserve beforechange state). function selectionchange, updating value of current cell, can restore cell value after users try. sub worksheet_change controling, if user targeting specified row , column (can adjusted whole range), , if try change value, prompted , value set back. dim prevvalue variant private sub worksheet_selectionchange(byval target range) prevvalue = target.value end sub private sub work...

python - Why do these two forms of iteration produce different results? -

alist = ['1', '2', '3'] blist = alist[:] x in alist: if not "@gmail.com" in alist: x = x + "@gmail.com" x in range(len(blist)): if not "@gmail.com" in blist[x]: blist[x] = blist[x] + "@gmail.com" the first block of code not implement need, yet second 1 does. what difference between these 2 blocks of code? when x = x + "@gmail.com" in first version of code, you're creating new value , rebinding name x refer it. has no effect on alist , though that's previous x value came from. when blist[x] = blist[x] + "@gmail.com" on other hand, you're explicitly modifying list. you're rebinding blist[x] refer new value. note different list contents, might have been able make first version of code work, using "in place" modification. strings immutable though, there no in-place operations. however, if alist contained mutable items such list s...

php - push an associative arrays as a one associative array -

i have desired associative array format (refer below) $url = array ( "a1" => array( 'k1' => "content of k1 in a1 array", 'k2' => "content of k2 in a1 array" ), "a2" => array( 'k1' => "content of k1 in a2 array", 'k2' => "content of k2 in a2 array" ), ); and in laravel thing, retrieved records in database table , loop on , value , push unto array. $k = kk::with('kk_names')->get(); $k_array = array(); foreach($k $item){ $sr = array($item->name => array("k1" => $item->items[0]->description,"k2" => $item->items[1]->description)) array_push($k_array,$sr); } it did works associative array format (refer above associative array format) not 1 want, gives me instead. $url = array ( array("a1" => array( 'k1' => "content of k1 in ...

javascript - Electron icns not showing up -

i installed electron-prebuilt inside main project root (locally). i browse node_modules/electron-prebuilt/ , see electron app package. then show package contents , browser resources/ app atom.icns can found (i converted atom.icns atom.png 1024x1024 file). i replace atom.icns default icon own .icns naming same atom.icons move app folder , original folder. pratically followed these steps https://github.com/atom/electron/issues/654 problem icon not appear can see blank icon "disabled" figure on if icon missing. any idea? i think should use electron-packager suggested electron. pass icon via icon option of electron-packager.

php - Can not scan some string in wordpress with LOCO TRANSLATE plugin in Wordpress -

Image
i have problem loco translate plugin. used loco scan string in theme (divi theme). great!. case such comment section in post (comment default function in post in wordpress). can not scan. please see below example: please me!!! thank much!! i saw problem. because site have not .po , .mo file in /wp-content/languages directory. loco-translate plugin not find them. the solution: access dashboard , go settings->general. select language want use in site language section. .po file , .mo file auto downloaded , auto put /wp-content/languages directory. demo here:

validation - How to disply the calender before 3 months and after 3 months only from current date onwords using jquery -

i want calendar when calendar shows it's show current date , want able see in calendar before 3 months date , after 3 months date only. i getting current date , selecting date. input type date $(document).ready(function() { $( "#txttrtdtpreaprvlsubn" ).datepicker({ changemonth: true, changeyear: true, mindate: '-3m', maxdate: '+3m', }); }); <input type="date" id="txttrtdtpreaprvlsubn" placeholder="treatment date"> $(...).datepicker not function error comming based on current date, calculate min date , max date , set these options date picker. like below: $(document).ready(function() { var date1 = new date(); var date2 = new date(); $("#from").datepicker().datepicker("setdate", new date()); var munimumdate = new date(date1.setmonth(date1.getmonth() - 3)); var maximumdate = new date(da...

elixir - Expected a truncated byte -

when pass 2 size of bits follow: iex(11)> <<2 :: size(2)>> i've got output in iex(i determine size of bit) <<2::size(2)>> but when write following in iex iex(12)> <<3 :: size(2)>> i've got <<3::size(2)>> but expected <<1::size(2)>> and 4 iex(13)> <<4 :: size(2)>> <<0::size(2)>> i've got 0 , right, 3 why i've got 3 instead 1? size(2) means 2 bits, can hold 4 (2^2) values: 0, 1, 2 or 3. it seems looking store 1 bit if expected 3 become 1. that, use size(1) : iex> <<3::size(1)>> <<1::size(1)>>

remove duplicate lines in each paragraph of a file using sed or awk -

i want remove duplicate lines pargraphs begin "set current" in file, share same first line , have same sentences , don't remove duplicate lines belong different paragraphs example: if have following file: set current = 'aaa' ; create syn file1 1000.file1 ; create syn file2 1000.file2 ; create syn file3 1001.file3 ; create syn file3 1001.file3 ; set current = 'aaa' ; create syn file1 1000.file1 ; create syn file2 1000.file2 ; create syn file7 1000.file7 ; set current = 'bbb' ; create syn file5 1002.file5 ; create syn file6 1003.file6 ; set current = 'bbb' ; create syn file1 1000.file1 ; create syn file8 1002.file8 ; create syn file6 1003.file6 ; the result set current = 'aaa' ; create syn file1 1000.file1 ; create syn file2 1000.file2 ; create syn file3 1001.file3 ; set current = 'aaa' ; create syn file7 1000.file7 ; set current = 'bbb' ; create syn file5 1002.file5 ; create syn file6 1003.file6 ; ...

php - why the day not equal to 24 hours timezone set to los angeles? -

background: our server php set timezone america/los_angeles at work, found piece of code $a = 1457856000; $b = $a + 24*3600-1; var_dump(date('y-m-d h:i:s', $a)); var_dump(date('y-m-d h:i:s', $b)); which output: string(19) "2016-03-13 00:00:00" string(19) "2016-03-14 00:59:59" quite strange, when code follow: date_default_timezone_set('etc/gmt+8'); $a = 1457856000; $b = $a + 24*3600-1; var_dump(date('y-m-d h:i:s', $a)); var_dump(date('y-m-d h:i:s', $b)); it output: string(19) "2016-03-13 00:00:00" string(19) "2016-03-13 23:59:59" could explain why happened? take @ output of <?php date_default_timezone_set ('america/los_angeles'); $a = 1457856000; echo date('y-m-d h:i:s', $a), "\r\n\r\n"; for($i=0; $i<25; $i++) { $b = $a + ($i*3600)-1; echo date('y-m-d h:i:s', $b), "\r\n"; } and marvel @ w...

Redis set becomes empty -

i have list of 10 million unique items in redis set. when set gets populated run 4 independent workers use spop (get&remove) command. each worker processes 6 items every 20 seconds (the api limits deal with). redis runs pretty default config, appendonly set "yes". the problem after ~20k items processed redis set becomes empty , workers jobless. why that? there's no ttl on keys , default redis should keep them forever. appendonly.aof file still remains huge on disk. i run redis 3.0.7 on debian 8, no errors in redis.

python - How can I distinguish percent encoded URL and NOT percent encoded URL? -

i receive 2 pattern url, percent encoded , not percent encoded. code don't work input_url_b because encoded. how can resolve or have ideas? from urllib.parse import urlparse, parse_qs, urlencode if __name__ == '__main__': input_url_a = "http://sample.jp/api?v1=aaa&v2=日本語&v3=ccc" input_url_b = "http://sample.jp/api?v1=aaa&v2=%93%fa%96%7b%8c%eav3=ccc" # '%93%fa%96%7b%8c%ea' = '日本語' # pattern ok. parsed = urlparse(input_url_a) query = parse_qs(parsed.query) fixed_url = parsed._replace(query=urlencode(query, doseq=true)).geturl() print(fixed_url) # 'http://sample.jp/api?v3=ccc&v2=%e6%97%a5%e6%9c%ac%e8%aa%9e&v1=aaa' resp = urllib.request.urlopen(fixed_url) # pattern b ng. parsed = urlparse(input_url_b) query = parse_qs(parsed.query) fixed_url = parsed._replace(query=urlencode(query, doseq=true)).geturl() print(fixed_url) # 'http://sample.jp/api?v2=%...

reactjs - React render nested component -

in return method of react component want have check async function , return if satisfied. code: render() { var data = new myclass() data.helper(function(response){ if(response.status === "authorised"){ return ( <div> <list videos={videos}/> </div> ) }else{ return ( <div> <p>please wait</p> </div> ) } }) } but way giving me error saying: a valid react component must returned. returning either array or list or undefined i want show data after logic. i suggest moving ajax call componentdidmount lifecycle method request fires when dom node mounted, , conditionally setting authorised property on state, contingent on successful response. use state property conditionally render different ui states in render method: class mycompo...

python - Can't rename a Maya locked node -

import maya.cmds cmds def replace(char): locators = cmds.ls(tr=true, s=true,type=('joint')) or [] try: lp in locators: if char in lp: newfilename = lp.replace(char, "a") cmds.rename(lp, newfilename) except: print "yes" charreplace="ghoul" charreplace2="shjnt" charreplace3="head" charreplace4="spine" charreplace5="arm" charreplace6="leg" replace(charreplace) replace(charreplace2) replace(charreplace3) replace(charreplace4) replace(charreplace5) replace(charreplace6) i'm trying rename nodes in maya scene. this current code renames these nodes: ghoul , shjnt. i can't rename head node. i following error when try rename it: // error: line 1: cannot rename locked node. // how can improve code able rename locked nodes? import maya.cmds cmds ######################################## # function renames ...

winforms - Play video from blob data Oracle using C# -

i have created simple project save blob file data oracle database using c# winform , worked fine. now, wanna play video blob oracle data using c# couldn't. here code: if (koneksidb.con.state == connectionstate.open) { koneksidb.con.close(); } koneksidb.con.open(); oraclecommand cmd = new oraclecommand(); oracledatareader dr; cmd.commandtext = @"select id,filename, filedata, keterangan, substr(filename, -4)as fileextention latihanfilemanager id = '1' , ispreview = n'1'"; cmd.connection = koneksidb.con; dr = cmd.executereader(); while (dr.read()) { string fileextention = dr["fileextention"].tostring(); //got file extention database switch(fileextention) { case ".pdf": //when blob pdf file worked fine byte[] filebytes = (byte[])dr["filedata"]; system.io.memorystream stream = new system.io.memorystream(filebytes); fmpdfviewer f = new fmpdfviewer(); f.pdf...

c++ - UDP client-server program compiles using gcc but not g++ -

server : int main(int argc, char *argv[]) { struct sockaddr_in client, server; int s, i=0; socklen_t n; char buf[31]; s=socket(af_inet,sock_dgram,0); server.sin_family=af_inet; server.sin_port=atoi(argv[1]); inet_pton(af_inet, "localhost", &(server.sin_addr)); bind(s,(struct sockaddr *)&server,sizeof(server)); n=sizeof(client); while(1) { recvfrom(s, buf, sizeof(buf), 0, (struct sockaddr *)&client, &n); printf("%s", buf); } close(s); return 0; } client : int main (int argc, char *argv[]) { struct sockaddr_in client, server; int s; socklen_t n; char buf[31]; char data[23]; s=socket(af_inet,sock_dgram,0); server.sin_family=af_inet; server.sin_port=atoi(argv[2]); inet_pton(af_inet, argv[1], &(server.sin_addr)); n=sizeof(server); while(1) { data[0] = 't'; data[1] = 'e'; data[2] = ...

javascript - Reading of text file without using any server in JS -

i want read text file in local directory,i found many examples have used httprequest()i don't want use of servers xampp,wampp etc i using js!! best partice php,nodejs or backend langaugae such things, in case might use angularjs . add below in js var myapp = angular.module('myapp', []); myapp.controller('mainctrl', function ($scope) { $scope.showcontent = function($filecontent){ $scope.content = $filecontent; }; }); myapp.directive('onreadfile', function ($parse) { return { restrict: 'a', scope: false, link: function(scope, element, attrs) { var fn = $parse(attrs.onreadfile); element.on('change', function(onchangeevent) { var reader = new filereader(); reader.onload = function(onloadevent) { scope.$apply(function() { fn(scope, {$filecontent:onloadevent.target.result}); ...

sql - Table return the result of two rows in one -

this question has answer here: efficiently convert rows columns in sql server 3 answers if have table this: matchcode transferid ---------- ----------- 17edce4d 7 17edce4d 17 20332cf0 22 20332cf0 30 is possible make result return this? matchcode transferid1 transferid2 ---------- ----------- ----------- 17edce4d 7 17 20332cf0 22 30 if each matchcode group have 2 records, can use min , max along group by : select matchcode, min(transferid) transferid1, max(transferid) transferid2 yourtable group matchcode

ios - textview text into array -

i want paste data text view, , want information placed array. @ moment need do, later on i'm looking place data tableview. if can me appreciated. thank you you can split string textview using nscharacterset *separator = [nscharacterset newlinecharacterset]; nsarray *dataarray = [textviewstring componentsseparatedbycharactersinset:separator]; eg. text pasted line 1 line 2 line 3 result array contain [@"line 1",@"line 2",@"line 3"]

python - How to replace a thread when finished -

i have code: from threading import thread queue = [] x in range(5): queue.append(thread(target=somefunction)) queue[x].start() while true: x in range(5): if not queue[x].isalive(): queue[x] = thread(target=someotherfunction) queue[x].start() #for reason, code not work , #iterates through loop lot i thinking of adding queue, saw in docs, don't think it's suited want. do want replace thread in list if has finished. if not, not replace it. just reminder, pseudo code. this code suited multi-segment downloader. as sidenote, python 3.

How to migrate XML type oracle data to Hadoop HDFS -

i have huge data in oracle in 1 table , 1 column type xml type contains main data. need move data hdfs. should best way migrate data in hadoop hdfc. sample code or instructions appreciated. do want move data flat (or csv) files hdfs or import table 1 of hive db. in case of hive import, can use sqoop. sqoop used import data rdbms databases hive db.

How can I format a javascript using java? -

i'm trying write javascript java application. i'm using try { writer writer = new bufferedwriter(new outputstreamwriter(new fileoutputstream(path.... my question is: how format result code correct indentation?

c# - Fluent API not cascading on delete in a one-to-one relationship -

i have 2 classes: public class student { public long studentid { get; set; } public studentdetails details { get; set; } } public class studentdetails { public long studentdetailsid { get; set; } public student student{ get; set; } //other properties } one student contains 1 studentdetails. studentdetails can not exist without corresponding student. with these mappings: public studentmapping() { this.totable("student"); this.haskey(x => x.studentid); this.hasrequired(x => x.details) .withrequireddependent(x => x.student) .willcascadeondelete(true); } public studentdetailsmapping() { this.totable("studentdetails"); this.haskey(x => x.studentdetailsid); this.hasrequired(x => x.student); } however, when go database in sql management studio, , following: delete students studentid == 1 , student row gets deleted, delete no...

java - Detect for fullscreen from a service in android -

i creating color picking feature able pick color anywhere on android screen. i able pick color accurately when app gets full screen, calculations have account system ui's height calculation. if (fullscreenstate == true) ycoord = ycoord + statusheight; int pixel = screen.getpixel(xcoord ,ycoord); log.d("pixel color", "pixel color: + " + integer.tohexstring(pixel) + " @ x:" + xcoord + " y:" + ycoord); you need add transparent view window manager, 1px width , match_parent height. then, add global layout listener view, , every time there's change on layout, check position of view on screen. if it's y 0, status bar not visible, full screen app must running.

dataframe - Subsetting a data frame with dates as `str` and nan values in Python -

i have data frame, extracted .csv file using data = pandas.read_csv one of columns of data frame dates, such '14/09/2015' , type of data str . i need create subset, use: newdataframe = dataframe['datescolumn'][dataframe['datescolumn']==desired date] but have 2 main problems: since dates strings, have tried use slice [-1]. error: keyerror : -1l i tried use code select 2014: newdataframe = dataframe['datescolumn'][dataframe['datescolumn'][-1]==4] i have empty fields have been imported nan values. if try perform for loop transform data, error: typeerror: 'float' object has no attribute '__getitem__' q: how can subset data (or clean it) year? many thanks. for nan values can use fillna() . # fill nans zeros nonans = withnans.fillna(0) and date issue, instead of handling date strings should let existing libraries handle them you. in case read_csv() function can you. see documentation here . ...

Migration Data from legacy table to new mysql mysql with django ORM gives Error -

i migrating legacy data mysql database new 1 using django orm. old application created in perl , mysql. but while migrating keep getting error: databaseerror: (1118, 'row size large (> 8126). changing columns text or blob or using row_format=dynamic or row_format=compressed may help. in current row format, blob prefix of 768 bytes stored inline.') i dropped table , recreated row_format=compressed (which implies row_format=dynamic) still getting error. i couldn't find working solution fixing this. has else encountered such situations? have @ row size large (> 8126)

python - Text segmentation: Algorithm to match input with the longest words from the dictionary -

i need split string words such each word comes dictionary. make sure longest possible word left chosen. hence thisisinsane => insane (correct longest possible word left) thisisinsane => in sane(wrong) assuming 'this', 'is', 'in', 'insane' words in dictionary. i managed solved problem traversing end of string beginning matching longest word possible. problem started cropping problems these.. shareasale => share ale(wrong 'ale' not in dictionary) shareasale => share sale(correct) assuming 'share', 'a', 'sale' words in dictionary unlike 'ale'. i tried solve problem removing valid segments found before encountering error i.e. shareasale => 'share' , 'as' (error = 'ale') and removing them once dictionary , solve problem. so shareasale => no valid segments when share removed shareasale => share sale (when 'as' removed dictionary. thus managed solv...

javascript - What is parent-child coupling in react and how does it relate to context? -

i reading context > parent-child coupling documentation of react. unable parent-child coupling documentation. typically line : by passing down relevant info in menu component, each menuitem can communicate containing menu component. the code is: <menu> <menuitem>aubergine</menuitem> <menuitem>butternut squash</menuitem> <menuitem>clementine</menuitem> </menu> as article mentions, data flow in react typically done passing props parent child component. however, in cases prop sharing can become tedious, , in these cases, we'd use context . the example in document describes how continually threading color prop become annoyance, in cases you'd utilize context when prop chain deeper 2 or 3 levels. better example might store in redux . for instance, use redux, don't implement react-redux , must access store context . now, let's have nested component (grandchildren of grandchildren), , n...

sql - How to order result in ascending order if it is Month Name -

i writing query sum values 2 different tables , find sale , purchase per month. after ordering in ascending order , expected giving false result, i.e august coming before february. how can modify query result correctly? here query: select coalesce(o.month , p.month) month, isnull([sale cost],0) [sale cost], isnull([purchase cost],0) [purchase cost] ( select sum(s.cost) [purchase cost], datename( month , dateadd( month , month(s.[date_added]) , -1 ) ) month dbo.spare_inventory s year(getdate()) = year(s.[date_added]) group month(s.[date_added]) ) o full join ( select sum(b.[total price]) [sale cost], datename(month, dateadd( month , month(b.[dateofsale]) , -1 ) ) month dbo.spare_sale_db b year(getdate()) = year(b.[dateofsale]) group month(b.[dateofsale])) p on o.month = p.month order month asc you have kind of given answer yourself; want rows oredered month number, not month name...

PHPExcel: Set Column Names fromArray using PHP array -

i'm using phpexcel library export data excel. i'm able data excel expected. how can set column names php array. here code i'm using. please help $data=( array(10) ( [0] => array(8) ( [#] => (string) [name] => (string) student1 [id] => (string) 123456 [date] => (string) 2016-02-01 [group] => (string) physics [month] => (string) february [year] => (string) 2016 ) [1] => array(8) ( [#] => (string) [name] => (string) student2 [id] => (string) 569874 [date] => (string) 2016-02-01 [group] => (string) biology [month] => (string) february [year] => (string) 2016......); $objphpexcel = new phpexcel(); $objphpexcel->setactivesheetindex(0); $objphpexcel->getactivesheet()->setcellvalue('a1', "#"); $objphpexcel->getactivesheet()->setcellvalue('...

typescript - angular 2 custom directive OnInit -

i'm getting starting on angular 2 , i'm encountering following problem. below simple custom directive supposed color font green. in ngoninit, can't access string "defaultcolor", console.log returns "undefined". any clue why? cheers! import {directive, elementref, oninit} 'angular2/core'; @directive({ selector: '[myhighlight]' }) export class highlightdirective implements oninit{ private elref:elementref; private defaultcolor: 'green'; constructor(elref:elementref){ this.elref = elref; } ngoninit():any { this.elref.nativeelement.style.color = this.defaultcolor; console.log(this.defaultcolor) } } the syntax wrong. private defaultcolor:string = 'green'; the value assigned using = not : . : define type field.

android - The layout in red color Layout is not visible over the silver one -

Image
the layout in red color layout not visible on silver one. overlap container , make visible textview visible in above container. please suggest should solution margintop=-30dp seems work bad. appriciated. <?xml version="1.0" encoding="utf-8"?> <scrollview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:fillviewport="true"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <linearlayout android:layout_width="match_parent" android:layout_height="400dp" > <linearlayout android:layout_width="match_parent...

php - Calculate commision based on level completeness of a binary tree -

Image
i have 2 tables. business plans users binary right now, if see users_binary, following hierarchy being developed. 1 / \ 3 4 / \ / \ 19 33 18 32 i want calculate commission based of completeness of level. has 2 childs. first level complete. user 1 on plan 1. plan 1's right , left points 20 , commission percentage 4.5. it's first level complete. ((20+20)*4.5%) commission. when 3 , 4 completes 1st levels, user 1 ((20+20+20+20)*4.5%) commission. 1 thing note. in query, note commission being calculated monday saturday , point_status should equal n. this getbasictree function. function getbasictree($user_id) { $query="select user_id,first_name,last_name,leg users introducer_id = '".$user_id."' , leg != ''"; if(($data=$this->customquery($query))!=null) { return $data; } return 0; } any...

javascript - Interpret a cumbersome conditional expression -

last night looking angularjs snippet manage vertical tabs menu , found expression: if(+!!variablename) dosomething(); sorry, can't understand mean +!!variablename how can resolve conditional expression? this 1 way of saying if number if not null or undefined if(+!!variablename) dosomething(); if variablename 0 , empty ( "" ), null or undefined , translate false or else true . for example, if var variablename = null; now, translate (+!!null) -> (+!true) -> (+false) -> false similarly, if var variablename = "anything"; this translate (+!!"anything") -> (+!false) -> (+true) -> true + in case has no effect on outcome, can safely removed. in fact, whole conditional expression can replaced by if(variablename) dosomething();

javascript - Jquery: Range Slider: How to get the set range values? -

i want set range values using $_post after form submit. problem when range set 10 - 25, value 10 value got. if(isset($_post['btn_submit'])) { $value = $_post['get']; echo "<script> alert($value) </script>"; } <form method="post"> <input class="range-slider" type="hidden" name="get"/> <input type="submit" value="submit" name="btn_submit"> </form> $(document).ready(function(){ $('.single-slider').jrange({ from: -2.0, to: 2.0, step: 0.5, scale: [-2.0,-1.0,0.0,1.0,2.0], format: '%s', width: 300, showlabels: true, snap: true }); $('.range-slider').jrange({ from: 0, to: 100, step: 1, scale: [0,25,50,75,100], format: '%s', width: 300, showlabels: true, isrange : true ...

.net - Writing a C# DateTime using HDF5.NET that can be read by PyTables -

i'm writing data logging application in c# using hdf5.net. .h5 files written opened , analysed using pytables. pytables uses time32col , time64col store timestamps in hdf5 files. files created pytables, works great. i know hdf5 stores timestamps 4 or 8-byte unix timestamps ( https://www.hdfgroup.org/hdf5/doc1.6/ug/12_datatypes.html ) , i'm able use c# convert .net datetime unix timestamps no trouble, problem in creating h5 type when open file on other end pytables knows it's timestamp. the documentation says use 1 of h5t_unix_d32le , h5t_unix_d32le , h5t_unix_d32le or h5t_unix_d32le . problem none of these available in h5t.h5type of hdf5.net. does have workaround?

Dial code from country code (mcc) using Cordova, ionic -

how dial code mcc (mobile country code)? eg. india has 404 or 405 mcc various network operators, +91 standard dial-code. i using cordova-plugin-sim plugin of cordova . when use window.plugins.sim.getsiminfo function, info through json response (i have not shown info privacy/security reasons): callstate: 0 carriername: "bsnl mobile" countrycode: "in" dataactivity: <some number> deviceid: "<some id integer>" devicesoftwareversion: "<a 2 digit code>" isnetworkroaming: false mcc: "404" mnc: "66" networktype: 10 phonenumber: "<my mobile number without dial code>" phonetype: 1 simserialnumber: "<sim serial number, long one>" simstate: 5 subscriberid: "<subscriber id, long one>" do need use api dial code using information window.plugins.sim.getsiminfo ?

java - How to compile a .jar without errors concerning libraries? -

i decompile .jar jd-gui edit file error. problem when open eclipse project recompile same classes, has lot of errors concerning libraries. therefore, compiling .jar again use in project, doesn't work. shouldn't libraries in original .jar? how original .jar work without libraries? how can fix without having find , add libraries? java compiler doesn't include external libraries in jar. should use build tools maven or gradle deal it. or place jar dependencies in /lib dir next jar , add dir classpath in jar's manifest file

how to display images from folder while displaying image by name using php? -

Image
i have 2 folders, 1)- 23feb2016 , 2)- 23feb2016 . want 1 image folder1 , 1 folder2 , image name must unique, userid etc. this html code: <div class="col-md-12"> <div class="col-md-6"> <image src="../images/registered/20115.jpg" style="width: 100%; height: 100%"></image> registered </div> <div class="col-md-6"> <image src="../images/registered/20115.jpg" style="width: 100%; height: 100%"></image> attendance </div> </div> you can use following approach find unique files. //path directory scan $directory1 = "./folder1/"; $directory2 = "./folder2/"; //get image files .jpg extension. $jpgfolder1 = glob($directory1 . "*.jpg"); $jpgfolder2 = glob($directory2 . "*.jpg"); $uniqeimage[]; if(($jpgfolder1 != null) && ($jpgfolder2 != null)) { $uniqeimage = arr...