Skip to content

Instantly share code, notes, and snippets.

Brendon Murphy bemurphy

Block or report user

Report or block bemurphy

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
@csswizardry
csswizardry / README.md
Last active Sep 2, 2019
Vim without NERD tree or CtrlP
View README.md

Vim without NERD tree or CtrlP

I used to use NERD tree for quite a while, then switched to CtrlP for something a little more lightweight. My setup now includes zero file browser or tree view, and instead uses native Vim fuzzy search and auto-directory switching.

Fuzzy Search

There is a super sweet feature in Vim whereby you can fuzzy find your files using **/*, e.g.:

:vs **/*<partial file name><Tab>
View rebuild
#!/usr/bin/env bash
set -e
if [ -e static ]; then
rm -r static
fi
mkdir -p static
sass src/sass/main.scss > static/application.css
$(npm bin)/browserify src/js/main.js > static/application.js
@ryanfelton
ryanfelton / install_qt5.sh
Last active May 25, 2017
CircleCI Install Qt5
View install_qt5.sh
#!/bin/sh
# Based on: https://gist.github.com/ryanong/ad6e7570e3f72b22c0e4
set -x
# Exit if any subcommand fails
set -e
if [ ! -d "/opt/qt55" ]; then
echo "Installing QT 5.5 ..."
@pedrosmmoreira
pedrosmmoreira / final_controller_calls.rb
Last active Jan 21, 2016
Dynamic Pundit Policies per user type
View final_controller_calls.rb
class FoosController < ApplicationController
include Pundit
#...
# record policy
def set_record_policy
policy(PolicyContext.new(record, current_user)
end
# scope policy
@jwood
jwood / application.html.erb
Last active Jul 2, 2019
Disable animations
View application.html.erb
<!-- app/views/layouts/application.html.erb -->
<!DOCTYPE html>
<html lang="en">
<head>
<!-- ... -->
<% if Rails.application.config.disable_animations %>
<%= stylesheet_link_tag('disable_animations') %>
<!-- Turn off animations in jQuery -->
<script>$.fx.off = true;</script>
@joost
joost / change_s3_metadata.rb
Last active Aug 26, 2016
Change metadata on existing S3 files
View change_s3_metadata.rb
# Using v1 of Ruby aws-sdk as currently v2 seems not able to do this (broken?).
require 'aws-sdk-v1'
key = YOUR_AWS_KEY
secret = YOUR_AWS_SECRET
region = YOUR_AWS_REGION
AWS.config(access_key_id: key, secret_access_key: secret, region: region)
s3 = AWS::S3.new
bucket = s3.buckets[bucket_name]
@krasnoukhov
krasnoukhov / 2013-01-07-profiling-memory-leaky-sidekiq-applications-with-ruby-2.1.md
Last active Jun 11, 2019
Profiling memory leaky Sidekiq applications with Ruby 2.1
View 2013-01-07-profiling-memory-leaky-sidekiq-applications-with-ruby-2.1.md

My largest Sidekiq application had a memory leak and I was able to find and fix it in just few hours spent on analyzing Ruby's heap. In this post I'll show my profiling setup.

As you might know Ruby 2.1 introduced a few great changes to ObjectSpace, so now it's much easier to find a line of code that is allocating too many objects. Here is great post explaining how it's working.

I was too lazy to set up some seeding and run it locally, so I checked that test suite passes when profiling is enabled and pushed debugging to production. Production environment also suited me better since my jobs data can't be fully random generated.

So, in order to profile your worker, add this to your Sidekiq configuration:

if ENV["PROFILE"]
View two-factor
#!/usr/bin/env ruby --disable-gems
# Roll your own two-factor authentication! Place this file on a USB key, make
# it executable, then run:
#
# two-factor --setup
#
# Now place each TOTP secret in its own file in the `keys/` directory. I like
# to name them after the website they apply to, but any name is fine. To
# generate a token, plug in your USB key and:
@relaxdiego
relaxdiego / graphite.md
Last active Apr 19, 2019 — forked from surjikal/graphite.md
Installing Graphite in OS X Mavericks
View graphite.md

Follow these steps to install graphite on OS X Mavericks.

Prerequisites

  • Homebrew
  • Python 2.7
  • Git

Install dependencies

Install Cairo and friends

@xaviershay
xaviershay / build_frontend.sh
Last active Dec 24, 2015
SASS + Coffee + Concatenation in prod
View build_frontend.sh
#!/bin/bash
set -exo pipefail
BUILD_ENV=$1
if [ `uname` == 'Darwin' ]; then
OSX=1
JSCOMPRESSOR="yuicompressor --type js"
else
OSX=
You can’t perform that action at this time.