This file contains 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
def kde_deobfuscate(str) | |
chars = str.split("") | |
out = '' | |
while chars.any? | |
b1 = chars.shift | |
if b1 == 0xef.chr | |
case chars.shift | |
when 0xbe.chr | |
out << (0x1001F - chars.shift[0] - 0xff00).chr | |
when 0xbf.chr |
This file contains 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
de: | |
errors: | |
messages: | |
not_found: "nicht gefunden" | |
already_confirmed: "wurde bereits bestätigt" | |
not_locked: "ist nicht gesperrt" | |
devise: | |
failure: | |
unauthenticated: 'Sie müssen sich anmelden oder registrieren, bevor Sie weiterfahren können.' |
This file contains 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
# | |
# License: WTFPL (http://sam.zoy.org/wtfpl/) | |
# | |
namespace :secret do | |
desc 'Replace the secure secret key in your secret_token.rb' | |
task :replace do | |
pattern = /(\.secret_token *= *')\w+(')/ | |
secret = SecureRandom.hex(64) | |
filepath = "#{Rails.root}/config/initializers/secret_token.rb" |
This file contains 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
namespace :deploy do | |
desc "Moves and replaces the secret-token if missing in shared directory" | |
task :symlink_secret, :roles => :app, :except => { :no_release => true } do | |
filename = 'secret_token.rb' | |
release_secret = "#{release_path}/config/initializers/#{filename}" | |
shared_secret = "#{shared_path}/config/#{filename}" | |
if capture("[ -f #{shared_secret} ] || echo missing").start_with?('missing') | |
rake_command "secret:replace" | |
run "mv #{release_secret} #{shared_secret}" |
This file contains 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 ApplicationController < ActionController::Base | |
# A foreign key constraint exception from the database | |
rescue_from PG::Error do |exception| | |
message = exception.message | |
if message.include?('foreign key constraint') | |
logger.warn(message) | |
# shorten the message | |
message = message.match(/DETAIL: .+/).to_s | |
This file contains 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
# | |
# Scopes for date attribute | |
# https://gist.github.com/2235839 | |
# | |
module Common::DateScope | |
extend ActiveSupport::Concern | |
included do | |
unless respond_to?(:year) |
This file contains 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
# Monkey patch to fix Rails JSON error decoding | |
# https://gist.github.com/2244799 | |
class ActiveResource::Errors | |
def from_json(json, save_cache = false) | |
clear unless save_cache | |
decoded = ActiveSupport::JSON.decode(json) | |
if decoded.is_a?(Hash) |
This file contains 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
// bootstrap-sass mixin for responsive designs | |
// this mixin requires sass support for content blocks (sass >= 3.2.0) | |
// Media widths: | |
// http://twitter.github.com/bootstrap/scaffolding.html#responsive | |
// https://github.com/digineo/bootstrap-sass/commit/20828376f7cf72ec1ca808633dde186c5682ea97 | |
=respond-to($media) | |
@if $media == phone | |
@media only screen and (max-width: $mediaPhone) |
This file contains 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
# | |
# WillPaginate renderer for will_paginate 2.3.16 to generate HTML code for Twitter Bootstrap | |
# Put this content in in your config/initializers/will_paginate.rb | |
module WillPaginate | |
module ViewHelpers | |
class BootstrapLinkRenderer < LinkRenderer | |
def to_html |
This file contains 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
module PaginationHelper | |
# adds a pagination before and after the given block | |
def pagination(collection=nil, options={}, &block) | |
# no Collection given? then call collection method | |
collection ||= send :collection | |
pages = will_paginate(collection, options) | |
html = '' |
OlderNewer