Skip to content

Instantly share code, notes, and snippets.

View dcorking's full-sized avatar

David Corking dcorking

View GitHub Profile
@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
@dcorking
dcorking / typecasting.c
Created August 2, 2014 20:40
Typecasting int to char in printf() in C
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
/* implements http://stackoverflow.com/questions/25079788/typecasting-int-to-char-in-printf-in-c */
/* by discussedtree */
/* Output is */
/* Int size in bits is: 32 */
/* Without typecasting, the integer at byte #0 is set to: 53200 */
@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
@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 / 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
@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
@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.
@maoueh
maoueh / Gemfile
Last active May 30, 2022 08:50
Simple Ruby files to statically serve files
source "https://rubygems.org"
gem 'rack', '~> 1.5'
gem 'rack-cache', '~> 1.2'
gem 'puma', '~> 2.7'
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@sjahandideh
sjahandideh / How to demo feature specs.md
Last active December 28, 2015 01:49
How to demo your feature specs

In order to demo your feature specs, follow these steps:

  1. Add capybara, poltergeist, launchy and selenium-webdriver to your Gemfile under test and development group.
  2. Add the attached demo helper to your spec/support.
  3. Add the capybara config to your spec_helper file.
  4. Run bundle install.
  5. Write your feature with its scenario specs.
  6. Put a demo filter on each scenario you want to demo. ( refer to the example below )
  7. Run bundle exec rspec spec.