Skip to content

Instantly share code, notes, and snippets.

@coridrew
coridrew / gitk_commands.md
Last active February 6, 2023 16:04
gitk is my favorite git gui, and is available on all platforms for free. Here are some of the helpful switches I've learned over the years.

> gitk -> Visualize current working directory / branch only.

> gitk --reflog -> VISUALIZE YOUR REFLOG! OMG! Thanks @Stjaertfena

> gitk --all -> Visualize current working directory & ALL branches (both local and remote).

> gitk --remotes -> Visualize ALL REMOTE branches only.

> gitk --remotes=origin/cd_* -> Visualize SPECIFIC (pattern-based!) REMOTE branches only.

@yetanotherchris
yetanotherchris / in-memory-http-server.cs
Last active February 4, 2024 14:00
In memory http server for C# unit and integration tests
public static Task BasicHttpServer(string url, string outputHtml)
{
return Task.Run(() =>
{
HttpListener listener = new HttpListener();
listener.Prefixes.Add(url);
listener.Start();
// GetContext method blocks while waiting for a request.
HttpListenerContext context = listener.GetContext();
@lwoodson
lwoodson / net_instrumentation.rb
Created April 17, 2015 21:56
Instrument HTTP calls made with Net::HTTP
HTTP_LOG_PATH = File.expand_path("~/http.log")
FileUtils.rm_f(HTTP_LOG_PATH)
module NetInstrumentation
def self.included(base)
puts "Writing HTTP out to ~/http.log"
base.send(:alias_method, :__original_request, :request)
base.send(:alias_method, :request, :__logged_request)
end
# fix tmux copy/paste per http://robots.thoughtbot.com/post/19398560514/how-to-copy-and-paste-with-tmux-on-mac-os-x
set-option -g default-command "reattach-to-user-namespace -l zsh"
set -g default-command /bin/zsh
set -g default-shell /bin/zsh
setw -g mode-keys vi
set -g prefix C-a
# Setting the prefix from C-b to C-a
@brasic
brasic / gist:8788958
Last active August 29, 2015 13:55 — forked from trcarden/gist:3295935
simulating a real https site in localhost:3000 (OSX)
running https://yourssldomain.com
# generate keys, run in ~/.sslcert
openssl genrsa -des3 -out server.orig.key 2048
openssl rsa -in server.orig.key -out server.key
openssl req -new -key server.key -out server.csr
# set Common Name: yourssldomain.com
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
echo "127.0.0.1 yourssldomain.com" | sudo tee -a /private/etc/hosts
@jed
jed / how-to-set-up-stress-free-ssl-on-os-x.md
Last active February 25, 2024 17:35
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@benweint
benweint / gdb-stuck-ruby.txt
Created April 16, 2013 14:55
An example of how to gather C and Ruby backtraces from a stuck Ruby process using gdb.
# Here's the script I'll use to demonstrate - it just loops forever:
$ cat test.rb
#!/usr/bin/env ruby
loop do
sleep 1
end
# Now, I'll start the script in the background, and redirect stdout and stderr
@funny-falcon
funny-falcon / changes.md
Last active March 23, 2024 05:53
Performace patch for ruby-1.9.3-p327

Changes:

  • this version includes backport of Greg Price's patch for speedup startup http://bugs.ruby-lang.org/issues/7158 .

    ruby-core prefers his way to do thing, so that I abandon cached-lp and sorted-lf patches of mine.

  • this version integrates 'array as queue' patch, which improves performance when push/shift pattern is heavily used on Array.

    This patch is accepted into trunk for Ruby 2.0 and last possible bug is found by Yui Naruse. It is used in production* for a couple of months without issues even with this bug.

@wtaysom
wtaysom / where_is.rb
Created September 23, 2011 08:57
A little Ruby module for finding the source location where class and methods are defined.
module Where
class <<self
attr_accessor :editor
def is_proc(proc)
source_location(proc)
end
def is_method(klass, method_name)
source_location(klass.method(method_name))
@jacortinas
jacortinas / app_config.rb
Created July 1, 2011 15:42
Redis Logging
# config/initializers/app_config.rb
# An initializer that contains config stuff
# ...
class RedisConfig < Settingslogic
source "#{Rails.root}/config/redis.yml"
namespace Rails.env
end