Skip to content

Instantly share code, notes, and snippets.

rocLv rocLv

Block or report user

Report or block rocLv

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
rocLv /
Created Feb 25, 2019 — forked from bjmc/
Basic setup script for installing Sentry ( + Redis on new Ubuntu 14.04 Amazon EC2 instance
#! /bin/bash
export RUN_AS='ubuntu';
export INSTALL_DIR='/var/www/sentry';
HOSTNAME=''; # No trailing slash
rocLv / rails.ipynb.json
Created Apr 25, 2018 — forked from l15n/rails.ipynb.json
Rails and Jupyter
View rails.ipynb.json
"cells": [
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
"outputs": [
View gist:9c99516d6225a8c3b305c0d7c8d180b5

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

rocLv /
Created Nov 11, 2017 — forked from JeffPaine/
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
View application.rb
require_relative 'boot'
require 'csv'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
module Giant
class Application < Rails::Application
View json_helper.rb
module RequestHelper
def json_response
JSON.parse(response.body, symbolize_names: true)
class ActionDispatch::IntegrationTest
include RequestHelper
rocLv / redis.rb
Created Apr 19, 2017 — forked from pubis/redis.rb
Redis config and initialization for rails
View redis.rb
require 'redis'
require 'redis/objects'
REDIS_CONFIG = YAML.load( Rails.root.join("config/redis.yml") ) ).symbolize_keys
dflt = REDIS_CONFIG[:default].symbolize_keys
cnfg = dflt.merge(REDIS_CONFIG[Rails.env.to_sym].symbolize_keys) if REDIS_CONFIG[Rails.env.to_sym]
$redis =
Redis::Objects.redis = $redis
View ai.rb
require 'curb'
require "json"
require "base64"
require "net/http"
require "uri"
CUID = "8132533";
CLIENT_ID = "your_client_id";
CLIENT_SECRET = "your_client_secret";
rocLv / company.rb
Created Apr 18, 2017 — forked from davinmsu/company.rb
remove duplicates from activerecord
View company.rb
def self.dedupe
# find all models and group them on keys which should be common
grouped = all.group_by{|model| [model.title,,model.address,] }
grouped.values.each do |duplicates|
# the first one we want to keep right?
first_one = duplicates.shift # or pop for last one
# if there are any more left, they are duplicates
# so delete all of them
duplicates.each{|double| double.destroy} # duplicates can now be destroyed
rocLv / custom_logger.rb
Created Apr 7, 2017 — forked from kinopyo/custom_logger.rb
Custom logger file in Rails
View custom_logger.rb
# lib/custom_logger.rb
class CustomLogger < Logger
def format_message(severity, timestamp, progname, msg)
"#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n"
logfile ="#{Rails.root}/log/custom.log", 'a') # create log file
logfile.sync = true # automatically flushes data to file
CUSTOM_LOGGER = # constant accessible anywhere
You can’t perform that action at this time.