Skip to content

Instantly share code, notes, and snippets.

@jorgehatccrma
jorgehatccrma / recursive-resample.sh
Last active June 29, 2023 14:48
Recursively resample a bunch of audio files in a directory, using sox
#!/bin/bash
# A simple script to recursively resample a bunch of files
# in a directory. Only certain file extensions (mp3, aac,
# flac, wav) are considered.
#
# It takes 2 command line options: `indir` and `outdir`.
# The destination (`outdir`) is relative to the current
# directory of where you were when the script was run.
#
@jorgehatccrma
jorgehatccrma / awk1liners.md
Created April 12, 2018 18:20
AWK one liners

HANDY ONE-LINE SCRIPTS FOR AWK

Based on this gist compiled by Eric Pement - eric [at] pement.org

USAGE:

awk '/pattern/ {print "$1"}'    # standard Unix shells

FILE SPACING:

@jorgehatccrma
jorgehatccrma / colors.sh
Last active March 23, 2018 17:30
Small bash script to print terminal color codes with bash
cumwidth=7
for i in {0..255}; do
printf "\x1b[38;5;${i}m [%03i] \x1b[0m" $i ;
if [ $i -eq $cumwidth ]; then
echo ;
if [ $cumwidth -ge 15 ]; then
((cumwidth+=6))
else
((cumwidth+=8))
fi ;
@jorgehatccrma
jorgehatccrma / demoLuceneJython.py
Last active April 12, 2019 09:33
Lucene + Jython
"""
This simple Jython script shows how to use Apache Lucene
directly in a Jython script
"""
# your usual Python imports
import sys
from contextlib import contextmanager
# add jars to classpath
@jorgehatccrma
jorgehatccrma / OSM_ways_2_polygons.py
Created October 24, 2017 16:45
Using OSM's Overpass QL it is fairly trivial to retrieve the boundary of an administrative region (e.g. country). These boundaries can be land or maritime. The problem is that these boundaries are returned as a set of `ways` (i.e. linestrings). Some ways are closed (the first and last point coincide) while others are not, and need to be strung t…
# -*- coding: utf-8 -*-
import logging
from collections import defaultdict
import overpy
from shapely.geometry.polygon import Polygon
from shapely.geometry.multipolygon import MultiPolygon
def ways2poly(ways):
@jorgehatccrma
jorgehatccrma / grok_vi.mdown
Last active February 25, 2017 06:22 — forked from nifl/grok_vi.mdown
Your problem with Vim is that you don't grok vi.

Answer by Jim Dennis on Stack Overflow question http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118

Your problem with Vim is that you don't grok vi.

You mention cutting with yy and complain that you almost never want to cut whole lines. In fact programmers, editing source code, very often want to work on whole lines, ranges of lines and blocks of code. However, yy is only one of many way to yank text into the anonymous copy buffer (or "register" as it's called in vi).

The "Zen" of vi is that you're speaking a language. The initial y is a verb. The statement yy is a simple statement which is, essentially, an abbreviation for 0 y$:

0 go to the beginning of this line. y yank from here (up to where?)

@jorgehatccrma
jorgehatccrma / MonomialFinding.ipynb
Last active August 29, 2015 14:19
3freq monomial finding relevant code
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jorgehatccrma
jorgehatccrma / resonantSequences.ipynb
Last active August 29, 2015 14:18
Resonant Sequences
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env python
# encoding: utf-8
from gevent import monkey; monkey.patch_all()
from socketio.namespace import BaseNamespace
from socketio import socketio_manage
from bottle import route, request, static_file, run
import logging
@jorgehatccrma
jorgehatccrma / webCompTest.html
Last active December 28, 2015 18:18
polymer bug?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<!-- Including this makes the code below crash -->
<!--script src="libs/polymer.min.js"></script-->
<script type="text/javascript" src="libs/jquery-1.9.1.js"></script>
</head>