Skip to content

Instantly share code, notes, and snippets.

@ariofrio
ariofrio / install.sh
Created April 28, 2012 06:00
Install Adobe Air 2.6 on Fedora 16
# This script will download the Adobe Air installer to the
# current directory. Just sayin'.
#
# Instructions from: http://www.zealfortechnology.com/2011/11/install-adobe-air-fedora-16.html
echo "-----> Installing dependencies"
sudo yum install ld-linux.so.2 gtk2-devel.i686 libdbus-glib-1.so.2 libhal.so.1 rpm-devel.i686 libXt.so.6 gnome-keyring-devel.i686 libDCOP.so.4 libxml2-devel.i686 nss-devel.i686 libxslt.i686 xterm rpm-build libgnome-keyring.i686
echo "-----> Downloading installer"
wget --continue http://airdownload.adobe.com/air/lin/download/2.6/AdobeAIRInstaller.bin
This file has been truncated, but you can view the full file.
@ariofrio
ariofrio / post-receive
Created July 25, 2012 21:48
Post-receive script for Goatee deployment, inspired by Heroku
#!/bin/bash
# Fail fast.
set -e
# Debug.
# set -x
function indent() {
c='s/^/ /'
@ariofrio
ariofrio / debug.cpp
Created December 2, 2012 02:13
C++ output stream proxy that adds a prefix to every line
#include "debug.h"
debug_stream debug;
*.io.run
@ariofrio
ariofrio / install-wp-nfshost.sh
Created May 18, 2013 09:16
Script that installs Wordpress on NearlyFreeSpeech.net. Takes care of safe_mode permissions, temporary folder, and automatic installation of plugins, etc.
#!/bin/sh
set -ex
cd /home/public
# Download Wordpress
wget http://wordpress.org/latest.tar.gz
tar -xf latest.tar.gz
rm latest.tar.gz
mv wordpress/* .
rmdir wordpress
@ariofrio
ariofrio / gist:8295235
Created January 7, 2014 06:05
Get the first two words of the names of all people in a Facebook Graph Search
var els = document.querySelectorAll("#browse_result_area [data-bt='{\"ct\":\"title\"}'] a");
var ret = ""
for(var i=0; i<els.length; i++) {
ret += /\w+ \w+/.exec(els[i].textContent) + ",";
}
@ariofrio
ariofrio / colors-utils.js
Created May 6, 2014 22:35
RGB parsing functions in Javascript
// http://stackoverflow.com/a/5624139/237285
function rgbToHex(r, g, b) {
return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
}
function hexToRgb(hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? [
parseInt(result[1], 16),
parseInt(result[2], 16),
@ariofrio
ariofrio / main.jsx
Created July 6, 2015 23:40
Using Director.js with React.js (uses ES6 extensions)
import router from './router.jsx';
import A from './A.jsx';
import B from './B.jsx';
import C from './C.jsx';
router.on('/a', () => { React.render(<A />, document.body); });
router.on('/b', () => { React.render(<B />, document.body); });
router.on('/c', () => { React.render(<C />, document.body); });
router.init();
export function mapValues<A, B>(
obj: { [key: string]: A },
f: (x: A) => B
): { [key: string]: B } {
const rv: { [key: string]: B } = {}
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
rv[key] = f(obj[key])
}