Skip to content

Instantly share code, notes, and snippets.

@itorres
itorres / config.scm
Created October 27, 2018 23:22 — forked from TeMPOraL/config.scm
GuixSD with custom kernel
(define-module (my packages)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (gnu packages linux)
#:use-module (guix build-system trivial)
#:use-module (gnu)
#:use-module (guix download)
#:use-module (guix git-download)
#:use-module (guix packages))
(define (linux-nonfree-urls version)
@itorres
itorres / sort_torrents.py
Created January 7, 2017 14:03
This script sorts a directory full of torrents into subdirectories per tracker.
#!/usr/bin/env python3.5
import os
from urllib.parse import urlparse
def read_header(h):
assert(h[:11] == b'd8:announce')
ann_head_end = h.index(b':',11)
announce_length = int(h[11:ann_head_end])
announce_start = ann_head_end + 1
@itorres
itorres / boto3_hands_on.md
Created January 2, 2017 12:06 — forked from iMilnb/boto3_hands_on.md
Programmatically manipulate AWS resources with boto3 - a quick hands on

boto3 quick hands-on

This documentation aims at being a quick-straight-to-the-point-hands-on AWS resources manipulation with [boto3][0].

First of all, you'll need to install [boto3][0]. Installing it along with [awscli][1] is probably a good idea as

  • [awscli][1] is boto-based
  • [awscli][1] usage is really close to boto's
@itorres
itorres / rename-shell.el
Created July 13, 2016 14:33
Emacs function to rename shell buffer based on path and tramp host (if this is a tramp buffer)
(defun my-rename-shell-buffer ()
"Rename the current shell buffer name."
(interactive)
(let ((candidate-name
(concat
(if (string-prefix-p "/ssh:" default-directory)
(concat tramp-current-host ":")
"")
(file-name-base (directory-file-name default-directory)))))
(rename-buffer (format "*shell* <%s>" candidate-name))))
@itorres
itorres / 20160316-OCC-host-not-found-error
Created March 16, 2016 23:28
OCC FreeBSD errors for folders with > 50000 files Raw
magellan:~$ owncloud --logfile -
03-17 00:04:41:709 101382 OCC::Application::setupLogging: "################## ownCloud ca_ES () 2.1.1"
03-17 00:04:41:709 101382 OCC::Application::setupTranslations: void OCC::Application::setupTranslations() Using "ca_ES" translation
03-17 00:04:41:711 101382 unknown: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-itorres'
03-17 00:04:41:712 101382 OCC::SocketApi::SocketApi: SocketApi: server started, listening at "/tmp/runtime-itorres/ownCloud/socket"
03-17 00:04:41:712 101382 OCC::FolderMan::FolderMan: setting remote poll timer interval to 30000 msec
03-17 00:04:41:841 101382 OCC::FolderMan::setupFolders: * Setup folders from settings file
03-17 00:04:41:841 101382 OCC::Folder::checkLocalPath: Checked local path ok
03-17 00:04:41:842 101382 OCC::FolderMan::addFolderInternal: Adding folder to Folder Map OCC::Folder(0x812677c00)
@itorres
itorres / 20160316-OCC-too-many-files-error
Created March 16, 2016 23:27
OCC FreeBSD errors for folders with > 50000 files
magellan:ownCloud$ owncloud --logfile -
03-17 00:00:25:862 101358 OCC::Application::setupLogging: "################## ownCloud ca_ES () 2.1.1"
03-17 00:00:25:862 101358 OCC::Application::setupTranslations: void OCC::Application::setupTranslations() Using "ca_ES" translation
03-17 00:00:25:864 101358 unknown: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-itorres'
03-17 00:00:25:864 101358 OCC::SocketApi::SocketApi: SocketApi: server started, listening at "/tmp/runtime-itorres/ownCloud/socket"
03-17 00:00:25:864 101358 OCC::FolderMan::FolderMan: setting remote poll timer interval to 30000 msec
03-17 00:00:25:945 101358 OCC::FolderMan::setupFolders: * Setup folders from settings file
03-17 00:00:25:945 101358 OCC::Folder::checkLocalPath: Checked local path ok
03-17 00:00:25:946 101358 OCC::FolderMan::addFolderInternal: Adding folder to Folder Map OCC::Folder(0x812677c00)
03-17 00:00:25:946 101358 OCC::FolderWatcherPrivate::slotAddFolderRecursive: (+) Watcher: "/usr/home/itorres/ownCloud
@itorres
itorres / flac2opus.py
Created December 10, 2014 10:53
Quick script to transcode a flac music collection to opus
#!/usr/bin/env python
import os
import sys
basedir = sys.argv[1]
for root, dirs, files in os.walk(basedir):
cmd = 'avconv -i "{infile}" -map 0:a -codec:a \
opus -b:a 48k -vbr on "{outfile}"'
print "Visiting", root
@itorres
itorres / gist:e8f242e292689d1ae6c2
Created November 7, 2014 01:22
Count wrong registrations by IP in an asterisk logfile
# model:
# [Nov 4 12:26:52] NOTICE[416] chan_sip.c: Registration from '"x" <sip:x@1.2.3.4:5060>' failed for '1.2.3.4' - No matching peer found
awk '/failed for/ {count[$12]++}END{for (j in count) printf "%8i %s\n", count[j],j }' messages|sort -n

Keybase proof

I hereby claim:

  • I am itorres on github.
  • I am itorres (https://keybase.io/itorres) on keybase.
  • I have a public key whose fingerprint is 2CCB 85E6 8AEC C336 5ADF 1C14 A728 61BC 6411 65EA

To claim this, I am signing this object:

@itorres
itorres / gist:2b88920c18af52b686c8
Created October 5, 2014 14:25
A quick hack to get an object with the devices in firefoxosdevices.org.
function firefoxosdevicesIndex() {
var r = { 'd': {}, 's': {} };
devices = document.querySelectorAll(".ag-device");
for (var i = 0; i < devices.length; i++) {
var model = devices[i].querySelector(".ag-name").textContent.trim();
var specs = devices[i].querySelectorAll("dt");
r['d'][model] = {};
for (var j = 0; j < specs.length; j++) {
var spec = specs[j].textContent.trim(),
value = specs[j].nextSibling.textContent.trim();