Skip to content

Instantly share code, notes, and snippets.

@nudomarinero
nudomarinero / toggle.py
Last active August 29, 2015 14:15
Toggle on and off the touch screen in a Dell XPS 13 with Linux
#!/usr/bin/env python
from __future__ import print_function
from subprocess import check_output, check_call
device_name = "Synaptics Large Touch Screen"
def get_device_number():
"""
Get the device number of the device using xinput.
@nudomarinero
nudomarinero / bash_anaconda
Created February 12, 2015 11:40
Functions in bash to activate or deactivate Anaconda. They can be added to the bashrc file and allow to go back quickly to the system Python if needed.
## Anaconda
# Based on http://stackoverflow.com/questions/370047/what-is-the-most-elegant-way-to-remove-a-path-from-the-path-variable-in-bash#370255
anaconda () {
path=$(IFS=':';t=($PATH);n=${#t[*]};a=();for ((i=0;i<n;i++)); do p="${t[i]%%*anaconda*}"; [ "${p}" ] && a[i]="${p}"; done;echo "${a[*]}");
export PATH=~/anaconda/bin:$path
}
noanaconda () {
path=$(IFS=':';t=($PATH);n=${#t[*]};a=();for ((i=0;i<n;i++)); do p="${t[i]%%*anaconda*}"; [ "${p}" ] && a[i]="${p}"; done;echo "${a[*]}");
export PATH=$path
@nudomarinero
nudomarinero / gist:92e13f5da0fb799c8797
Last active August 29, 2015 14:20
example of asurv called with pexpect
import pexpect
file_in = "input.dat"
file_out = "output.txt"
c = pexpect.spawn ('asurv')
c.expect('(CARRIAGE RETURN TO CONTINUE)')
c.sendline('')
c.expect('(CARRIAGE RETURN TO CONTINUE)')
c.sendline('')
#!/usr/bin/env python
"""
Solutions to the problem proposed in http://gu.com/p/493zk/stw
"""
from itertools import permutations
from decimal import Decimal
def p(x):
"""
Define the problem. Follow the canonical order of operations
@nudomarinero
nudomarinero / macjournal2zim.py
Created February 20, 2016 16:16
Transform MacJournal individual text entries to Zim
from __future__ import print_function
import locale
import datetime
import re
import os
from os.path import isfile, join
import unicodedata
from unidecode import unidecode
@nudomarinero
nudomarinero / ref.md
Created October 12, 2016 11:20
Referencias y enlaces adicionales de la charla de la PyConES 2016
#!/usr/bin/env python
import sys
import PyQt5
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QThread, QUrl
from PyQt5.QtWebKitWidgets import QWebView
from bottle import Bottle
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nudomarinero
nudomarinero / read_accel.py
Created November 22, 2015 18:38
Get the acceleration data of a LightBlue Bean using Python
from __future__ import print_function
from bluetooth.ble import GATTRequester
from time import sleep
def get_accel(data):
"""
Get the acceleration values from the data
TODO: Add CRC check
See: http://legacy.punchthrough.com/bean/the-arduino-reference/accelerationreading/
"""
@nudomarinero
nudomarinero / download.bash
Created December 4, 2018 12:07
Download the data from the first SKA science data challenge
#!/bin/bash
# Images
wget https://owncloud.ia2.inaf.it/index.php/s/UDiKqvuscDQViEt/download -O SKAMid_B1_8h.fit
wget https://owncloud.ia2.inaf.it/index.php/s/2nTtGBWpzYJ5Ghr/download -O SKAMid_B1_100h.fit
wget https://owncloud.ia2.inaf.it/index.php/s/DUNztYKW0PSlNH5/download -O SKAMid_B1_1000h.fit
wget https://owncloud.ia2.inaf.it/index.php/s/zEW4JsefeMycR8p/download -O SKAMid_B2_8h.fit
wget https://owncloud.ia2.inaf.it/index.php/s/8K750vop1yjZZXE/download -O SKAMid_B2_100h.fit
wget https://owncloud.ia2.inaf.it/index.php/s/A7XjSZ3n1Kr57TV/download -O SKAMid_B2_1000h.fit
wget https://owncloud.ia2.inaf.it/index.php/s/Uu7yhRjCYknle54/download -O SKAMid_B5_8h.fit
wget https://owncloud.ia2.inaf.it/index.php/s/7lEeXlNvoYFmEfG/download -O SKAMid_B5_100h.fit