Skip to content

Instantly share code, notes, and snippets.

Thomas Fuchs madrobby

View GitHub Profile
View gist:da12f6394fa7f2fdf7b0
- name: Symlink release to be current version
sudo: yes
shell: >
rm -f {{ freckle_current_path }} &&
ln -s {{ release_path }} {{ freckle_current_path }}
notify:
- restart unicorn
- restart resque-worker
- restart resque-priority-worker
when: (new_release|changed) and ('appservers' in group_names)
View gist:27b537ab0344c827daf8
letters = ""
letters << user.first_name[0,1] if user.first_name.size > 1 && 'A'..'Z'.include?(user.first_name[0,1].upcase)
letters << user.last_name[0,1] if user.last_name.size > 1 && 'A'..'Z'.include?(user.last_name[0,1].upcase)
View generate.sh
#!/bin/sh
# This requires "imagemin", install via:
# npm install --global imagemin
echo "Cleaning up..."
rm -rf build
mkdir build
echo "Optimizing SVG..."
imagemin *.svg ../public/images/icons
View generate_icons.rb
#!/usr/bin/env ruby
require 'json'
FILENAME = "../app/helpers/icon_helper.rb"
JAVASCRIPT_HELPER = "../public/js/icons/icons.js"
puts "Generating helper #{FILENAME}"
File.open(FILENAME, 'w') do |helper|
helper.write "module IconHelper\n\n"
View gist:b428cc58afff0a89c007
def self.carriage_returns_to_newlines!(file_contents)
(file_contents.gsub!(/\r\n/,"\n")||file_contents).gsub!(/\r/, "\n") || file_contents
end
View gist:c010cd550aa55ecbda1c
<!-- iPhone 6 Plus -->
<link href="startup-image-1242x2148.png"
media="(device-width: 414px) and (device-height: 736px)
and (-webkit-device-pixel-ratio: 3)"
rel="apple-touch-startup-image">
View gist:7c46687b008bb0e947f0
+----------------------+-------+-------+---------+---------+-----+-------+
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers | 6115 | 4880 | 48 | 436 | 9 | 9 |
| Helpers | 1534 | 1214 | 1 | 175 | 175 | 4 |
| Models | 10394 | 8021 | 106 | 1126 | 10 | 5 |
| Libraries | 2098 | 1519 | 28 | 186 | 6 | 6 |
| Integration tests | 1419 | 1054 | 12 | 6 | 0 | 173 |
| Functional tests | 13650 | 10437 | 28 | 71 | 2 | 145 |
| Unit tests | 21981 | 17809 | 41 | 73 | 1 | 241 |
View gist:e78cd94e7d4ad374e0ac
def format_date_range(from, to)
to = from if to.nil?
return '' if from.nil? && to.nil?
from, to = to, from if to < from
if from == to
from.strftime('%B %e, %Y')
elsif from.year == to.year && from.month == to.month &&
from.beginning_of_month == from && to.end_of_month == to
from.strftime('%B %Y')
@madrobby
madrobby / gist:8dc43c58114466d6a894
Created Jun 24, 2014
Code to prevent drag/drop in a Webview inside a Mac app. You can throw this in a `<script>` tag first thing inside the `<body>`. Users will no longer be able to accidentally break your app by dropping something (like a web page URL) onto it.
View gist:8dc43c58114466d6a894
document.addEventListener('dragover', function(e){
e.preventDefault();
e.stopPropagation();
}, false);
document.addEventListener('drop', function(e){
e.preventDefault();
e.stopPropagation();
}, false)
View gist:0caa0a78445f41de422a
irb(main):001:0> A = [1,2,3].freeze
=> [1, 2, 3]
irb(main):002:0> A[2] = 5
TypeError: can't modify frozen array
from (irb):2:in `[]='
from (irb):2
You can’t perform that action at this time.