This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copy and paste this to the rails console to test your email settings | |
class MyMailer < ActionMailer::Base | |
def test_email | |
@recipients = "[email protected]" | |
@from = "[email protected]" | |
@subject = "test from the Rails Console" | |
@body = "This is a test email" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'RMagick' | |
include Magick | |
PIXEL = ["&", "8", "0", "$", "2", "1", "|", ";", ":", "'", " ", " "] | |
colors = PIXEL.size - 1.0 | |
# load image | |
oimg = ImageList.new("mario.jpg") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# script/runner for rails 3.0 | |
APP_PATH = File.expand_path('../../config/environment', __FILE__) | |
require 'rubygems' | |
require 'rails/commands/runner' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you post to a Ruby on Rails REST API endpoint, then you'll get an | |
# InvalidAuthenticityToken exception unless you set a different | |
# content type in the request headers, since any post from a form must | |
# contain an authenticity token. | |
# | |
# This example shows you how to post to a rails endpoint. | |
require 'json' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If you don't use underscore.js, use it (http://documentcloud.github.com/underscore/) | |
// Then, use underscore's mixin method to extend it with all your other utility methods | |
// like so: | |
_.mixin({ | |
escapeHtml: function () { | |
return this.replace(/&/g,'&') | |
.replace(/>/g,'>') | |
.replace(/</g,'<') | |
.replace(/"/g,'"') | |
.replace(/'/g,'''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If you switch to kaminari, | |
http://railscasts.com/episodes/254-pagination-with-kaminari | |
...the lines added to application.js become redundant when you implement the pager like in this demo project: | |
https://github.com/amatsuda/kaminari_example/tree/ajax | |
in index.html: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
puts "input N" | |
i=gets.to_i | |
m=[1] | |
1.upto i do |j| | |
puts "input N#{j}" | |
k=gets.to_i | |
m.unshift m[0]*(k+1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Keyboard shortcuts for browsing pages of lists | |
(function($) { | |
$(document).keydown(handleKey); | |
function handleKey(e) { | |
var left_arrow = 37; | |
var right_arrow = 39; | |
if (e.target.nodeName == 'BODY' || e.target.nodeName == 'HTML') { | |
if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey) { | |
var code = e.which; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# auto deploy script | |
# content: sync update all servers code, control unicorn servers and thin servers | |
# by liuzihua | |
default_environment["LC_CTYPE"] = "en_US.UTF-8" | |
# servers! | |
set :server1, "124.42.34.226" | |
set :server2, "124.42.34.238" | |
set :server3, "119.254.7.196" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js'></script> | |
<script> | |
$(document).ready(function(){ | |
function debug(str){ $("#debug").append("<p>"+str+"</p>"); }; | |
if(typeof WebSocket === 'undefined') { | |
alert("Your browser does not support websockets.") | |
} |
OlderNewer