Skip to content

Instantly share code, notes, and snippets.

View liamwhite's full-sized avatar

liamwhite

View GitHub Profile
@chetan
chetan / yardoc_cheatsheet.md
Last active May 10, 2024 02:53
YARD cheatsheet
@mattetti
mattetti / tracepoint_middlware.rb
Created March 6, 2013 06:34
test middleware for Ruby 2.0 logging the method dispatches going on when a request is being handled.
class TracePoint
class Middleware
def initialize(app)
@app = app
end
def call(env)
stats = {}
trace = TracePoint.new(:call) do |tp|
@suryart
suryart / application.html.erb
Last active October 26, 2023 00:16
Rails 4 flash messages using Twitter Bootstrap(bootstrap-sass: https://github.com/thomas-mcdonald/bootstrap-sass). An improved version of https://gist.github.com/roberto/3344628
// layout file
<body>
<div class="container">
<%= flash_messages %>
<%= yield %>
</div><!-- /container -->
</body>
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
@thebucknerlife
thebucknerlife / authentication_with_bcrypt_in_rails_4.md
Last active July 10, 2024 00:17
Simple Authentication in Rail 4 Using Bcrypt

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

@nicktoumpelis
nicktoumpelis / repo-rinse.sh
Created April 23, 2014 13:00
Cleans and resets a git repo and its submodules
git clean -xfd
git submodule foreach --recursive git clean -xfd
git reset --hard
git submodule foreach --recursive git reset --hard
git submodule update --init --recursive
Start GDB and execute the following commands:
catch syscall ptrace
commands 1
set ($eax) = 0
continue
end
Then, run the app and voilá! you can debug your program :)
@marcan
marcan / asm.py
Created December 22, 2018 10:07
Python module to assemble snippets of code
#!/usr/bin/env python
import os, tempfile, shutil, subprocess
class AsmException(Exception):
pass
class BaseAsm(object):
def __init__(self, source, addr = 0):
self.source = source
self._tmp = tempfile.mkdtemp() + os.sep
@marcan
marcan / vortex_patch.py
Created December 22, 2018 10:09
Alesis Vortex Wireless 2 patch to send MIDI messages when pressing the ribbon bank buttons
from asm import *
blob = open("image.bin", "rb").read()
start_addr = 0x08003000
patch_start = start_addr + len(blob)
assert patch_start % 4 == 0
@liamwhite
liamwhite / gist:8bbaafc2ded5147c7890065c67f89635
Created January 24, 2019 01:38
Dump SASS/SCSS variables from a Rails app
class Sass::Tree::Visitors::Perform
def visit_variable(node)
env = @environment
env = env.global_env if node.global
if node.guarded
var = env.var(node.name)
return [] if var && !var.null?
end
val = node.expr.perform(@environment)