Monday, 15 March 2010

c# - Using a singleton to send messages between any two classes -



c# - Using a singleton to send messages between any two classes -

is using singleton send messages between classes or bad idea?

one side of communication registers listener (listening string or object, perchance parameters) , other side sends messages. there can multiple or no listeners message.

using such pattern means objects in different projects can communicate without having reference 1 another.

a case useful sending errors in application 1 object. can send error part of application , error manager can hear errors have occurred.

what downsides taking such approach?

problems come mind globals create hard testing , possibility of unexpected consequences since in app listening event , in unrelated projects.

for situations similar using observer pattern , making event dispatcher singleton.

c# events design-patterns singleton global-variables

jquery - How to ignore font-size setting changes for Cordova App when runs on Android 4.4+? -



jquery - How to ignore font-size setting changes for Cordova App when runs on Android 4.4+? -

i've developed cordova app cordova version 3.6.3 , jquery. 1 problem still can't best solutions when test app on android 4.4+ , there users love alter font size in setting > display > font-size of device larger normal. causes app layout displays ugly (the best display when font-size setting normal only). there no effect of font-size setting android older 4.4 (4.3,4.2...) app displays on older version.

the solutions i've applied app creating custom plugin observe configuration changed , detects if user uses android 4.4+ , if set font-size setting not normal, i'll utilize jquery forcefulness font-size specified size.

example is....

if (font_scale == huge) { $("div").css("font-size","20px !important"); }

this works fine after page loaded, css doesn't changes want. , suppose if there 30 divs+ on page must insert statement above 30 times , takes much time needlessly.

i want know, there ways solve problem easier using plugin? maybe using xml configuration or css3 properties can makes app displays without side effect font-size setting of android 4.4?

another ways tried , doesn't works

inserting fontscale on androidmanifest.xml > activity tag inserting webkit-text-size-adjust:none; in css

i'd love hear ideas help solve this.

try remove 1 index.html:

target-densitydpi=device-dpi

good luck.

android jquery cordova android-4.4-kitkat

git - Internal github VCS intellij idea issue -



git - Internal github VCS intellij idea issue -

at first using version command scheme subversion on windows in "origin / master" branch, after changed os ubuntu , started using git command system. after 2 successful commit, saw thread have "head" "master" makes possible can not commit main branch. how switch branch "origin / master"?

it seems confusion between how git , svn work.

svn keeps remote history , each commit, stores changes in remote repository.

git keeps local history of each change. @ commit time, changes stored localy. so, if want "push" local history, have git push. in intellij, several ways it, example, right click on project->git->repository->push (or ctrl+alt+k), check ok in window (you have force origin master) , push. if don't want commit force in 2 steps, in commit window, instead of commit, have possibility commit , force (see arrow right of commit button.

if need more details, here's corresponding chapter in git book : http://git-scm.com/book/en/git-basics-working-with-remotes

chapter 2 of book start git sense free read :)

hope helps

git svn github intellij-idea

CSV to image in python -



CSV to image in python -

i want create image out of csv data.

i reading csv with:

f = open('file.csv', 'rb') reader = csv.reader(f)

from here, want create grayscale image translating each row of numbers in list line of intensities in image file.

not sure useful here details csv file: using floats, columns:315, rows: 144

thanks

two steps:

convert csv file numpy array using genfromtxt

from @andrew on how read csv record array in numpy?

from numpy import genfromtxt my_data = genfromtxt('my_file.csv', delimiter=',') then save numpy array image

python image csv

hive - Count and find maximum number in Hadoop using pig -



hive - Count and find maximum number in Hadoop using pig -

i have table contain sample cdr info in column , column b having calling person , called person mobile number need find having maximum number of calls made(column a) , need find number(column b) called most

the table construction below

calling called 889578226 77382596 889582256 77382596 889582256 7736368296 7785978214 782987522

in above table 889578226 have number of outgoing calls , 77382596 called number in such way need output

in hive run below

select calling_a,called_b, count(called_b) cdr_data grouping calling_a,called_b;

what might equalent code above query in pig?

anas, please allow me know expecting or different?

input.txt a,100 a,101 a,101 a,101 a,103 b,200 b,201 b,201 c,300 c,300 c,301 d,400 pigscript: = load 'input.txt' using pigstorage(',') (name:chararray,phone:long); b = grouping (name,phone); c = foreach b generate flatten(group),count(a) cnt; d = grouping c $0; e = foreach d { sortedlist = order c cnt desc; top = limit sortedlist 1; generate flatten(top); } dump e; output: (a,101,3) (b,201,2) (c,300,2) (d,400,1)

hadoop hive apache-pig cdr

tsql - Excel 2010 Pivot Table from MS Query Calculation and Grouping Issue -



tsql - Excel 2010 Pivot Table from MS Query Calculation and Grouping Issue -

first post here, have helped me much.

my issue building sales board in excel 2010 using odbc connection sql server 2008 r2 database. have 2 row groups , 2 column groups. groups in parent kid order.

row groups product grade , product. column groups date , region(east , west). value product cost region. i'm trying add together subtotal after each part grouping gives (east cost - west price). 1 part reported if west subtotal shouldn't exist.

i've tried combination of calculated items, works adds column each region. or doing work in sql server works except product grade grouping spreads products in every parent group. i'd prefer create work in sql server obvious reasons , new building info in excel. i'm sure simple i'm missing. help much appreciated.

;with t ( select info.protype, info.product, case when info.pricecode = 'x' 'east' else 'west' end region, sum(isnull(info.price,0)) price, case when r1.product=r2.product sum(x.price-y.price) else 0 end diff, info.effectdate (select protype, product, pricecode, price, effectdate prc_table pricecode in ('x','y') , protype = 'z') info left bring together prc_table r1 on info.protype = r1.protype , info.product = r1.product , info.effectdate = r1.effectdate , r1.pricecode = 'x' left bring together prc_table r2 on info.protype = r2.protype , info.product = r2.product , info.effectdate = r2.effectdate , r2.pricecode = 'y' info.effectdate >= dateadd(mm, -3, getdate()) , info.effectdate <= getdate() grouping info.effectdate, info.protype, info.product, r1.product, r2.product, info.pricecode, r1.price, r2.price ) select c.codedesc [grade], r.product [product], r.region [region], r.price [price], r.diff [e-w], r.effectdate [date] t r inner bring together pro_item on r.protype = i.protype , r.product = i.product inner bring together pro_duct p on i.protype = p.protype , i.product = p.product , i.1 = p.1 (product grade join) inner bring together xxx_codes c on p.desc3 = c.code , c.prefix = 'xxx' i.protype = 'z' , i.loc = 'loc' , p.desc4 = '' , i.branch = 'm' order r.effectdate desc, codedesc, product

i you're trying do. , you're on right track calculate differences in sql, because it's not possible show/hide subtotals in pivot table depending on whether it's east/west or east. doing in sql good. think have bit of design flaw in query trying set difference in separate column.

the problem is, how nowadays in pivot table? if have both cost , diff value field in pivot table, botch layout completely. want 1 value field - price. , want east, west, , diff column headings, should regions in data.

so, in sql, grade, product, region, price, , date you're doing, set in temp table, insert temp table difference records, region='diff' , price= actual difference value, both east , west record exist product , effective date.

your output should this:

grade product part cost effdt p1 east 1.5 31-oct-14 p2 east 3 31-oct-14 b p3 east 5 31-oct-14 b p4 east 2.44 31-oct-14 c p5 east 3.67 31-oct-14 c p6 east 10.3 31-oct-14 b p3 west 5.5 31-oct-14 b p4 west 2.7 31-oct-14 c p5 west 3.8 31-oct-14 c p6 west 10.7 31-oct-14 p1 east 1.5 30-nov-14 p2 east 3 30-nov-14 b p3 east 5 30-nov-14 b p4 east 2.44 30-nov-14 c p5 east 3.67 30-nov-14 c p6 east 10.3 30-nov-14 b p3 diff -0.5 31-oct-14 b p4 diff -0.26 31-oct-14 c p5 diff -0.13 31-oct-14 c p6 diff -0.4 31-oct-14

you insert difference rows applicable, when pivottable data, show either east+west+diff or east not east+diff.

it looks you're pretty comfortable sql write above query should able implement that. if having problem post , i'll have look.

cheers

excel tsql sql-server-2008-r2 grouping

coffeescript - Convert javascript code into coffescript -



coffeescript - Convert javascript code into coffescript -

im working dashing , need convert javascript code coffescript in order create utilize of rickshaw graph library. (according source code on website http://code.shutterstock.com/rickshaw/examples/x_axis.html)

i'm trying have customized x axis on graph.

default coffescript code= x_axis = new rickshaw.graph.axis.x(graph: @graph)

js code converted

var format = function(n) { var map = { 0: 'zero', 1: 'first', 2: 'second', 3: 'third', 4: 'fourth' }; homecoming map[n]; } var x_ticks = new rickshaw.graph.axis.x( { graph: graph, tickformat: format } );

into coffescript

var format = function(n) { var map = { 0: 'zero', 1: 'first', 2: 'second', 3: 'third', 4: 'fourth' }; homecoming map[n]; } x_axis = new rickshaw.graph.axis.x(graph: @graph,tickformat: format)//make utilize of format

format = (n)-> map = 0: 'zero', 1: 'first', 2: 'second', 3: 'third', 4: 'fourth' map[n]

javascript coffeescript rickshaw