Skip to content

Instantly share code, notes, and snippets.

View icco's full-sized avatar
🏠
Working from home

Nat Welch icco

🏠
Working from home
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@icco
icco / cdn.txt
Last active December 26, 2015 16:39
CDN tests using siege.
http://pubnub.a.ssl.fastly.net/pubnub-3.4.6.min.js
http://storage.googleapis.com/calvin166-test/pubnub-3.4.6.min.js
http://s3.amazonaws.com/test.icco.me/pubnub-3.4.6.min.js
http://d1cq9hp03zvonx.cloudfront.net/pubnub-3.4.6.min.js
#! /usr/bin/env ruby
require 'benchmark'
require 'open-uri'
n = 50
Benchmark.bm(12) do |x|
x.report("base:") { 1.upto(n) { a = "1" } }
x.report("fastly:") { 1.upto(n) { open("http://pubnub.a.ssl.fastly.net/pubnub-3.4.6.min.js") } }
x.report("gcs:") { 1.upto(n) { open("http://storage.googleapis.com/calvin166-test/pubnub-3.4.6.min.js") } }
require 'xmlsimple'
Dir.glob('*/*.nfo').each {|f| xs = XmlSimple.new; config = xs.xml_in(f); config.delete 'fileinfo'; p xs.xml_out(config); break }
@icco
icco / n.rb
Created October 27, 2013 12:18 — forked from anonymous/n.rb
require 'fileutils'
Dir.glob('/Volumes/Downloads/torrents/Naruto Shippuuden Season 13 720p/*mkv').sort.each do |f|
episode = (File.basename(f).scan /\d\d\d/).first
file_name = "/Volumes/TV/Naruto Shippuuden/Naruto Shippuuden 13x#{episode.to_i - 260}.mkv"
puts "#{episode}: #{f.inspect} => #{file_name.inspect}"
FileUtils.cp f, file_name
end
[ Mon May 20 10:39:52 ]
[ natwelch@MobileNat ~ ]$ irb
1.9.2p290 :001 > a = (0...10).to_a
=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
1.9.2p290 :002 > n = 4
=> 4
1.9.2p290 :003 > a[n..-1]
=> [4, 5, 6, 7, 8, 9]
@icco
icco / Gemfile
Last active December 12, 2015 02:38
A very simple sinatra site.
source 'https://rubygems.org'
gem 'sinatra'
<!doctype html>
<html>
<head>
<title>A Message</title>
<link href='http://fonts.googleapis.com/css?family=Arvo:400,700' rel='stylesheet' type='text/css'>
<style>
h1 {
font-family: 'Arvo', serif;
font-weight: 700;
text-align: center;
@icco
icco / entertain-mac.sh
Created March 13, 2012 21:36
entertain.sh
#!/bin/bash
clear;
while true; do
for i in $(ls /); do
code=${code}`dd bs=1 count=32 if=/dev/urandom 2> /dev/null | md5 | grep -o '\w*'`;
done;
echo $code;
code=0;
done;
@icco
icco / gist:1310409
Created October 24, 2011 21:39
Niket's Code thing
# <Niket Desai 2:36> define a method
# <Niket Desai 2:36> that when given (assumed) > 0 integer value
# <Niket Desai 2:36> will return a random string of alphabet characters
# <Niket Desai 2:36> where alphabet chars CAN be reused
# Niket
def alphabet(num)
alpha_array = []
(1..num).each { |i| alpha_array[i] = ('a'..'z').to_a.shuffle[0] }