Skip to content

Instantly share code, notes, and snippets.

View danryan's full-sized avatar
🔥

Dan Ryan danryan

🔥
View GitHub Profile
@bkaradzic
bkaradzic / orthodoxc++.md
Last active April 23, 2024 13:59
Orthodox C++

Orthodox C++

What is Orthodox C++?

Orthodox C++ (sometimes referred as C+) is minimal subset of C++ that improves C, but avoids all unnecessary things from so called Modern C++. It's exactly opposite of what Modern C++ suppose to be.

Why not Modern C++?

@trusktr
trusktr / DefaultKeyBinding.dict
Last active April 21, 2024 06:32
My DefaultKeyBinding.dict for Mac OS X
/* ~/Library/KeyBindings/DefaultKeyBinding.Dict
This file remaps the key bindings of a single user on Mac OS X 10.5 to more
closely match default behavior on Windows systems. This makes the Command key
behave like Windows Control key. To use Control instead of Command, either swap
Control and Command in Apple->System Preferences->Keyboard->Modifier Keys...
or replace @ with ^ in this file.
Here is a rough cheatsheet for syntax.
Key Modifiers
@lyrixx
lyrixx / segfault-finder.php
Last active August 15, 2023 21:17
How to find a segfault in PHP
<?php
register_tick_function(function() {
$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
$last = reset($bt);
$info = sprintf("%s +%d\n", $last['file'], $last['line']);
file_put_contents('/tmp/segfault.txt', $info, FILE_APPEND);
// or
// file_put_contents('php://output', $info, FILE_APPEND);
});
@allanmac
allanmac / sha256.cu
Last active November 10, 2023 01:26
A CUDA SHA-256 subroutine using macro expansion
// -*- compile-command: "nvcc -m 32 -arch sm_35 -Xptxas=-v,-abi=no -cubin sha256.cu"; -*-
//
// Copyright 2013 Allan MacKinnon <allanmac@alum.mit.edu>
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
@trobrock
trobrock / notify.rb
Created June 20, 2013 17:06
weechat ruby notifications, thanks @joelteon
require 'ruby_gntp'
Weechat.register "notify", "otters", "0.2", "GPL", "notify: A real time notification system for weechat", "", ""
Settings = {
:show_hilights => "on",
:show_priv_msg => "on"
}
def notify_show data, buffer, empty, tagsn, isdisp, ishilight, prefix, msg
@andrewkatz
andrewkatz / .zshrc
Created May 6, 2013 17:22
Simple command for ssh'ing into rails hosts. Thanks to @trobrock for the ruby script.
# Usage:
# rails_ssh release cron
# => ssh release@ec2-xx-xx-xx-xx.compute-1.amazonaws.com
rails_ssh()
{
username=$1
hostname="$(ruby $HOME/Scripts/parse_cap_config.rb $2)"
ssh $username@$hostname
}
@andreas
andreas / gist:5432990
Created April 22, 2013 07:14
Use [rblineprof](https://github.com/tmm1/rblineprof) for profiling Rails apps
class RBLineProfiler
WALL_TIME_LIMIT = 10e3 # ms
def initialize(app)
@app = app
end
def call(env)
result = nil
profile = lineprof(/./) { result = @app.call(env) }
@gnarf
gnarf / ..git-pr.md
Last active April 12, 2024 22:00
git pr - Global .gitconfig aliases for Pull Request Managment

Install

Either copy the aliases from the .gitconfig or run the commands in add-pr-alias.sh

Usage

Easily checkout local copies of pull requests from remotes:

  • git pr 4 - creates local branch pr/4 from the github upstream(if it exists) or origin remote and checks it out
  • git pr 4 someremote - creates local branch pr/4 from someremote remote and checks it out
@mudge
mudge / logstash.conf
Last active April 17, 2019 07:58
A grok pattern for Rails 3.2 logs for use with logstash. Assumes that you have a multiline filter to combine Rails logs into one line and only one worker is logging to a file (c.f. https://gist.github.com/mudge/5063930).
multiline {
tags => ["rails"]
pattern => "^Started"
negate => true
what => "previous"
}
@jbyck
jbyck / gist:5036615
Created February 26, 2013 07:19
403 Error in Chef Run List
"exception": "Net::HTTPServerException: deploy_revision[wikiposit] (/var/chef/cache/cookbooks/application/providers/default.rb line 122) had an error: Net::HTTPServerException: template[/etc/unicorn/wikiposit.rb] (/var/chef/cache/cookbooks/unicorn/definitions/unicorn_config.rb line 38) had an error: Net::HTTPServerException: 403 \"Forbidden\"",
"backtrace": [
"/opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:2632:in `error!'",
"/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/rest.rb:259:in `block in streaming_request'",
"/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/rest.rb:280:in `retriable_rest_request'",
"/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/rest.rb:236:in `streaming_request'",
"/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/rest.rb:97:in `get'",
"/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/cookbook/remote_file_vendor.rb:63:in `get_filename'",
"/opt/chef/embedded/lib/ruby/gems