Posts

recursion - Combinatorics in Scala: How to iterate/enumerate all possibilities to merge multiple sequences/lists (riffle shuffle permutations) -

recursion - Combinatorics in Scala: How to iterate/enumerate all possibilities to merge multiple sequences/lists (riffle shuffle permutations) - updated question: in original question did not know how refer next problem. clarify question, added following illustration wikipedia: it turns out problem named after analogy: riffle shuffle permutations. based on terminology question becomes: how can iterate/enumerate riffle shuffle permutations in general case of multiple decks? original question: let's assume given multiple sequences , want merge these sequences 1 single sequence. resulting sequence should preserve order of original sequences. think of merging multiple stacks of cards (say seq[seq[t]] ) 1 single stack ( seq[t] ) randomly drawing card (random) stack. input stacks should merged resulting stack. how can iterate or enumerate possible compositions of such resulting sequence? to clarify: if have 3 stacks a, b, c (of 5 elements each) not want 6 possible arrange...

r - Reshape three column data frame to matrix -

r - Reshape three column data frame to matrix - i have data.frame looks this. x 1 x b 2 x c 3 y 3 y b 3 y c 2 i want in matrix form can feed heatmap create plot. result should like: b c x 1 2 3 y 3 3 2 i have tried cast reshape bundle , have tried writing manual function not seem able right. there many ways this. reply starts favorite ways, collects various ways answers similar questions scattered around site. tmp <- data.frame(x=gl(2,3, labels=letters[24:25]), y=gl(3,1,6, labels=letters[1:3]), z=c(1,2,3,3,3,2)) using reshape2: library(reshape2) acast(tmp, x~y, value.var="z") using matrix indexing: with(tmp, { out <- matrix(nrow=nlevels(x), ncol=nlevels(y), dimnames=list(levels(x), levels(y))) out[cbind(x, y)] <- z out }) using xtabs : xtabs(z~x+y, data=tmp) you can utilize reshape , suggested here: convert table matrix co...

Is there a way to pull a list of all user that have ever authenticated to a Twitter Application? -

Is there a way to pull a list of all user that have ever authenticated to a Twitter Application? - i unable find in documentation know facebook has similar where, app can pull list of users have authenticated ( or granted permissions ) said app. the twitter rest api not expose methods allow developers see has authorized application. twitter

c# - Strangely slow: what happened when TakeWhile met AsParallel? -

c# - Strangely slow: what happened when TakeWhile met AsParallel? - i know wrong usage of linq may cause lower performance time it's strange. when phone call "asparallel.takewhile.asparallel.forall", it's much slower "asparallel.takewhile.forall". can explain why? using system; using system.diagnostics; using system.linq; namespace consoleapplication1 { class programme { static void main(string[] args) { action<int> donothing = => { }; var stopwatch = stopwatch.startnew(); enumerable.range(1, 100).asparallel().takewhile(m => m < 10) .forall(donothing); var ticks1 = stopwatch.elapsedticks; stopwatch.restart(); enumerable.range(1, 100).asparallel().takewhile(m => m < 10) .asparallel() // spend much more time asparallel .forall(donothing); var ticks2 = stopwatch.elapsedti...

azureservicebus - Azure notification hubs shared access key expiry -

azureservicebus - Azure notification hubs shared access key expiry - from azure portal, on configure tab notification hub able generate primary key , secondary key. understand these required gain programmatic access azure api - allowing client app create registrations , send messages. could please explain: why there 2 keys (primary , secondary)? keys generated ui expire , if how long live before expiry? they don't expire. reason there 2 because it's recommended regenerate keys periodically security reasons. example, suppose application using primary key today. if regenerated primary key, application broken until update , resulting in downtime. instead, can alter application utilize secondary key little or no downtime. then, after application has been updated, can regenerate primary key. next month (or whatever schedule like), can repeat process, switching primary key , regenerating secondary key. this not unique notification hubs. see primary , seco...

asp.net - What is the typical method for securely exposing some data on a public website that is taken from internal databases? -

asp.net - What is the typical method for securely exposing some data on a public website that is taken from internal databases? - i have few internal databases , intranet site on server that's totally inaccessible outside world. , have external website on off-network server. there handful of info on internal databases want available on public website, internal databases contain sensitive info want away public site. how typically handled? not exclusively sure search for. right now, manually dump needed info xml file used website, sense there improve way go this. you have few options can think of, , more i'm list... not much of network guy. set firewall rule allows port requests external server's ip address internal database server. set external facing service exposes info wish share. can have authentication/authorization set on service allow users wish access info have access. additionally, set service allow calls external web site'...

Unix Socket C: Connecting from another network -

Unix Socket C: Connecting from another network - i'm starting larn how configure unix server/client basilar application in c tcp socket, thing is, connect client server using port i've take in server, , (local?) address 192.168.1.x. don't know it, presume 192 local interface address , connection can achieved in same network, i've tried 2 pcs still in same network. connection network? it's complicated thing? suppose passing network's provider ip client won't job usually in such case open router configuration web page in browser , in section "port forwarding/triggering" come in entry redirecting connections outside lan port on given machine on lan, e.g: # service name start port end port server ip address 1 myserveronport9875 9875 9875 192.168.1.7 given external ip 89.75.140.30 can connect anywhere telnet 89.75.140.30 9875 to reach port 9875 on local machine 192.168.1.7 assuming server ...