Skip to content

Instantly share code, notes, and snippets.

View trivektor's full-sized avatar
🏠
Working from home

Tri Vuong trivektor

🏠
Working from home
View GitHub Profile
Paul Rand
• Design is the method of putting form and content together. Design, just as art, has multiple definitions; there is no single definition. Design can be art. Design can be aesthetics. Design is so simple, that's why it is so complicated.
• Providing, meaning to a mass of unrelated needs, ideas, words and pictures - it is the designer's job to select and fit this material together and make it interesting.
• Simplicity is not the goal. It is the by-product of a good idea and modest expectations.
Shigeo Fukuda
@trivektor
trivektor / connection_fix.rb
Created May 2, 2012 00:39 — forked from defunkt/connection_fix.rb
MySQL server has gone away fix
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/
@trivektor
trivektor / string_ext.rb
Created May 11, 2012 01:51 — forked from erskingardner/string_ext.rb
Convert String to Boolean value
class String
def to_bool
return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
return false if self == false || self.blank? || self =~ (/(false|f|no|n|0)$/i)
raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
end
end

Routing in Ember

In Ember, the application's state manager handles routing. Let's take a look at a simple example:

App.stateManager = Ember.StateManager.create({
  start: Ember.State.extend({
    index: Ember.State.extend({
      route: "/",
config.action_controller.asset_host = Proc.new { |source, request = nil, *_|
request && request.ssl? ? 'https://s3.amazonaws.com/my_bucket' : 'http://s3.my-domain.com'
}
@trivektor
trivektor / gist:2792423
Created May 26, 2012 05:32
Turn off auto assets generation in Rails 3.1+
1/ rails generate controller controller_name --assets=false
or
2/ Add these lines to application.rb:
config.generators.stylesheets = false
config.generators.javascripts = false
@trivektor
trivektor / gist:2897545
Created June 8, 2012 18:48
Useful Vagrant commands
1/ Create a box file
vagrant box add uitl http://dl.dropbox.com/u/8072848/centos-5.7-x86_64.box
2/ vagrant init
3/ vagrant up
4/ vagrant ssh
5/ vagrant box list
Fix SSL certificate error when installing RVM on Centos
echo insecure >> ~/.curlrc
and then install as normal
@trivektor
trivektor / README.md
Created June 24, 2012 03:50 — forked from aiwilliams/README.md
Storyboard in RubyMotion 1.4

Start XCode and create a new Storyboard file. I closed all my other XCode projects. When you choose the location of the created file, it should be your RubyMotion project's resources directory. Add a UIViewController, and set it's identifier property to "Start". Add some UI elements so you can see it working.

When you run rake in your RubyMotion project, it will compile the .storyboard file. You could auto-load the Storyboard using a plist configuration, but you'll see code can do it too.

@trivektor
trivektor / gist:3117786
Created July 15, 2012 17:24 — forked from postnati/gist:1075624
PhoneGap Watchr
watch /src\/.*\.haml/ do |md| `thor convert:haml` end
watch /src\/.*\.rb/ do |md| `thor convert:haml` end
watch /src\/.*\.scss/ do |md| `thor convert:sass` end
watch /src\/.*\.sass/ do |md| `thor convert:sass` end
watch /src\/.*\.coffee/ do |md| `thor convert:coffee` end