Skip to content

Instantly share code, notes, and snippets.

View plukevdh's full-sized avatar
🔥

Luke van der Hoeven plukevdh

🔥
View GitHub Profile
@nzroller
nzroller / git-pr-cleanup
Created August 19, 2016 06:00
Github squash-merge PR local cleanup
#!/bin/sh
# Delete local branches whose upstream has been removed
# (useful for Github squashed and merged branches)
# WARNING: git branch -D will force delete branches!
git branch -vv | grep ' gone' | cut -d' ' -f1-3 | xargs -i git branch -D {}
@mefellows
mefellows / BundleConfig.ps1
Last active December 25, 2023 23:33
Sysprepped Windows AMI using Packer
$EC2SettingsFile="C:\\Program Files\\Amazon\\Ec2ConfigService\\Settings\\BundleConfig.xml"
$xml = [xml](get-content $EC2SettingsFile)
$xmlElement = $xml.get_DocumentElement()
foreach ($element in $xmlElement.Property)
{
if ($element.Name -eq "AutoSysprep")
{
$element.Value="Yes"
}
@jodosha
jodosha / class_loading_benchmark.rb
Last active August 29, 2015 14:04
Lotus::Utils vs ActiveSupport benchmarks
#!/usr/bin/env ruby
require 'benchmark'
require 'rubygems'
require 'active_support/core_ext/string/inflections' # v4.1.4
require 'lotus/utils/class' # v0.2.0
TIMES = (ENV['TIMES'] || 1_000_000).to_i
class Foo
end
@plukevdh
plukevdh / prod-setup.sh
Last active August 29, 2015 14:01
Shell helpers for sharing setups between dev and prod .rvmrc files
setup_env() {
if [[ -f ".env" ]]; then
for line in `cat .env`; do export $line; done
echo "Loaded .env file from this directory"
fi
}
bundled_commands=(foreman rackup rake rspec ruby shotgun thin pry)
_bundler-installed() {
@plukevdh
plukevdh / collection.coffee
Last active December 26, 2015 19:19
simple model with properties and delegation
class Collection
constructor: (items) ->
@all = if _.any(items, (item) => item instanceof @modelType)
items
else
(new @modelType(item) for item in items)
add: (item) ->
@all.push(item)
@Hypercubed
Hypercubed / README.md
Last active December 12, 2021 02:23
DocPad: rsync Deploy Script

DocPad: rsync Deploy Script

  • Place deploy.sh in {docpad folder}/bin/
  • Create (or edit) a .env file in your docpad folder with the following values:
#!/bin/bash
DEPLOY_SOURCE_DIR="out/"
DEPLOY_DEST_DIR="~/public_html/"
DEPLOY_SERVER=deploy-server-name
@plukevdh
plukevdh / lazy_mustachio.coffee
Last active December 16, 2015 15:59
add handlebars rendering/pre-caching to backbone
class Mustachio extends Backbone.View
templates: {}
render: ->
@templates[@templateName].call @, @renderContext()
lazyCompileFactory: (template_id, raw_template) ->
@templates[template_id] = (context) =>
compiled_template = Handlebars.compile(raw_template)
@templates[this.id] = compiled_template
require 'benchmark/ips'
Benchmark.ips do |x|
RESULT = [1]
x.report('first') do |times|
i = 0
while i < times
id = RESULT.first
i += 1
@hryk
hryk / Gemfile
Last active December 13, 2015 22:08
Examples for using blueprints on JRuby.
source "https://rubygems.org/"
gem "neo4j"
gem "pry"
gem "minitest"
gem "jbundler"
@ibanez270dx
ibanez270dx / ConditionalValidations.rb
Last active April 10, 2018 11:31
A simple module that allows validation of only certain attributes of any given model. Created for CoverHound.com.
#
# At CoverHound, we use conditional validations all over the form. However, there is no proper way to do
# this in Rails. Instead, we can provide an array of attributes (validated_fields attribute)
# and ensure they are the only ones to get validated.
#
module ConditionalValidations
attr_accessor :validated_fields
def field_is_required?(field)