Skip to content

Instantly share code, notes, and snippets.

View mxswd's full-sized avatar

Maxwell mxswd

View GitHub Profile
@mxswd
mxswd / bookmarks.rb
Created April 7, 2011 14:49
Tells you about your Chrome Bookmarks.
#!/usr/bin/ruby
# Go to chrome tools -> bookmark manager -> organize -> export -> call it bookmarks.html
# Run this from the same directory as the export
File.open('bookmarks.html', 'r') do |f|
urls, dups = [], []
domains = {}
while line = f.gets
url = line.match(/<A HREF="([^"]*)"/)
if url
@mxswd
mxswd / prime.c
Created June 24, 2011 03:26
Prime number generator. First 5gb's worth.
/* This code is in public domain. Use for whatever purpose at your own risk. */
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#define MAXN 10000000000ll /* maximum value of N */
#define P1 156250100ll /* = ceil(MAXN/64) */
#define P2 5000000000ll /* = ceil(MAXN/2) */
#define P3 50000ll /* = ceil(ceil(sqrt(MAXN))/2) */
@mxswd
mxswd / backup_check.rb
Created July 9, 2011 05:12
Mac OS X Checking if Backups work
#!/usr/bin/ruby
# remember to:
# sudo gem install pony
require 'rubygems'
require 'pony'
# -k Sender com.apple.backupd-auto
# This option specifies what recorded the log.
@mxswd
mxswd / .zshrc
Created August 21, 2011 12:54
My .zshrc
# maxs
# History
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
# task warrior
fpath=($fpath /usr/local/Cellar/task/1.9.4/share/doc/task/scripts/zsh)
@mxswd
mxswd / classdiagram.gv
Created September 21, 2011 01:13
Class Diagram / ERD Graphviz example. Compile with `dot -Tpdf diagram.gv > diagram.pdf`
digraph models_diagram {
graph[overlap=false, splines=true]
"Venue" [shape=record, label="{\
Venue|name :string\l\
}"]
"User" [shape=record, label="{User|\
email :string\l\
password :string\l\
}"]
@mxswd
mxswd / java_uml.rb
Created October 2, 2011 10:03
Java Graphviz UML Generator
#!/usr/bin/env ruby
raise "Usage: ruby main.rb ../java_program/src" unless ARGV[0]
java_files = Dir.glob(ARGV[0] + "/**/*.java")
@klasses = []
java_files.each do |java_file|
@class_name = nil
@methods = []
File.open(java_file).each_line do |line|
@mxswd
mxswd / email_stats.rb
Created December 5, 2011 15:39
Statistics on email activity.
#!/usr/bin/env ruby
# email_stats.rb
# ======================`README.md`========================
#
# Email Stats
# ===========
#
# Requirements
# ------------
@mxswd
mxswd / Rakefile
Created December 16, 2011 02:53
Ruby Without Bundler
# Run this on dev machine, to download the .gem files to install.
# Spec the gems in the Gemfile and `bundle install` first.
task :bundle do
sh "bundle package"
end
# Run this on deploy location, to install and compile the
# .gem files with native extensions.
task :bundle_go do
sh "gem install --no-ri --no-rdoc --install-dir vendor/ vendor/cache/*.gem"
@mxswd
mxswd / insta-importo.rb
Created January 26, 2012 12:41
Import articles from a feed into Instapaper
# gem install faraday nokogiri
require 'faraday'
require 'nokogiri'
START_PAGE = "/Articles/Classic-WTF-What-Is-Truth.aspx"
USERNAME = "INSTAPAPER USERNAME"
PASSWORD = "INSTAPAPER PASSWORD"
$conn = Faraday.new(:url => "https://www.instapaper.com") do |builder|
builder.request :url_encoded
@mxswd
mxswd / shopping.yml
Created July 22, 2012 02:35
My shopping list script
---
:items:
- :name: Drink Grapefruit
:price: '4.59'
:owner: max
:paid:
:max: 0
:ritwik: 314