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
require 'benchmark' | |
ITERATIONS = 1_000_000 | |
def rename(source, dest) | |
{ source: source, dest: dest } | |
end | |
def literal_work | |
ITERATIONS.times do |
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
# Public: Module that overrides Thread initialization to preserve the request context. | |
module ThreadWithContext | |
# Public: Returns a new Thread that preserves the context of the current request. | |
def new(*args) | |
request_id = Thread.current[:request_id] | |
super(*args) { | |
Thread.current[:request_id] = request_id | |
yield *args | |
} |
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 Mongoid | |
# Public: Allows to use inheritance to reuse logic, without using Single- | |
# Collection Inheritance, storing the model and superclass in different | |
# collections. | |
module NoHeritage | |
extend ActiveSupport::Concern | |
included do | |
# Internal: Preserve the default storage options instead of storing in the |
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
require 'benchmark' | |
class User | |
def initialize(first_name:, last_name:, email:) | |
@first_name, @last_name, @email = first_name, last_name, email | |
end | |
def to_s | |
"#{ @first_name } #{ @last_name } (#{ @email })" | |
end |
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
override_git_prompt_colors() { | |
GIT_PROMPT_THEME_NAME="Custom" | |
PathShort="\W" # Display only the current folder | |
# Display the current folder first | |
GIT_PROMPT_START_USER="${Green}${PathShort}" | |
GIT_PROMPT_START_ROOT="${Green}${PathShort}" | |
# Skip the default prefix |
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
#!/bin/bash | |
echo "Requesting initial permissions (necessary to start and stop services)" | |
sudo echo "OK" | |
if [[ "$(uname)" == 'Darwin' ]]; then | |
platform='osx' | |
DB_PATH='/usr/local/var/mongodb' | |
LOG_PATH='/usr/local/var/log/mongodb/mongo.log' | |
CONFIG_PATH='/usr/local/etc/mongod.conf' | |
BACKUP_PATH="$HOME/mongobackups" |
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
package com.maximomussini.anko; | |
import android.os.Bundle; | |
import android.support.design.widget.FloatingActionButton; | |
import android.support.design.widget.NavigationView; | |
import android.support.design.widget.Snackbar; | |
import android.support.v4.view.GravityCompat; | |
import android.support.v4.widget.DrawerLayout; | |
import android.support.v7.app.ActionBarDrawerToggle; | |
import android.support.v7.app.AppCompatActivity; |
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 BandController < ApplicationController | |
def new | |
@band = Band.new | |
end | |
def create | |
@band = Band.new(band_params) | |
if @band.save | |
redirect_to(@band) | |
else |
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 BandController < ApplicationController | |
def new | |
@band = Band.new.decorate | |
end | |
def create | |
@band = Band.new(band_params) | |
if @band.save | |
redirect_to(@band) | |
else |
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
{ | |
"always_show_minimap_viewport": true, | |
"auto_complete": false, | |
"bold_folder_labels": true, | |
"color_scheme": "Packages/Material Theme/schemes/Material-Theme-Darker.tmTheme", | |
"draw_white_space": "none", | |
"ensure_newline_at_eof_on_save": true, | |
"find_selected_text": true, | |
"font_face": "Fira Code", | |
"font_face": "Fira Code", |
OlderNewer