Skip to content

Instantly share code, notes, and snippets.

View apirak's full-sized avatar

Apirak Panatkool apirak

View GitHub Profile
@apirak
apirak / install_ruby_and_rails.md
Created March 16, 2012 02:03
Install ruby and rails on OSX, Linux and Windows

Install Ruby and Rails

Ruby now come preinstalled on many Linux distributions, and Mac OS X includes Ruby). Try typing ruby -v at a command prompt--you may be pleasantly surprised.

If you don't already have Ruby on your system or if you'd like to upgrade to a newer version (remembering that this couse describes Ruby 1.9), you can install it pretty simply. What you do next depends on your operating system.

Install Ruby on Windows

  1. Download http://railsinstaller.org/ from Apple Application Store :
@apirak
apirak / Hangman.rb
Created March 23, 2012 14:38
Hangman games with out class
@words = %w{spiderman superman powerpuf hangman}
@finish = false
@limit = 8
@win = false
@word = @words[rand(@words.length-1)]
@answer = "_" * @word.length
def guest(answer)
@limit -= 1
@apirak
apirak / hangman.rb
Created March 23, 2012 14:42
Hangman game with simple class
require_relative 'hangman_class'
hangman = Hangman.new
hangman.start
until hangman.finish
puts hangman.answer
print "#{hangman.limit} Enter your best guess: "
hangman.guess(gets)
@apirak
apirak / hangman.rb
Created March 23, 2012 14:49
Hangman game with class and yield
require_relative 'hangman_class_2'
hangman = Hangman.new
hangman.start do
puts hangman.answer
print "#{hangman.limit} Enter your best guest: "
hangman.guess(gets)
end
@apirak
apirak / hangman.rb
Created March 23, 2012 14:51
Hangman game with class, yield and self
require_relative 'hangman_class_3'
hangman = Hangman.new
hangman.start do |h|
puts h.answer
print "#{h.limit} Enter your best guest: "
h.guess(gets)
end
@apirak
apirak / meta_currency.rb
Created March 23, 2012 15:02
Meta programming example with currency expert
currency = {usd: 1, baht: 30.73, yen: 83.447, rupee: 50.21}
[Float, Fixnum].each do |number|
currency.each do |key, value|
number.class_eval "def #{key};
return self/#{value};
end"
number.class_eval %{def #{key}_string;
return (self * #{value}).to_s+" #{key.upcase}";
end}
@apirak
apirak / gist:2497293
Created April 26, 2012 07:49
opendream services page
<div>
<h1>services</h1>
<p>
Opendream services bring Internet technology to our client-friends and non-profit organisations.<br/>
<br/>
We commit a long term partnership, support those to utilise the power of the Internet for their organisation in sustainably way, provide innovative Internet applications on powerful open platform, connect people together, and save the world.<br/>
<br/>
Our social-mind-passion-driven technologists are so keen on Internet technology adaptation for social impact, we're unique.
</p>
</div>
@apirak
apirak / gist:2497342
Created April 26, 2012 08:00
opendream about page
<div>
<h2>About Opendream</h2>
<p>
<img src="http://opendream.co.th/sites/all/themes/opendream/images/dreamer-03.png" />
Information is power. Opendream weaving information systems to your control, excelling the power of your organization.<br/>
<br/>
We are a social enterprise with expertise in Internet solution development and information design. All the Opendream crews are digital natives from diverse backgrounds and experiences, with one single bold aim — deliver the information, change the world.<br/>
</p>
<p>
<img src="http://opendream.co.th/sites/all/themes/opendream/images/dreamer-04.png" />
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" viewBox="0 0 559 783" width="559pt" height="783pt">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:date>2012-05-10 01:04Z</dc:date>
<!-- Produced by OmniGraffle Professional 5.3.6 -->
</metadata>
<defs>
<filter id="Shadow" filterUnits="userSpaceOnUse">
<feGaussianBlur in="SourceAlpha" result="blur" stdDeviation="3.488" />
<feOffset in="blur" result="offset" dx="0" dy="4" />

How to install Nginx Mysql and PHP on Ubuntu

  1. Set root by default

    $ sudo -s

  2. Make sure that we use last update of apt-get

    $ apt-get update