Skip to content

Instantly share code, notes, and snippets.

@eheikes
eheikes / fixjpeg.php
Created March 15, 2014 03:12
Fix JPEGs with bad EXIF resolution
<?php
//
// Fix for JPEGs with bad EXIF data that will crash some versions of
// Photoshop. If bad, it will output an equivalent PNG (for losslessness).
//
// To run, PHP must be compiled with GD (JPEG & PNG) and EXIF support.
//
// Make sure a JPG filename has been specified.
if ($argv[1] == '') {
@eheikes
eheikes / Gruntfile.js
Last active August 29, 2015 14:01
How to access a task's filesSrc (expanded files) from another config
module.exports = function(grunt) {
// The helper function to access the filesSrc of the specified task
function filesSrc(configName) {
var config = grunt.config(configName);
var tasks = grunt.task.normalizeMultiTaskFiles(config);
return grunt.util._(tasks).chain().pluck('src').flatten().uniq().value();
}
// Example config
@eheikes
eheikes / gist:2df5d8d1cde82933934d
Created July 16, 2014 16:14
npm install touch error
This file has been truncated, but you can view the full file.
20010 verbose fetch to= /jenkins/tmp/npm-1828-OZKAuTho/1404456112127-0.6931601180694997/tmp.tgz
20011 http GET https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz
20012 http GET https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.25-1.tgz
20013 silly lockFile 19ea773f-s-minimatch-node-modules-sigmund tar:///jenkins/workspace/banno-sentry/node_modules/grunt-contrib-htmlmin/node_modules/html-minifier/node_modules/cli/node_modules/glob/node_modules/minimatch/node_modules/sigmund
20014 silly lockFile 19ea773f-s-minimatch-node-modules-sigmund tar:///jenkins/workspace/banno-sentry/node_modules/grunt-contrib-htmlmin/node_modules/html-minifier/node_modules/cli/node_modules/glob/node_modules/minimatch/node_modules/sigmund
20015 silly lockFile 0c6c0193-ns-npm-sigmund-1-0-0-package-tgz tar:///jenkins/.npm/sigmund/1.0.0/package.tgz
20016 silly lockFile 0c6c0193-ns-npm-sigmund-1-0-0-package-tgz tar:///jenkins/.npm/sigmund/1.0.0/package.tgz
20017 info preinstall sigmund@1.0.0
20018 verbose readDependencies u
$(function() {
// Wrap a container around images.
// Change $("img") to the appropriate selector.
$("img").wrap("<div class='polaroid'></div>").wrap("<div class='film'></div>");
// Start the polaroids with low opacity.
$(".polaroid img").css("opacity", .1);
// Rotate the polaroids a bit.
.film {
background: #000;
}
.polaroid {
background: #fff;
padding: 5%;
padding-bottom: 15%;
@include box-shadow(0 2px 5px rgba(0,0,0,.25));
}
@eheikes
eheikes / gist:3606459
Created September 3, 2012 03:01
Is this really the best way to print a date?
<P>&#169; <SPAN id=footerdate>2010</SPAN> City of Ankeny. All Rights Reserved. <A href="Index.aspx?page=34">Privacy Policy and Disclaimer</A> | Website&nbsp;CMS by <A href="http://www.visioninternet.com/">Vision Internet</A>.
<script type="text/javascript">
var footerDateContainer = document.getElementById('footerdate');
try{
if ( footerDateContainer != null && footerDateContainer != "undefined" )
footerDateContainer.innerHTML = "2012";
}
@eheikes
eheikes / assets-graphviz.rb
Created October 29, 2012 20:38 — forked from cthiel/assets-graphviz.rb
Rails 3.1 stylesheet assets dependency graph
#!/usr/bin/ruby
#
# (c) 2011 SUSE Linux Products GmbH, Author: Christoph Thiel <cthiel@suse.com>
#
# script that generate dependency graph for Rails 3.1 stylesheet assets
#
# usage: sudo rubygem install ruby-graphviz
# cp assets-graphviz.rb yourapp/app/assets/
# cd yourapp/app/assets/; chmod +x assets-graphviz.rb; ./assets-graphviz.rb
@eheikes
eheikes / paam.js
Last active October 12, 2015 05:37
Script to create a single-use short URL using the pa.am service
(function(){
var form=document.createElement('FORM');
form.action='http://pa.am/new';
form.method='post';
var mode=document.createElement('INPUT');
mode.name='mode';
mode.type='hidden';
mode.value='0';
form.appendChild(mode);
# Start all project servers, one per screen.
# http://superuser.com/questions/91881/invoke-zsh-having-it-run-a-command-and-then-enter-interactive-mode-instead-of
screen -t Web 1 zsh -ic 'cd ~/www/goodsmiths/ && gpull; bundle exec foreman start; zsh -i'
screen -t API 2 zsh -ic 'cd ~/www/goodsmiths_recommendation_engine && gpull && bundle exec foreman start; zsh -i'
screen -t AS 3 zsh -ic 'cd ~/www/goodsmiths_activity_stream && gpull && bundle exec foreman start; zsh -i'
screen -t GE 4 zsh -ic 'cd ~/www/goodsmiths_gaminator && gpull && bundle exec foreman start; zsh -i'
# Change the hardstatus settings to give an window list at the bottom of the screen, with the time and date and with the current window highlighted.
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m %{W}%c %{g}]'
@eheikes
eheikes / fucking
Last active December 14, 2015 19:39
batch scripts
#!/bin/bash
case $1 in
"die")
pkill ruby
pkill rake
pkill redis-server
pkill searchd
pkill mongo
;;
"repair")