Skip to content

Instantly share code, notes, and snippets.

@sharno
sharno / anonymous_recursive1.exs
Last active February 2, 2018 16:35
As Elixir doesn't have a way to create an anonymous recursive function yet, we have to do a little trick and pass the function to itself when calling it to get recursion
print = fn f ->
receive do
name -> IO.puts(name)
f.(f)
end
end
server = spawn(fn -> print.(print) end)
send(server, "Sharno")
@sharno
sharno / learnHaskell.hs
Created October 3, 2017 04:45
Lecture notes for Bartosz Milewski's videos on Haskell
:l <filename> -- load
:r -- reload
:q -- quit
:t <expression> -- type
:i -- info
:k <something> -- kind
:sprint <expression> -- prints an expression without evaluation
------------------------------------
-- this is a comment
<!DOCTYPE html>
<meta charset="utf-8">
<style>
text{
font-size:12px;
}
.mainBars rect{
shape-rendering: auto;
fill-opacity: 0;
stroke-width: 0.5px;
@sharno
sharno / recon 2.2 metabolites with only producers or with only consumers
Created November 22, 2016 12:24
recon 2.2 metabolites with only producers or with only consumers
10fthf7glu_e
12RHPET_c
12harachd_r
12ppd_R_c
15HPET_r
17ahprgnlone_m
17ahprgstrn_m
18harachd_r
1a2425thvitd2_m
1a2425thvitd3_m
{'',
'Alanine and aspartate metabolism',
'Alkaloid synthesis',
'Aminosugar metabolism',
'Androgen and estrogen synthesis and metabolism',
'Arachidonic acid metabolism',
'Arginine and Proline Metabolism',
'Bile acid synthesis',
'Biotin metabolism',
'Blood group synthesis',
[(u'HMDB00211',
[u'cis-1,2,3,5-trans-4,6-cyclohexanehexol',
u'i-inositol',
u'iso-inositol',
u'meat sugar',
u'meso-inositol',
u'mi',
u'myo-inositol',
u'myoinosite',
u'myoinositol',
[('R_group_phosphotase_3', 'R group phosphotase 3'),
('r0068',
'Acetyl adenylate:CoA ligase (AMP-forming) Pyruvate metabolism EC:6.2.1.1'),
('r0082',
'Oxalosuccinate:NADP+ oxidoreductase (decarboxylating) Citrate cycle (TCA cycle) EC:1.1.1.42'),
('r0083',
'Oxalosuccinate:NADP+ oxidoreductase (decarboxylating) Citrate cycle (TCA cycle) EC:1.1.1.42'),
('r0084',
'Oxalosuccinate:NADP+ oxidoreductase (decarboxylating) Citrate cycle (TCA cycle) EC:1.1.1.42'),
('r0097', 'Acetate:CoA ligase (AMP-forming) Pyruvate metabolism EC:6.2.1.1'),
from selenium import webdriver
import time, json
browser = webdriver.Firefox()
browser.implicitly_wait(10)
browser.get('http://reporterslab.org/fact-checking/')
data = {}
data = {}
import json
import csv
with open("amr.json", "r") as f:
data = json.load(f)
data = sorted([(x['_id'], x['sent']) for x in data])
data2 = [(data[0][0], data[0][1], data[0][1])]
for i in range(1, len(data)):
data2.append((data[i][0], data[i][1], data[i][1] + data2[i-1][2]))
import sys
import pandas as pd
file_names = [sys.argv[1], sys.argv[2]]
frames = []
output_filename = ""
for file_name in file_names: