Skip to content

Instantly share code, notes, and snippets.

@prusswan
prusswan / math puzzle.rb
Last active December 14, 2015 00:19
X+Y
h = Hash.new(0)
product = Hash.new([])
sum = Hash.new([])
(2..99).to_a.each do |x|
next if x == 99
((x+1)..99).to_a.each do |y|
# puts "#{x} #{y} #{x+y} #{x*y}"
puts product[x*y]
product[x*y] = product[x*y].push([x,y])
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
cd
sudo apt-get update
sudo apt-get upgrade
@prusswan
prusswan / graphite
Created March 15, 2013 05:29 — forked from drawks/graphite
#This is the "site config" for nginx
upstream django {
# Distribute requests to servers based on client IP. This keeps load
# balancing fair but consistent per-client. In this instance we're
# only using one uWGSI worker anyway.
ip_hash;
server unix:/tmp/uwsgi.sock;
}
server {
Boot Info Script e7fc706 + Boot-Repair extra info [Boot-Info 31Jan2013]
============================= Boot Info Summary: ===============================
=> Windows 7/8/2012 is installed in the MBR of /dev/sda.
=> Syslinux MBR (3.00-3.35) is installed in the MBR of /dev/sdb.
sda1: __________________________________________________________________________
@prusswan
prusswan / gnome-xmonad.desktop
Created April 7, 2013 17:49
xmonad config for Ubuntu Precise
[Desktop Entry]
Name=GNOME with Xmonad
Comment=A GNOME fallback mode session using xmonad as the window manager.
Exec=gnome-session-xmonad
TryExec=gnome-session
Icon=
Type=Application
# /usr/share/xsessions/gnome-xmonad.desktop
@prusswan
prusswan / gist:5703074
Last active December 18, 2015 01:19
Ruby and Rails offline docs generation
# rails
sdoc -x test -x example -x bin -N --main rails-3.2.13/README.rdoc --title "Rails 3.2.13" --op ~/Desktop/rails-3.2.13 rails-3.2.13
# ruby (rbenv)
sdoc --main ruby-1.9.3-p392/README -x test -x example -x bin -N --title "Ruby 1.9.3" --op ~/Desktop/ruby-1.9.3 ~/.rbenv/sources/1.9.3-p392/ruby-1.9.3-p392 ~/.rbenv/sources/1.9.3-p392/ruby-1.9.3-p392/README
sdoc --main ruby-1.9.3-p392/README -x test -x example -x bin -N --title "Ruby 1.9.3" --op ~/Desktop/ruby-1.9.3 ruby-1.9.3-p392 ruby-1.9.3-p392/README
# not working yet
sdoc --main ruby-2.0.0-p195/README -x test -x example -x bin -N --title "Ruby 2.0.0" --op ~/Desktop/ruby-2.0.0 ~/.rbenv/sources/2.0.0-p195/ruby-2.0.0-p195 ~/.rbenv/sources/2.0.0-p195/ruby-2.0.0-p195/README
@prusswan
prusswan / bundle-viz.rb
Created June 18, 2013 23:41
Customizing graphviz options for `bundle viz`
require 'graphviz'
require 'bundler'
module Bundler
class Graph
class GraphVizClient
def g
@g ||= ::GraphViz.digraph(@graph_name, {
:use => 'neato',
:concentrate => true,
@prusswan
prusswan / r4ia.txt
Last active December 19, 2015 11:29
Rails 4 in Action 1P review notes
1.2.4 Scaffolding
binstubs was only introduced later on, so bin/rails makes no sense
Listing 1.16
update(purchase_params) is used instead of update_attributes(params[:purchase])
## https://github.com/jnicklas/capybara
#=Navigating=
visit('/projects')
visit(post_comments_path(post))
#=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
# Setting up dnsmasq for Local Web Development Testing on any Device
Please note, these instructions are for OS X Lion.
First, you need to get the IP address of your machine on your local network. In OS X, the easiest place to find this is in System Preferences > Network. If you're using DHCP on your local network, you will want to make sure your computer requests the same IP address when it renews it's IP address lease. I recommend configuring the DCHP Reservation settings on your router to accomplish this. Otherwise, you can specify a manual address in your network settings:
1. Go to *System Preferences > Network*
1. Click *Advanced...*