Skip to content

Instantly share code, notes, and snippets.

View bemurphy's full-sized avatar

Brendon Murphy bemurphy

View GitHub Profile
@csswizardry
csswizardry / README.md
Last active April 2, 2024 20:17
Vim without NERD tree or CtrlP

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>
#!/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 04:01
CircleCI Install Qt5
#!/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 January 21, 2016 06:40
Dynamic Pundit Policies per user type
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 March 15, 2021 16:03
Disable animations
<!-- 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 August 26, 2016 01:40
Change metadata on existing S3 files
# 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 October 4, 2023 21:53
Profiling memory leaky Sidekiq applications with Ruby 2.1

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"]
#!/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 January 5, 2022 09:07 — forked from surjikal/graphite.md
Installing Graphite in OS X Mavericks

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 December 24, 2015 20:49
SASS + Coffee + Concatenation in prod
#!/bin/bash
set -exo pipefail
BUILD_ENV=$1
if [ `uname` == 'Darwin' ]; then
OSX=1
JSCOMPRESSOR="yuicompressor --type js"
else
OSX=