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 / dk_group.py
Last active October 3, 2024 20:12
Command line interface to group raw and normal files in a Digikam album.
#!/usr/bin/env python3
# -*- coding: utf8 -*-
#####
# Copyright (C) 2015 J. Sabater
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@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 / 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.