Skip to content

Instantly share code, notes, and snippets.

@chrisyour
chrisyour / gist:11183907
Created April 22, 2014 15:36
Build Help: Get Started with Rails
# Open bash.rc in Terminal using the 'mate' command
mate ~/.bashrc
# Do you have this line in your .bashrc file? The PostgresApp should have added PostgresApp to your PATH.
PATH="/Applications/Postgres.app/Contents/Versions/9.3/bin:$PATH"
// CakePHP Enkoder
// USAGE:
// Uses the same syntax as $html->link($title, $url, $htmlAttributes, $confirmMessage, $escapeTitle)
<?=$enkode->mailto('Email Me', 'user@example.com', array('subject'=>'Hello world!'))?>
// HELPER:
// app/views/helpers/enkode.php
// CakePHP Block Helper
// Ever wanted a clean way to capture a block of HTML in your CakePHP view and use it later in your layout just like CakePHP uses $content_for_layout?
// I use Rails all the time and take content_for for granted. I recently started a CakePHP project and noticed the absence of a simple content_for method to capture a block of HTML.
// For this example we are creating a helper named $cake, a controller named 'main', and using a layout named 'app'.
// HELPER:
// CakePHP Block Helper
// Ever wanted a clean way to capture a block of HTML in your CakePHP view and use it later in your layout just like CakePHP uses $content_for_layout?
// I use Rails all the time and take content_for for granted. I recently started a CakePHP project and noticed the absence of a simple content_for method to capture a block of HTML.
// For this example we are creating a helper named $cake, a controller named 'main', and using a layout named 'app'.
// HELPER:
# Install Passenger with RVM / Ruby 1.9.1
rvm 1.9.1 ; gem install passenger ; which passenger-install-nginx-module
# Install Apache module
rvmsudo passenger-install-apache2-module
# Restart Apache
sudo /usr/sbin/apachectl restart
# If needed (when --default doesn't stick)
(From @wayneeseguin)
This example shows how to setup an environment running Rails 3 beta under 1.9.1 with a 'rails3' gem set.
∴ rvm update --head
# ((Open a new shell))
# If you do not already have the ruby interpreter installed, install it:
∴ rvm install 1.9.1
@chrisyour
chrisyour / Test Project.jsfl
Created November 4, 2010 17:15
Flash CS4/CS5 Project Panel: "Test Project" Keyboard Shortcut
// # I've assumed you've downloaded and installed the Flash CS4/CS5 Project Panel update at: http://www.gskinner.com/blog/archives/2010/07/project_panel_u.html
// # 1. Create this file in: /Users/{you}/Library/Application Support/Adobe/Flash CS4/en/Configuration/Commands
// # 2. Then go to Flash => Keyboard Shortcuts...
// # 3. Create your shortcut under the Commands menu, I use 'Cmd+Opt+P'
function call_method(p_panelName, p_function, p_param){
l = fl.swfPanels.length;
if (l == 0) return 'false';
for (i=0; i<l; i++){
@chrisyour
chrisyour / Polly.rb
Created November 17, 2010 22:11
My quest to create new Rails 3 Double Sided Polymorphic Gem
# Ok, I'm creating a paired down version of Has_Many_Polymorphs in Rails 3 and making use of Arel. A great way to learn!
# Super simple setup:
class Content < ActiveRecord::Base
polly :parents => :posts, :children => [:images, :paragraphs, :quotes]
end
class Post < ActiveRecord::Base
end
@chrisyour
chrisyour / ie.sass
Created November 22, 2010 18:36
How to make display:inline-block; compatible with IE 6 and IE 7
// One of the biggest problems with Internet Explorer 6 and 7 is the lack of display:inline-block support.
// I use inline-block all the time. It's very handy. I'm ready to bug test in IE and of course, the main CSS problems
// are with inline-block.
// Using Compass you can remove that pain. Compass has cross-browser support for inline-block.
// Enjoy.
@import "compass/css3/inline-block";
ul{
@chrisyour
chrisyour / .bashrc
Created December 2, 2010 22:36
Git Branch Status in the Command Prompt (OSX)
# A minimally beautiful command prompt:
# user: directory (branch):
# Place this in ~/.bashrc
export PS1="\u: \W"'$(__git_ps1 " (%s)")'": "
# Place this is /etc/profile to ensure Terminal sources ~/.bashrc when it launches
[ -r $HOME/.bashrc ] && source $HOME/.bashrc