Skip to content

Instantly share code, notes, and snippets.

View balkian's full-sized avatar

J. Fernando Sánchez balkian

View GitHub Profile
class RecursiveDict(UserDict):
def __getitem__(self, k):
if not isinstance(k, Iterable):
return self.data[k]
dest = self.data
for j in k:
dest = dest[j]
return dest
@balkian
balkian / set-default-browser.sh
Created August 30, 2017 17:52
Set default browser
xdg-settings set default-web-browser chromium.desktop
NEUTRAL = 0
INFECTED = 1
class ControlModelM2(BaseBehaviour):
NEUTRAL = 0
INFECTED = 1
def step(self, now):
if self.state['id'] == NEUTRAL:
self.neutral_behaviour()
elif self.state['id'] == INFECTED:
@balkian
balkian / Demo.ipynb
Created May 5, 2017 09:50
Demo gsitk
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@balkian
balkian / example.tex
Created May 4, 2017 07:36
Rotated headers in latex tables
\usepackage{adjustbox}
\usepackage{array}
\newcolumntype{R}[2]{%
>{\adjustbox{angle=#1,lap=\width-(#2)}\bgroup}%
l%
<{\egroup}%
}
\newcommand*\rot{\multicolumn{1}{R{45}{1em}}}% no optional argument here, please!
@balkian
balkian / 4_4.ipynb
Last active April 20, 2017 11:20
SITC Classification
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
#import selenium.webdriver.firefox.webdriver as fwb
import selenium.webdriver.chrome as cwd
from selenium.webdriver.support import expected_conditions as EC
import time
import os
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import json
from senpy import Client
client = Client('http://senpy.cluster.gsi.dit.upm.es')
with open('madrid.json', 'r') as f:
for line in f:
tweet = json.loads(line.strip())
results = client.analyse(input=tweet['text'], algorithm='sentiText')
tweet['sentiment'] = results.entries[0].sentiments[0]
@balkian
balkian / octo.sh
Last active December 28, 2016 01:36
Simple script to control octoprint
begin
button = KEY_5
prog = irexec
config = /home/balkian/octo.sh home
repeat = 0
delay = 3
end
begin
button = KEY_1
prog = irexec