Skip to content

Instantly share code, notes, and snippets.

@meleyal
meleyal / optimize_images.rb
Created October 19, 2011 11:10
Simple png + jpg optimization script using optipng + jpegtran
#!/usr/bin/ruby
# Instructions
# - Install optipng + libjpeg (http://mxcl.github.com/homebrew/)
# - Put this file in a directory of images
# - Open in TextMate + run it (cmd+r)
# Config
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>GitHub</string>
<key>settings</key>
<array><dict><key>name</key><string>mon_color</string><key>scope</key><string>mcol_999988FF</string><key>settings</key><dict><key>background</key><string>#999988FF</string><key>caret</key><string>#000000FF</string><key>foreground</key><string>#000000FF</string></dict></dict>
<dict><key>name</key><string>mon_color</string><key>scope</key><string>mcol_666666FF</string><key>settings</key><dict><key>background</key><string>#666666FF</string><key>caret</key><string>#FFFFFFFF</string><key>foreground</key><string>#FFFFFFFF</string></dict></dict>
<dict><key>name</key><string>mon_color</string><key>scope</key><string>mcol_999999FF</string><key>settings</key><dict><key>background</key><string>#999999FF</string><key>caret</key><string>#000000FF</string><key>foreground</key><string>#000000
@meleyal
meleyal / air.md
Last active December 19, 2015 03:39
Macbook Air setup 2013
@meleyal
meleyal / example.md
Created June 14, 2013 14:28
Markdown example

An h1 header

Paragraphs are separated by a blank line.

2nd paragraph. Italic, bold, monospace. Itemized lists look like:

  • this one
  • that one
@meleyal
meleyal / search.md
Last active December 18, 2015 07:29
Disable integrated Google search in latest Chrome

Create a new default search engine without the {google:instantExtendedEnabledParameter} token:

Before:

{google:baseURL}search?q=%s&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:searchClient}{google:sourceId}{google:instantExtendedEnabledParameter}ie={inputEncoding}

After:

{google:baseURL}search?q=%s&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:searchClient}{google:sourceId}ie={inputEncoding}

###
**ConditionalField** toggles the visibility of other elements
based on the state of a form field.
Usage:
<input data-show="#example1" data-unless="blank">
<input data-hide="#example2" data-if="['A', 'B', 'C']">
$('[data-if], [data-unless]').conditionalField()
###
**TextUpdater**: change the text of one or more elements when another element changes.
Usage:
<input data-updates="#price, #vat-price" data-price="40 €" data-vat-price="48 €">
<input data-updates="#price, #vat-price" data-price="80 €" data-vat-price="88 €">
$('[data-updates]').textUpdater()
Example 1:
@meleyal
meleyal / backbone-plugin-view.coffee
Created May 28, 2013 10:31
Backbone.PluginView latest
###
Backbone.PluginView
https://github.com/meleyal/backbone.pluginview
Copyright (c) 2012 William Meleyal
MIT License
Make jQuery plugins from your Backbone Views.
Backbone.PluginView extends Backbone.View with some simple helpers for creating jQuery plugins ($.fn).
@meleyal
meleyal / memory.coffee
Last active December 17, 2015 10:58
Tools for debugging memory leaks
# Get all the jQuery bound events on an element:
console.log $._data(el, 'events')
# Create and remove multiple instances of a view:
window.installTest = ->
views = []
viewClass = MyView
options = {}
@meleyal
meleyal / testing.md
Last active December 16, 2015 07:28
Notes on testing
  • If you've already wrote the code, try commenting it all out, then start testing it piece by piece.

  • Test the public API (not internal/implementation details)

  • Test as little as possible to reach a given level of confidence

  • Test the critical parts of your application

  • Test expectations not implementations