Skip to content

Instantly share code, notes, and snippets.

@codingfoo
codingfoo / constrain.py
Created January 8, 2021 05:17
Generate Reading list from a csv list of recomendations.
import csv
HARD_MODE = 2
NORMAL_MODE = 3
recs_column = HARD_MODE
name_column = 0
from constraint import *
problem = Problem()
@codingfoo
codingfoo / README
Last active July 19, 2017 20:03
Proof of concept for Elixir add functions to a mock library in tests
1. To pull in functions from multiple Tests a different before_compile hook needs to be registered for each test module
2. To add mocks to multiple mock modules, a attribute needs to be set up for each mock
@codingfoo
codingfoo / index.js
Created February 16, 2016 17:58
Template for nodjs http server
var http = require('http'); // require is unique to nodejs
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World\n");
});
// Listen on port 8080, IP defaults to 127.0.0.1
server.listen(8080);
@codingfoo
codingfoo / monit-test
Last active August 29, 2015 14:19
Monit smoke test
check file alerttest with path /.nonexistent
if does not exist then alert
@codingfoo
codingfoo / iron-worker-deploy.sh
Last active August 29, 2015 14:05
Script for deploying iron.io workers
#!/usr/bin/env sh
set -o nounset
set -o errexit
set -o pipefail
shopt -s nullglob
declare -a environments=("production" "staging" "development")
declare -a workers=(*.worker)
@codingfoo
codingfoo / sublime.json
Created May 7, 2014 23:08
Sublime Config
{
"auto_complete_commit_on_tab": true,
"binary_file_patterns":
[
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
"*.ttf",
"*.tga",
@codingfoo
codingfoo / README
Last active December 8, 2015 16:31
Bash script template
To perform a syntax check/dry run of your bash script run:
bash -n myscript.sh
To produce a trace of every command executed run:
bash -v myscripts.sh
To produce a trace of the expanded command use:
@codingfoo
codingfoo / deploy.rb
Created March 11, 2014 20:15
Rails 4 Capistrano 2 local assets precompile
namespace :deploy do
namespace :assets do
desc 'Run the precompile task locally and rsync with shared'
task :precompile, :roles => :app, :except => { :no_release => true } do
system("bundle check"); exit if $? != 0
system("RAILS_ENV=#{stage} bundle exec rake assets:precompile"); exit if $? != 0
servers = find_servers :roles => :web, :except => { :no_release => true }
run <<-CMD.compact
cp -- #{shared_manifest_path.shellescape} #{current_path.to_s.shellescape}/assets_manifest#{File.extname(shared_manifest_path)}
CMD

Learn a variety of programming paradigms:

  • Write a program in assembly language
  • Write an application in a functional language
  • Write an application in an object-oriented language
  • Write an application in a prototype-based language
  • Write an application in a logic programming language
  • Write an application using the Actor model
  • Write an application in Forth
@codingfoo
codingfoo / boot.rb
Created January 20, 2014 23:12
Modify default rails server port
#config/boot.rb
require 'rails/commands/server'
module Rails
class Server
alias :default_options_alias :default_options
def default_options
default_options_alias.merge!(:Port => 3014)
end
end