Skip to content

Instantly share code, notes, and snippets.

@wvega
wvega / grupomide-ssh-snippets.sh
Created March 19, 2010 20:40
Create video thumbnails with ffmpeg
# create a thumbnail for a video with ffmpeg
ffmpeg -itsoffset -16 -i video.flv -vcodec mjpeg -vframes 1 -an -f rawvideo -s 142x94 thumbnail.jpg
# ...
video=video.flv; ffmpeg -itsoffset -16 -i $video -vcodec mjpeg -vframes 1 -an -f rawvideo -s 142x94 "`basename $video .flv`.jpg"
# remove last charater from filename of JPG files with filename ending in M
ls *M.jpg | while read line; do echo mv $line `echo $line | sed 's/\(.*\)M.jpg/\1.jpg/'`; done
@wvega
wvega / natural-sequence.py
Created April 1, 2010 04:46
Natural Numbers Stream
#!/usr/bin/python
# Copyright (c) 2010 Willington Vega, http://wvega.com/
# Licensed under WTFPL (http://sam.zoy.org/wtfpl/)
class NaturalSequence:
def __init__(self, digit, length=None):
"""Creates a stream to generate natural numbers whose first digit is self.digit.
if length is given only numbers of that length will be generated"""
self.digit = digit
self.length = length
@wvega
wvega / unauth.user.js
Created April 14, 2010 19:33
UN Web Authentication
// ==UserScript==
// @name UN Web Authentication
// @namespace scripts.wvega.com
// @include https://200.24.8.8/login.html
// ==/UserScript==
var inputs = document.getElementsByTagName('input'),
username = inputs[6],
password = inputs[7],
submit = inputs[8];
@wvega
wvega / fixtures.php
Created April 29, 2010 16:11
CakePHP Fixtures Shell
<?php
/* CakePHP fixtures shell */
ini_set('memory_limit', '512M');
require_once CAKE_TESTS_LIB.'cake_test_model.php';
require_once CAKE_TESTS_LIB.'cake_test_fixture.php';
class FixturesShell extends Shell {
/**
* Truncates all tables and loads fixtures into db
*
@wvega
wvega / random-color.js
Created June 4, 2010 16:51
Random HEX colors
/* Generate random colors
* source: http://twitter.com/rem/status/15427387974 */
'#' + (~~(Math.random() * 16777215)).toString(16)
@wvega
wvega / httpd-conf.py
Created June 24, 2010 19:38
Helper script to quickly setup Apache VirtualHosts on my laptop
#!/usr/bin/python
#
# helper script to quickly setup Apache VirtualHosts on my laptop
import os
import sys
HTTPD_CONF_DIR = '/var/www/conf.d'
HTTPD_DOCUMENT_ROOT = '/var/www/html'
@wvega
wvega / imdb-sort.py
Created August 17, 2010 04:21
IMDB Movie Sorter
#!/usr/bin/python
import imdb
import os
import re
# (?:\[.+) everything after an opening bracket
# (?:(?:\.|\()(?:\d{4}.*)) everything after a period followed by a year
@wvega
wvega / jquery.lazyload.js
Created November 9, 2010 01:36
jQuery LazyLoad
(function($, window){
$.LazyLoader = function(elements, options) {
var self = this;
self.elements = elements;
self.timeout = null;
self.options = $.extend({}, self.defaults, options);
window.bind('scroll.lazyload', function(event) {
// clearTimeout(self.timeout);
@wvega
wvega / minecraft-install.sh
Created December 4, 2010 18:14
Downloads and install Minecraft (http://minecraft.net) in Linux
#!/bin/sh
DESKTOP=/usr/share/applications/minecraft.desktop
INSTALL=/usr/local/minecraft
JAVA=/usr/java/latest/bin/java
MINECRAFT='http://www.minecraft.net/download/minecraft.jar'
mkdir $INSTALL
cd $INSTALL
@wvega
wvega / Makefile
Created December 25, 2010 18:48
Compiles cocos2d against installed Android SDK and creates a JAR file
# Compiles cocos2d against installed Android SDK and creates a JAR file
#
# Usage:
#
# 1. Checkout latest source
# svn checkout http://cocos2d-android.googlecode.com/svn/trunk/ .
# 2. Set ${SDK} and ${API} to reflect your current configuration
# 3. Run make
SDK := /usr/local/android-sdk-linux-86/platforms/