Skip to content

Instantly share code, notes, and snippets.

View manufaktor's full-sized avatar
🏠
Working from home

Immi manufaktor

🏠
Working from home
View GitHub Profile
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` or `git checkout` if a specified file was changed
# Run `chmod +x post-checkout` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id HEAD@{1} HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && echo " * changes detected in $1" && echo " * running $2" && eval "$2"
@manufaktor
manufaktor / report.js
Created April 30, 2015 13:25
Create a CSS properties report from the visible elements on page, so you can easily check if you're using too many font-sizes or colors.
// needs jQuery trollollooo
// example: report("fontSize")
// example: report("fontSize", false) // reports the elements which have the given properties
function gather(prop){
var reduce = function(result, item){
var $item = $(item);
var propValue = $item.css(prop);
result[propValue] = result[propValue] || [];
hi from test.html
@manufaktor
manufaktor / number.js
Created December 20, 2013 08:47
format number
Number.prototype.toCurrency = function() {
var value;
if (isNaN(this) || !isFinite(this)) {
return '-';
}
value = Math.abs(this).toFixed(2);
value = value.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,');
return (this < 0 ? '-$' : '$') + value;
};
@manufaktor
manufaktor / products.js
Last active December 30, 2015 08:19
Poor man's colletions in ember.js
App = Ember.Application.create({
collections: Ember.Object.create({
products: null
})
});
App.set("collections.products", Ember.ArrayProxy.create({
content: [],
all: function(params){
// animated route transition workaround for ember
// this workaround only deals with the current view
// if you need to animate the new and the old view in parallel this won't help you.
App.ApplicationRoute = Ember.Route.extend({
actions: {
willTransition: function(transition){
if(!this.isInTransition){
// stop transition until animation is complete
@manufaktor
manufaktor / automate_print_preview.applescript
Last active December 23, 2015 12:39
Open with Apple Script editor, Export as "Application" with "Run only" flag and add to your dock. Happy PDF preview!
-- Setup:
-- 1. Open with Apple Script editor
-- 2. Export as "Application" with "Run only" flag
-- 3. Add to your dock. Happy PDF preview!
set webBrowser to "Firefox" -- or Safari
set pdfMenuItemTitle to "Open PDF in Preview" -- the title of the menu item you want
set myDelay to 0.2
@manufaktor
manufaktor / application.js
Last active December 23, 2015 08:19
Custom events with ember.js and hammer.js
App = Ember.Application.create({
customEvents: {
swipeLeft: 'swipeLeft',
swipeRight: 'swipeRight',
swipeLeftTwoFinger: 'swipeLeftTwoFinger',
swipeRightTwoFinger: 'swipeRightTwoFinger',
dragDown: 'dragDown',
dragUp: 'dragUp',
dragDownTwoFinger: 'dragDownTwoFinger',
dragUpTwoFinger: 'dragUpTwoFinger'
@manufaktor
manufaktor / media-queries.sass
Created April 4, 2013 10:59
Using SASS 3.2 for media query helpers
// A basic media query mixin that makes responsive work simple.
=respond-to($device)
@if $device == handheld
@media only screen and (min-width : 320px)
@content
@if $device == handheld-landscape
@media only screen and (min-width : 320px) and (orientation : landscape)