Skip to content

Instantly share code, notes, and snippets.

View scribu's full-sized avatar

Cristi Burcă scribu

View GitHub Profile
@scribu
scribu / package-setup.sh
Created December 24, 2013 01:05
Set up the package index for WP-CLI
#!/usr/bin/env bash
if [ -z "$INSTALL_DIR" ]; then
INSTALL_DIR=$HOME/.wp-cli
fi
mkdir -p "$INSTALL_DIR"
cd "$INSTALL_DIR"
if [ ! -x composer.phar ]; then
@scribu
scribu / README.md
Last active August 5, 2019 09:59
Convert notes from Tomboy XML to Evernote XML

This is a quick script to convert notes from Tomboy to Evernote.

Usage

pip install -r requirements.txt
mkdir export/
python tomboy-export.py <tomboy-dir>
@scribu
scribu / adb-su.py
Created September 3, 2013 23:33
Make adb work as if you had true root access.
import sys
import subprocess
# Requirements:
# - `adb` command locally
# - `su` command on device
def use_su(cmd):
to_escape = ['*', '|']
@scribu
scribu / generate-key-mac.sh
Last active September 7, 2016 14:43 — forked from floydpink/travis-secure-key-mac.sh
Generating secure environment variables for GitHub deployment keys to be used from a Travis-CI build.
#!/usr/bin/env bash
# On OS X, use this script to generate an encrypted deployment key for Travis CI.
# Dependencies:
# gem install travis
# brew install coreutils
if [ $# -lt 1 ]; then
echo "usage: $0 <user>/<repo>"
@scribu
scribu / stdin-stream_select.php
Created August 8, 2013 00:31
Proof of concept: read content from STDIN; doesn't block if there's nothing there. Works by assuming that content will be available on STDIN immediately, which might not always be the case.
<?php
$read = array(STDIN);
$write = null;
$except = null;
if ( stream_select($read, $write, $except, 0) > 0 ) {
$content = stream_get_contents($read[0]);
} else {
$content = false;
#!/bin/bash
# rndsound.sh - make a wav from the RNG source
# must be run as root: sudo ./rndsound.sh
# needs sox toolkit: sudo apt-get install sox libsox-fmt-all
# created by scruss on Mon Jun 3 23:07:54 EDT 2013
# length of sample, seconds
DURATION=5
# output file
OUTFILE=random$(date +%Y%m%d%H%M%S).wav
@scribu
scribu / ask_hidden.php
Created June 27, 2013 15:39
CLI: Prompt for sensitive data, like passwords, but hide input
<?php
/**
* Ask for input, but make it hidden.
*/
function ask_hidden( $prompt ) {
echo $prompt;
echo "\033[30;40m"; // black text on black background
$input = fgets( STDIN );
@scribu
scribu / wpformat
Created June 8, 2013 12:39
WordPress code formatting utility
#!/usr/bin/php
<?php
/**
* Takes some code from STDIN, fixes whitespace according to the WordPress Coding Standards and outputs it to STDOUT
* Usage example: wpformat < some-file.php > some-file.php
*/
// Read file from standard input
$file = '';
@scribu
scribu / gist:5660088
Last active December 17, 2015 19:19
bash arg handling inside functions
#!/usr/bin/env bash
function fn_star() {
for word in "$*"; do
echo $word
done
}
function fn_at() {
for word in "$@"; do
# Install Xcode, Command Line Tools, Xquartz (on 10.8)
# In a terminal (probably best to do one thing at a time):
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php
brew install php54 --with-mysql
chmod -R ug+w /usr/local/Cellar/php54/5.4.7/lib/php
pear config-set php_ini /usr/local/etc/php/5.4/php.ini