Skip to content

Instantly share code, notes, and snippets.

View joninvski's full-sized avatar

Joao Trindade joninvski

View GitHub Profile
@joninvski
joninvski / bellman.py
Created November 16, 2010 11:31
Bellman ford python implementation
import pdb
"""
The Bellman-Ford algorithm
Graph API:
iter(graph) gives all nodes
iter(graph[u]) gives neighbours of u
graph[u][v] gives weight of edge (u, v)
"""
@joninvski
joninvski / spec.json
Created November 2, 2020 23:50
Vega-Lite spec from Mon Nov 02 2020
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {
"url": "https://covid.ourworldindata.org/data/owid-covid-data.csv",
"format": {"parse": {"date": "date"}}
},
"transform": [
{
"filter": {
"or": [
@joninvski
joninvski / spec.json
Created October 30, 2020 15:56
Vega-Lite spec from Fri Oct 30 2020
{
"$schema":"https://vega.github.io/schema/vega-lite/v4.json",
"data":{
"url":"https://covid.ourworldindata.org/data/owid-covid-data.csv",
"format":{
"parse":{
"date":"date"
}
}
},

How git works

Word of warning: you don't need to use the command line, but you need to know the basics. Please first know how to do things in their simplest form and only then move to magic GUIs.

Starting (or my very first two commits)

  1. It all starts with a git init
@joninvski
joninvski / OpenDay.md
Last active June 26, 2019 13:47
Onfido OpenDay

Convict the scammer 👮

Let's try the Onfido API. We have captured four criminals that we know have spoofed their IDs. Please use onfido to run checks on their ids.

Title First Name Last Name Email Country Address town Date of Birth
Miss Patricia Scarlett patricia@onfido.com PT Barreiro 08/08/1957
Professor Tom Plum tom@onfido.com GB Liverpool 09/11/1948
Mrs Mafalda Peacock mafalda@onfido.com PT Lisboa 28/07/1966

Python Example

Read csv

import csv
 
with open('suspects.txt') as csv_file:
    csv_reader = csv.reader(csv_file, delimiter=',')
 for row in csv_reader:

Ruby Example

Read csv

require 'csv'
 
data = CSV.read('suspects.csv')
 
data.each { |r|

Keybase proof

I hereby claim:

  • I am joninvski on github.
  • I am joaotrindade (https://keybase.io/joaotrindade) on keybase.
  • I have a public key ASD9UyzVe2ZdTlhoUYbavD8GYubD-rwai-7N99rjSU87Xwo

To claim this, I am signing this object:

require 'twilio-ruby'
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new account_sid, auth_token
# Get an object from its sid. If you do not have a sid,
# check out the list resource examples on this page
@account = @client.accounts.get("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
@account.update(:status => "suspended")