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 File.expand_path(File.join(File.dirname(__FILE__), 'config', 'environment')) | |
if File.exist?('config/database.yml') | |
database_platform = YAML.load_file(File.join("config/database.yml"))[Rails.env] | |
database_platform.delete("socket") | |
ActiveRecord::Base.establish_connection(database_platform) | |
ActiveRecord::Base.connection.execute("ALTER DATABASE `#{database_platform['database']}` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci\;") | |
ActiveRecord::Base.connection.tables.each {|table|ActiveRecord::Base.connection.execute("ALTER TABLE `#{table}` CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci\;")} | |
puts "Successfully converting database collation" | |
else |
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
#!/bin/sh | |
sqlite3 ~/Library/Application\ Support/Dock/*.db 'DELETE from apps; DELETE from groups WHERE title<>""; DELETE from items WHERE rowid>2;' && killall Dock |
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
$.ajaxSetup | |
statusCode: | |
401: -> $.pub('flash:show', text: "You have been logged out. Please, <a href='javascript:window.location.reload()'><span class='icon'>X</span>refresh</a> the page", type: 'warning', hide: false) | |
404: -> $.pub('flash:show', text: "Page not found", type: 'warning', hide: false) | |
500: -> $.pub('flash:show', text: "Oops! Something went wrong.", type: 'warning', hide: false) | |
error: -> $.pub('flash:show', text: "Can't connect to the server. Please, check your internet connection.", type: 'warning', hide: false) | |
timeout: -> $.pub('flash:show', text: "Server is not response. Please, <a href='http://turbinehq.com/contact/'>report about that to us</a>.", type: 'warning', hide: false) |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.IO; | |
namespace drawwell | |
{ | |
class Program | |
{ |
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
[alias] | |
di = diff | |
dc = diff --cached | |
amend = commit --amend | |
aa = add --all | |
head = !git l -1 | |
h = !git head | |
r = !git --no-pager l -20 | |
ra = !git r --all | |
ff = merge --ff-only |
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 Float | |
def notches_rounding(notches=2) | |
rounded = (self * notches).round / notches.to_f | |
rounded % 1 == 0 ? rounded.to_i : rounded | |
end | |
end unless Float.respond_to? :notches_rounding |
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
When /^I wait for the ajax request to finish$/ do | |
until page.evaluate_script('jQuery.isReady&&jQuery.active==0') do | |
sleep 0.05 | |
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
isDivider = (n, d)-> n % d is 0 | |
maxDivider = (i)-> parseInt(Math.sqrt(i)) | |
sumOfDividers = (n)-> | |
sum = 1; | |
i = 2 | |
while i <= maxDivider(n) | |
if isDivider(n, i) | |
sum += i |
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
# config/initializers/array_wrap.rb | |
class Array | |
def self.wrap(object) | |
if object.nil? | |
[] | |
elsif object.respond_to?(:to_ary) | |
object.to_ary || [object] | |
else | |
[object] |
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
$(document).on 'click', 'input[type=checkbox]', -> | |
$("label[for=#{$(@).attr('id')}]").toggleClass 'checkbox-checked', $(@).is(':checked') |