Skip to content

Instantly share code, notes, and snippets.

@roberto
roberto / _flash_messages.html.erb
Created August 13, 2012 22:47
Rails flash messages using Twitter Bootstrap
<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>
@mikepfirrmann
mikepfirrmann / pretty-exception.rb
Created October 2, 2012 16:24
Print a prettier stack trace for Ruby exceptions
def colorize(text, color_code)
"\e[#{color_code}m#{text}\e[0m"
end
begin
# Here be dangerous things.
rescue => e
print "\r" << (' ' * 50) << "\n"
stacktrace = e.backtrace.map do |call|
if parts = call.match(/^(?<file>.+):(?<line>\d+):in `(?<code>.*)'$/)
@ryanseys
ryanseys / play_mp3.rb
Created April 3, 2013 03:37
Play MP3 file in terminal using Ruby
pid = fork{ exec 'afplay', "song.mp3" } # on mac osx
@evantoli
evantoli / GitConfigHttpProxy.md
Last active July 11, 2024 13:31
Configure Git to use a proxy

Configure Git to use a proxy

In Brief

You may need to configure a proxy server if you're having trouble cloning or fetching from a remote repository or getting an error like unable to access '...' Couldn't resolve host '...'.

Consider something like:

@ufologist
ufologist / mobile-hls-video.html
Last active September 21, 2023 09:01
Web 前端如何播放 HLS(.m3u8) 视频
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Mobile HLS video</title>
</head>
<body>
<h1>Mobile HLS video</h1>
@barbolo
barbolo / benchamark_hash_to_json.rb
Last active September 24, 2022 03:32
Benchmark of JSON rendering in Ruby
# gem install multi_json json yajl-ruby oj benchmark-memory
require 'multi_json'
require 'json'
require 'yajl'
require 'oj'
require 'benchmark'
require 'benchmark-memory'
hash1 = {
@joshdholtz
joshdholtz / .zshrc
Created October 27, 2021 19:16
Josh's M1 Mac Development Environment - homebrew, zsh
# ~/.zshrc
ZSH_DISABLE_COMPFIX=true
export ZSH="/Users/joshholtz/.oh-my-zsh"
# joshdholtz theme shows arch type in the prompt
ZSH_THEME="joshdholtz"
plugins=(git)
source $ZSH/oh-my-zsh.sh
# M1 and Rosetta
@fernandoaleman
fernandoaleman / mysql2-m1.md
Last active July 4, 2024 06:22
How to install mysql2 gem on m1 Mac

Problem

Installing mysql2 gem errors on Apple silicon M1, M2 or M3 Mac running macOS Sonoma.

Solution

Make sure mysql-client, openssl and zstd are installed on Mac via Homebrew.

Replace mysql-client with whichever mysql package you are using