Skip to content

Instantly share code, notes, and snippets.

View mscottford's full-sized avatar
🔎
hunting for code to clean up

M. Scott Ford mscottford

🔎
hunting for code to clean up
View GitHub Profile
@jnx
jnx / rbenv-install-system-wide.sh
Created October 1, 2011 20:09
rbenv install and system wide install on Ubuntu 10.04 LTS.
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential
apt-get -y install git-core
# Install rbenv
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv
# Add rbenv to the path:
@luciomartinez
luciomartinez / slash.sh
Last active June 1, 2023 08:49
Add or Remove trailing slash in bash
### Add trailing slash if needed
STR="/i/am/a/path"
length=${#STR}
last_char=${STR:length-1:1}
[[ $last_char != "/" ]] && STR="$STR/"; :
echo "$STR" # => /i/am/a/path/
/*----------------------------------------------------------------------
* "Agatha Christie" Problem
* Who was the killer?
*
* Alice, her husband, son, daughter,
* and brother are involved in a murder.
* One of the five killed one of the other
* four.
*
* 1. A man and a woman were together in the bar
@SoundLogic
SoundLogic / roslyn2jsSequenceDiagrams.cs
Last active September 21, 2022 14:33
P.O.C. for UML sequence diagram project leveraging Roslyn
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.MSBuild;
using Microsoft.CodeAnalysis.FindSymbols;
@kennethkalmer
kennethkalmer / gist:278814
Created January 16, 2010 13:14
node.js SMTP Server
/*
smtpd.js is SMTP server written for node.js
MIT License
*/
var tcp = require('tcp');
var sys = require('sys');
@matschaffer
matschaffer / mdtopdf.rb
Created September 27, 2010 03:42
A rough translation of markdown to pdf
require 'rubygems'
require 'jekyll'
require 'maruku'
require 'pathname'
# Need pre for inline format support
gem 'prawn', '=0.11.1.pre'
require 'prawn'
require 'to_prawn'
class Converter
@afn
afn / gist:c04ccfe71d648763b306
Created June 12, 2014 15:35
Restart phantomjs when it hangs
# Borrowed from https://github.com/y310/rspec-retry/blob/master/lib/rspec/retry.rb
CAPYBARA_TIMEOUT_RETRIES = 3
RSpec.configure do |config|
config.around(:each, type: :feature) do |ex|
example = RSpec.current_example
CAPYBARA_TIMEOUT_RETRIES.times do |i|
example.instance_variable_set('@exception', nil)
self.instance_variable_set('@__memoized', nil) # clear let variables
@bokmann
bokmann / ActiveRepository.rb
Created March 27, 2012 16:15
ActiveRepository Strawman
# MOTIVATION: As rails apps are growing, people are noticing the drawbacks
# of the ActiveRecord pattern. Several apps I have seen, and several
# developers I have spoken to are looking towards other patterns for object
# persistence. The major drawback with ActiveRecord is that the notion
# of the domain object is conflated with what it means to store/retrieve
# it in any given format (like sql, json, key/value, etc).
#
# This is an attempt to codify the Repository pattern in a way that would
# feel comfortable to beginner and seasoned Ruby developers alike.
#
@saturnflyer
saturnflyer / gist:1351998
Created November 9, 2011 16:37
simple load path handling
def needs(short_path)
full_path = File.expand_path(__FILE__ + '../../../' + short_path)
unless $:.include?(full_path)
$: << full_path
end
end
# Example use:
# needs('app/models')
# require 'my_model'