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
# ruby expand.rb /path/to/files | |
Dir["#{ARGV[0]}/**/*"].each do |file| | |
if file =~ /\.(rb|scss|css|erb|sql|conf|html|js)$/ | |
`expand -t 2 #{file} > #{file}.tmp` | |
`mv #{file}.tmp #{file}` | |
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
local http = require "socket.http" | |
local function url_encode(str) | |
if (str) then | |
str = string.gsub (str, "\n", "\r\n") | |
str = string.gsub (str, "([^%w ])", | |
function (c) return string.format ("%%%02X", string.byte(c)) end) | |
str = string.gsub (str, " ", "+") | |
end | |
return str |
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
growMessageBody: function() { | |
var messageBody = $("message_body"); | |
var rows = messageBody.value.split('\n').length; | |
if (rows <= 1) | |
rows = 2; | |
if (rows >= 10) | |
rows = 10; | |
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
class ActiveOhm < Ohm::Model | |
include ActiveModel::Validations | |
include ActiveModel::Conversion | |
extend ActiveModel::Naming | |
include Ohm::Boundaries | |
include Ohm::Callbacks | |
include Ohm::Timestamping | |
include Ohm::Typecast | |
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 'redis/list' | |
require 'redis/value' | |
class RedisModel | |
include ActiveModel::Validations | |
include ActiveModel::Conversion | |
extend ActiveModel::Naming | |
attr_accessor :id | |
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
protected override void DataPortal_Update() | |
{ | |
RaiseListChangedEvents = false; | |
using (SqlConnection cn = new SqlConnection(Database.LocalConnection)) | |
{ | |
cn.Open(); | |
// loop through each deleted child object | |
// foreach (Sales deletedChild in DeletedList) | |
// // deletedChild.DeleteSelf(cn); | |
// DeletedList.Clear(); |
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 'erubis' | |
class Verb | |
def call(env) | |
base_path = File.join(Dir.pwd, env["REQUEST_URI"].sub(/\/$/, "")) | |
exact_path = base_path + ".rhtml" | |
index_path = File.join(base_path, "index.rhtml") | |
if File.exists?(exact_path) | |
render(exact_path, env) |
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
SELECT HOUR(CONVERT_TZ(created_at, '+00:00','-07:00')) AS hour, COUNT(DISTINCT uuid) as count FROM hits WHERE DATE(created_at) = DATE(NOW()) GROUP BY HOUR(created_at); |
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 'fastercsv' | |
def normalize(row) | |
row[2].sub!(/^0+/, "") | |
row[3].sub!(/^0+/, "") | |
return row | |
end | |
old_rows = FasterCSV.read "old.csv" |
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
// To get delimited values as an array | |
if (!string.IsNullOrEmpty(input)) | |
items = input.Split(new[] { ",", " ", ";" }, StringSplitOptions.RemoveEmptyEntries); | |
// To put them back together with a standard delimiter | |
var output = string.Join(", ", items); |