Skip to content

Instantly share code, notes, and snippets.

class Player
def initialize
@max_health = 20
@last_health = @max_health
@taking_damage = false
@directions = [:backward, :forward]
@current_direction = :forward
@reached_wall = false
end
@paav-o
paav-o / gist:2926262
Created June 13, 2012 20:18
Nakkikoneen datamalliluonnos
# app/models/event.rb
class Event < ActiveRecord::Base
field :name, :type => String # "Maailmanlopun reivit"
field :date, :type => Date # "2012-12-21"
field :description, :type => String # "Osallistumalla nakkiin pääset maksutta bileisiin..."
has_many :tasks
end
@paav-o
paav-o / rails-install-ubuntu.sh
Created January 26, 2012 09:45
rails-install-ubuntu
echo "Updates packages. Asks for your password."
sudo apt-get update -y
echo "Installs packages. Give your password when asked."
sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev -y
echo "Installs ImageMagick for image processing"
sudo apt-get install imagemagick --fix-missing -y
echo "Installs RVM (Ruby Version Manager) for handling Ruby installation"
@paav-o
paav-o / linkedin_industry_codes.rb
Created January 11, 2012 15:06
LinkedIn API Industry Codes
industry_codes = Hash.new
(1..150).each do |industry_code|
query = "http://api.linkedin.com/v1/company-search:(companies:(industry))?facet=industry,"+industry_code.to_s+"&count=1&format=json"
linkedin_response = JSON.parse(previously_acquired_access_token.get(query).body)
industry_codes[industry_code] = linkedin_response.try(:[], "companies").try(:[], "values").try(:[], 0).try(:[], "industry")
end
@paav-o
paav-o / convore_backup.rb
Created December 15, 2011 17:35
Varmuuskopio Convoresta
require 'httparty'
auth = { :username => "oma_nick", :password => "oma_salasana" }
#groups = HTTParty.get("https://convore.com/api/groups.json", :basic_auth => auth)
#puts YAML::dump(groups)
#=> tässä tapauksessa haluttu id on 2648
topics = HTTParty.get("https://convore.com/api/groups/2648/topics.json", :basic_auth => auth)
all_topics = topics["topics"]