Skip to content

Instantly share code, notes, and snippets.

View mariozig's full-sized avatar

Mario Zigliotto mariozig

  • Intuit
  • San Mateo, CA
View GitHub Profile
@mariozig
mariozig / mastermind.rb
Last active December 10, 2015 23:48
Source for the Mastermind game. Blog post @ http://ruby.zigzo.com/2013/01/10/building-mastermind/
class Game
COLORS = ["R", "G", "B", "Y", "O", "P"]
def initialize
@comp = Computer.new
@player = Player.new
end
def play
10.times do |i|
class Hangman
attr_accessor :words
def initialize
@words = []
@word = []
@hint = []
@guess = ""
@player = Player.new()
@computer = Computer.new()
def swingers(couples)
randomized_couples = couples.shuffle
randomized_couples.each_with_index do |couple, index|
if index != randomized_couples.length - 1
randomized_couples[index][1], randomized_couples[index+1][1] = randomized_couples[index+1][1], randomized_couples[index][1]
end
end
end
require "http/client"
class Word
def initialize(word)
raise ArgumentError.new "Not a single word" if word.split(" ").size > 1
@word = word
end
def wiki_title
wiki_page = WikipediaPage.new(@word)
@mariozig
mariozig / perm-solution.conf
Created July 8, 2012 05:59
perm solution
# Edits to /etc/sysctl.conf
kern.sysv.shmall=65536
kern.sysv.shmmax=16777216
@mariozig
mariozig / temp-solution.sh
Created July 8, 2012 04:17
temp solution
sudo sysctl -w kern.sysv.shmall=65536
sudo sysctl -w kern.sysv.shmmax=16777216
@mariozig
mariozig / console-errors.log
Created July 8, 2012 03:39
console errors
7/7/12 8:24:23.017 PM com.heroku.postgres-service: server starting
7/7/12 8:24:23.018 PM Postgres: 75469 /Applications/Postgres.app/Contents/MacOS/bin/pg_ctl: Status 0
7/7/12 8:24:23.117 PM com.heroku.postgres-service: FATAL: could not create shared memory segment: Invalid argument
7/7/12 8:24:23.117 PM com.heroku.postgres-service: DETAIL: Failed system call was shmget(key=5432001, size=14499840, 03600).
7/7/12 8:24:23.117 PM com.heroku.postgres-service: HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded your kernel's SHMMAX parameter. You can either reduce the request size or reconfigure the kernel with larger SHMMAX. To reduce the request size (currently 14499840 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
7/7/12 8:24:23.117 PM com.heroku.postgres-service: If the request size is already small, it's possible that it is less than your kernel's SHMMIN parameter, in which case raising the request size or
@mariozig
mariozig / gist:2980705
Created June 24, 2012 00:24
Liberating Working Moms - Link to Us HTML
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top"><img src="http://i1102.photobucket.com/albums/g459/wa_tracy/tracybutton3150.jpg" width="150" height="150" alt="Liberating Working Moms Button" /></td>
<td align="center" valign="top"><textarea cols="25" rows="7"><a href="http://liberatingworkingmoms.com" target="_blank"><img height="150" width="150" src=" http://i1102.photobucket.com/albums/g459/wa_tracy/tracybutton3150.jpg " border="0" /></a></textarea></td>
</tr>
</table>
posts = Post.all
Parallel.each(posts, :in_processes => 10) do |post|
post.title = post.title.downcase
post.save!
end
# Goes with
# http://ruby.zigzo.com/2012/01/29/the-parallel-gem-and-postgresql-oh-and-rails/
posts = Post.all
Parallel.each(posts, :in_processes => 10) do |post|
# Reconnect to prevent errors with Postgres
ActiveRecord::Base.connection.reconnect!
post.title = post.title.downcase
post.save!
end