Skip to content

Instantly share code, notes, and snippets.

Matt Briggs mbriggs

Block or report user

Report or block mbriggs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:177268
queue = []
['hello', 'x', 'world'].each do |word|
queue << word and puts "Added to queue" unless word.length < 2
end
puts queue.inspect
# Output:
# Added to queue
# Added to queue
# ["hello", "world"
View Evolution of a Python programmer.py
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
View gist:357976
public static string EscapeXml( this string s )
{
string xml = s;
if ( !string.IsNullOrEmpty( xml ) )
{
// replace literal values with entities
xml = xml.Replace( "&", "&amp;" );
xml = xml.Replace( "&lt;", "&lt;" );
xml = xml.Replace( "&gt;", "&gt;" );
xml = xml.Replace( "\"", "&quot;" );
View webapp.rb
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
View node-and-npm-in-30-seconds.sh
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
View gist:1153042
// most of render()
this.el.html(this.template())
this.$('input[name=id]').val(this.endpoint.get('id'))
this.$('input[name=group]').val(this.endpoint.get('group'))
this.$('input[name=name]').val(this.endpoint.get('name'))
this.$('input[name=route]').val(this.endpoint.get('route'))
this.$('textarea[name=sample_xml]').val(this.endpoint.get('sample_xml'))
View gist:1384804
(defun find-functional-test (test-file)
(find-file (replace-regexp-in-string "_test" "" test-file
(replace-regexp-in-string "test\\/functional"
"app\/controllers\/"
test-file))))
View gist:1384806
(defun test ()
(let ((a 1)
(b (+ a 2)))
(message b)))
(test)
Debugger entered--Lisp error: (void-variable a)
(+ a 2)
@mbriggs
mbriggs / gist:1453590
Created Dec 9, 2011
making mingle nice
View gist:1453590
{
"mingle.local": {
"_enabled": true,
"_rules": {
"#card-index": {
"font-size": "5em",
"color": "#0076BA"
},
"#show_enumeratedpropertydefinition_479_drop_link": {
"font-weight": "bold",
View screening.js
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
You can’t perform that action at this time.