Skip to content

Instantly share code, notes, and snippets.

@madrobby
madrobby / gist:c55f39bfdbd60bf14671
Last active August 23, 2018 17:48
Deny commonly used security-probing things that spam up log files (for a Rails app)
location ~ ^/(wp-admin|wp-login\.php|priv\.dog|companies\/sidekick) {
deny all;
break;
}
# file extensions that should never be served, this prevents
# potential malicious downloads in case someone manages to manipulate
# a Rails URL or write a file that can be served
# (~* matches case-insensitive)
location ~* \.(?:git|svn|DS_Store|asp|aspx|cgi|pt|pl|idx|php|exe|scpt|AppleScript|dll|dmg|pif|msi|application|msp|com|scr|hta|cpl|gadget|msc|jar|bat|vb|vbs|vbe|ws|wsh|inf|lnk|reg|scf|wsc|wsh|ps1|ps1xml|ps2|ps2xml|psc1|psc2|msh|msh1|msh2|mshxml|msh1xml|msh2xml)$ {
deny all;
- 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)
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)
#!/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
#!/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"
def self.carriage_returns_to_newlines!(file_contents)
(file_contents.gsub!(/\r\n/,"\n")||file_contents).gsub!(/\r/, "\n") || file_contents
end
<!-- 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">
+----------------------+-------+-------+---------+---------+-----+-------+
| 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 |
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 June 24, 2014 12:20
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.
document.addEventListener('dragover', function(e){
e.preventDefault();
e.stopPropagation();
}, false);
document.addEventListener('drop', function(e){
e.preventDefault();
e.stopPropagation();
}, false)