Skip to content

Instantly share code, notes, and snippets.

View typeoneerror's full-sized avatar
🤠
iOS, Capacitor, Ember, Vue, Rails

Benjamin Borowski typeoneerror

🤠
iOS, Capacitor, Ember, Vue, Rails
View GitHub Profile
@everm1nd
everm1nd / rubocop.sh
Last active January 8, 2020 04:31
Run Rubocop locally for changed files only
git status --porcelain | grep -v "D " | cut -c4- | grep "\.rb\|rake" | xargs rubocop -a
import Ember from 'ember';
import config from 'garaje/config/environment';
// based on https://karl-sjogren.com/2015/08/05/lazy-loading-extra-scripts-in-ember/
const LOADING = {};
function scriptLoader(id, src, parent = 'head') {
let promise;
@vasinov
vasinov / gist:8855052
Created February 7, 2014 00:03
generate_authentication_token
def generate_authentication_token
loop do
token = Devise.friendly_token
hashed_token = BCrypt::Password.create(token)
update_attribute(:token_id, Devise.friendly_token)
final_token = "#{token_id}-#{token}"
break { token: final_token, hashed_token: hashed_token } unless User.where(authentication_token: hashed_token).first
end
@wheeyls
wheeyls / application_controller.rb
Last active May 15, 2022 07:04
A cached key-value store backend for Rails I18n. Designed to speed up translations when using a database like Redis or Mongo.
class ApplicationController < ActionController::Base
before_filter :ensure_fresh_i18n
private
def ensure_fresh_i18n
I18n.backend.ensure_freshness! I18n.locale
end
end
@tobscher
tobscher / custom_plan.rb
Created January 30, 2013 15:39
Zeus engine setup.
require 'zeus/rails'
ROOT_PATH = File.expand_path(Dir.pwd)
ENV_PATH = File.expand_path('spec/dummy/config/environment', ROOT_PATH)
BOOT_PATH = File.expand_path('spec/dummy/config/boot', ROOT_PATH)
APP_PATH = File.expand_path('spec/dummy/config/application', ROOT_PATH)
ENGINE_ROOT = File.expand_path(Dir.pwd)
ENGINE_PATH = File.expand_path('lib/my_engine/engine', ENGINE_ROOT)
class CustomPlan < Zeus::Rails
@shripadk
shripadk / gist:652819
Created October 29, 2010 03:10
Express authentication using Redis for session store and Couchdb for database (in coffeescript!)
###
Module dependencies
###
require.paths.unshift "#{__dirname}/lib/support/express-csrf/"
require.paths.unshift "#{__dirname}/lib/support/node_hash/lib/"
express = require 'express'
app = module.exports = express.createServer()
RedisStore = require 'connect-redis'