Skip to content

Instantly share code, notes, and snippets.

View dcarneiro's full-sized avatar

Daniel Carneiro dcarneiro

  • Porto, Portugal
View GitHub Profile
@dcarneiro
dcarneiro / flow2
Created November 24, 2017 15:32
Flow 2
### Flow 2.0
#### Sequence Diagrams
##### When Invoice is transmitted
###### Sequence
```sequence
ScheduleFirstRequestEmailJob->InvoiceEventScheduler: schedule_first_request
Note right of InvoiceEventScheduler: Decide the 1st request date
Note right of InvoiceEventScheduler: Schedule the event without a channel
InvoiceEventScheduler-->ScheduleFirstRequestEmailJob: Ok!

Keybase proof

I hereby claim:

  • I am dcarneiro on github.
  • I am dcarneiro (https://keybase.io/dcarneiro) on keybase.
  • I have a public key ASBumS-l_ZIWVOfJC0lSaz6mFRIIGd8DHe_2DdmfG4wZbQo

To claim this, I am signing this object:

@dcarneiro
dcarneiro / sagas.js
Last active November 9, 2023 12:21
connect redux-saga to phoenix channel
function* connectToSocket(url) {
const socket = new Socket(socketBaseUrl() + url, { params: { token: 'your-auth-token' } });
socket.connect();
return socket;
}
// channel.join is async, this is probably an error
function* joinChannel(socket, channel_name) {
const channel = socket.channel(channel_name, {});
channel.join();
# This shell will get you the top x items for each group
# pe:
# if you have a csv with user_id, song_id, relevance
# this will sort the csv by user_id asc and then by relevance desc
# after that it will only print the top x results for each user to STDOUT
sort -t, -k 1,1n -k 3,3nr my.csv | awk -F, -v max_items=5 '{if (user_id != $1) {user_id=$1; count=1} ; if (count <= max_items) { print; } ; count+=1;}' > result.csv