Skip to content

Instantly share code, notes, and snippets.

View dcorking's full-sized avatar

David Corking dcorking

View GitHub Profile
@korczis
korczis / rubocop-cops.txt
Created April 24, 2014 18:15
List of RuboCop cops
# Available cops (167) + config for /Users/tomaskorcak/dev/gooddata-ruby:
# Type 'Lint' (32):
AmbiguousOperator:
Description: Checks for ambiguous operators in the first argument of a method invocation
without parentheses.
Enabled: true
AmbiguousRegexpLiteral:
Description: Checks for ambiguous regexp literals in the first argument of a method
invocation without parenthesis.
@johnnymo87
johnnymo87 / gist:711e1d38e2e5707fda06
Created May 17, 2014 17:38
Finding fixed points
import math.abs
object finding_fixed_points {
val tolerance = 0.0001 //> tolerance : Double = 1.0E-4
def isCloseEnough(x: Double, y: Double) =
abs((x - y) / x) / x < tolerance //> isCloseEnough: (x: Double, y: Double)Boolean
def fixedPoint(f: Double => Double)(firstGuess: Double) = {
def iterate(guess: Double): Double = {
val next = f(guess)
if (isCloseEnough(guess, next)) next
@dcorking
dcorking / disk-usage.sh
Created June 26, 2014 13:54
Explore the apt cache in Debian
# this looks interesting
du --max-depth=1 -b -k /var/cache/apt | sort -k1 -rn
@lengarvey
lengarvey / staging.rb
Created June 29, 2014 11:28
Enabling Rails 4.1 mail previews in staging (or any other env besides development)
# put this in your staging.rb file. Obviously you'll need more config than this it's just an example.
Rails.application.configure do
config.action_mailer.preview_path ||= defined?(Rails.root) ? "#{Rails.root}/test/mailers/previews" : nil
config.autoload_paths += [config.action_mailer.preview_path]
routes.append do
get '/rails/mailers' => "rails/mailers#index"
get '/rails/mailers/*path' => "rails/mailers#preview"
end
@dcorking
dcorking / find_abuse.sh
Last active May 17, 2017 08:01
Notes on findutils
# This is not the official way to prune directories, but I found it easier.
# It prints the contents of all the files in the tree - excluding .git and CachedPixmaps,
# but there is a potential bug in the second globbed file name
#
# Works with GNU findutils. Might not work with BSD find, such as Mac OS X.
find -not -wholename './.git*' -not -wholename '*CachedPixmaps*' -type f |xargs cat
@caike
caike / Dockerfile
Created September 29, 2014 21:54
Fixed version of the Dockerfile for the tutorial at https://docs.docker.com/examples/nodejs_web_app/
# DOCKER-VERSION 1.2.0
FROM centos:centos6
# Enable EPEL for Node.js
RUN rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# Install Node.js and npm
RUN yum install -y npm
# Creates a new folder on the container
VOLUME /src

The thing that students have the hardest time on when learning functional programming is how to process a recursive structure while maintaining some sort of "state", the result if you will. I'll attempt here to demystify the process.

Functional programming languages almost always use a lot of recursively defined structures. Depending on the language those can be implemented in various ways, but in any case the end result is the same. A structure of this type is either an "atom", i.e. an irreducible thing, or a "compound" consisting of substructures of the same form.

For example a "list" is either an Empty/Nil list (the "atom") or it is formed as a Cons of a value and another list (compound form). That other "sublist" can itself be empty or another cons and so on and so forth. A tree is similar. It is either empty, or it consists of a triple of a value and two sub-trees, left and right.

Almost every problem we encounter is a question about doing something with all entries in a structure. To solve these prob

@steve-jansen
steve-jansen / export-zone.sh
Created December 15, 2014 19:11
Export DNS records from Rackspace Cloud DNS to zone files on disk
#!/bin/bash
# exports DNS records from Rackspace Cloud DNS to text files
# Depends on https://github.com/wichert/clouddns/blob/master/src/clouddns.py
set -e
me=export-zone
base_domain=
rackspace_region=
rackspace_rate_limit_delay=3
@cole007
cole007 / freelance-2014.csv
Last active October 4, 2017 22:04
Freelance Rates 2014 (@asclearasmud)
Where are you based in the UK? How would you describe what you do? Is your primary skill set(s) How old are you? How many years have you been a web professional? How many years have you been freelance? What is your DAY (not hourly) rate? DAY RATE (clean) What is your HOUR (not daily) rate? HOUR RATE (clean) How do you primarily charge clients? Do you normally request a deposit before starting work on a project? Do you normally use a contract? Do you mostly work … What is the average value of projects you work on? What is your gender? Do you primarily charge a fixed rate or does your rate vary between clients? What is the average amount of time spent working on a project? How many projects do you tend to work on at any on time? What is your normal invoicing terms? Where do you primarily work? On average, how many hours a day do you normally work? On average, how many days a week do you normally work? Do you have an accountant? What accounting software do you use, if any? Accounting software (clean) Is fr
@lopezpdvn
lopezpdvn / install-fahclient-linux-systemd-service-unit.md
Last active January 14, 2023 07:21
Install Folding@home FAHClient on Linux as a systemd service unit

Install Folding@home FAHClient on Linux as a systemd service unit

Republished on my website, keeping this version here for historical reasons.

Install FAHClient as documented in the official guide. Stop the traditional init script service that was created and automatically started.