Skip to content

Instantly share code, notes, and snippets.

View elecnix's full-sized avatar

Nicolas Marchildon elecnix

View GitHub Profile
@elecnix
elecnix / setup-openwrt-usb.sh
Last active August 29, 2015 14:13
Setup USB storage for vfat USB key on OpenWrt (without OpenWrt internet acccess)
BASE_URL=https://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/base/
TARGET_IP=192.168.1.1
TARGET_USER=root
KERNEL_VERSION=3.10.49-1
HARDWARE=ar71xx
MODULES="kmod-fs-vfat kmod-nls-base kmod-nls-cp437 kmod-nls-iso8859 kmod-scsi-core kmod-usb2 kmod-usb-storage"
for MOD in MODULES do
wget $MOD_$KERNEL_$VERSION_$HARDWARE.ipk
done
wget $BASE_URL/block-mount_2014-06-22-e0430f5c62f367e5a8e02755412977b02c3fc45e_ar71xx.ipk
cat top-1m.csv | sed -e 's_.*,\(.*\)_echo | openssl s\_client -connect \1:443 > certs/\1.pem\&_' > certs.sh
bash certs.sh
ls certs | xargs -L1 -I DOMAIN echo 'openssl x509 -in certs/DOMAIN -text -noout > checks/DOMAIN.check' > checks.sh
bash checks.sh
cat top-1m.csv | sed -e 's#.*,\(.*\)#\1#'| xargs -n1 -P20 -I DOM grep -H 'Not After' checks/DOM.pem.check 2>/dev/null | cut -d ':' -f 1,3-|sed -e 's_checks/\(.*\).pem.check: \(.*\)_\1,\2_' > top-1m-expiry.csv
#!/usr/bin/perl
#
# Feeds ganglia with web server error rate information.
#
# The latest version can be found on GitHub:
#
# http://gist.github.com/14352
#
# This script can be called by Apache by setting up a special logger:
#
require 'rubygems'
require 'mechanize'
postal_codes = File.open("postal_codes.txt").read.split("\n")
# randomize to make the pattern slightly harder to see in logs
postal_codes = postal_codes.sort_by {|e| rand(10_000)}
@agent = WWW::Mechanize.new do |a|
a.user_agent_alias = 'Mac Safari'
a.max_history = 1
require 'rubygems'
require 'mechanize'
# Generates a CVS list: Postal Code, District ID, District Name
# Use like this:
# $~/postal_codes/A$ ruby /path/to/extract_elections_ca 2>/dev/null >> districts.csv
postal_codes = File.open("postal_codes.txt").read.split("\n")
postal_codes.each do |postcode|
postcode.sub! ' ', ''
@elecnix
elecnix / bash-git-prompt
Created November 25, 2008 22:31
Displays the current git branch name and the dirty state in your Bash shell prompt
#!/bin/bash
#
# Displays the current git branch name and the dirty state in your Bash shell
# prompt. Add a line like this to your ~/.bashrc file:
#
# . ~/path/to/gist/bash-git-prompt
#
# To use this, you must enable "enable programmable completion features".
# Look at your ~/.bashrc for something like:
#
@elecnix
elecnix / get-all-railscasts.rb
Created November 27, 2008 02:28
Download railscasts.com archive
require 'rubygems'
require 'mechanize'
require 'net/http'
agent = WWW::Mechanize.new do |a|
a.user_agent_alias = 'Mac Safari'
end
archive = agent.get("http://railscasts.com/episodes/archive")
episodes = archive.links.select do |link|
@elecnix
elecnix / git-travel-test.sh
Created November 28, 2008 02:59
Keep two huge disks in sync with git
# Read carefully. This script is mostly useless.
# It demonstrates how git could help keep two huge disks in sync, one bigger than the other.
# Execute like this:
# bash -xf git-travel-test
set -e
echo "suppose we build a really really big repo"
mkdir repo1
cd repo1
@elecnix
elecnix / get-grails-podcasts.rb
Created November 29, 2008 17:10
Downloads podcasts from grailspodcast.com
#!/usr/bin/ruby
# Downloads podcasts from http://www.grailspodcast.com
# Creates files named like this example:
# grails_podcast_episode_17 - Interview with Jason Rudolph.mp3
require 'rubygems'
require 'mechanize'
agent = WWW::Mechanize.new do |a|
a.user_agent_alias = 'Mac Safari'
@elecnix
elecnix / get-all-podcasts.rb
Created November 27, 2008 02:43
Downloads podcast.rubyonrails.org audio archive.
require 'rubygems'
require 'mechanize'
require 'net/http'
agent = WWW::Mechanize.new do |a|
a.user_agent_alias = 'Mac Safari'
end
archive = agent.get("http://podcast.rubyonrails.org/programs/1/transcripts")
episodes = archive.links.select do |link|