Skip to content

Instantly share code, notes, and snippets.

# USAGE:
# parser = Util::PlistParser.new("#{ENV['HOME']}/.cappconfig")
# config_hash = parser.parse!
module Util
class PlistParser
attr_accessor :file
DOCTYPE = /280NPLIST;1.0;D;/
// Attempt to make a drop-and-forget bunch of scripts that mimick some missing html5 goodies automatically
// Example:
// $(document).ready(function() {
// ProvideHtml5.autofocus()
// ProvideHtml5.datepicker()
// ProvideHtml5.forcenumber()
// })
var ProvideHtml5 = {
autofocus = function() {
@nickw
nickw / gist:1043436
Created June 23, 2011 19:38
Permissions Query
def viewable_by(user)
# An item is viewable if:
# 1. There are no permissions set
(!self.blocking_enabled? && !self.targeting_enabled?) ||
# 2. OR the user owns the item
(self.user_id == user.id) ||
# 3. OR the item is not blocked from the user
.browser {
h3 {
margin-bottom: 10px;
}
ol {
@include pie-clearfix;
}
}
@nickw
nickw / jquery.myplugin.coffee
Created April 24, 2012 01:49 — forked from jimeh/jquery.myplugin.coffee
Example jQuery plugin written in CoffeeScript, and the resulting compiled JavaScript file.
$.fn.extend
myplugin: (options) ->
self = $.fn.myplugin
opts = $.extend {}, self.defaultOptions, options
for el in this
self.init el, opts
self.log el if opts.log
$.extend $.fn.myplugin,
class CH.Views.PostFormView extends Backbone.View
events:
"focus #post_title": "focus"
initialize: ->
$("body").on "click", (event) => @blur(event)
focus: ->
@$(".post-form-expanded").show()
CH.Concerns.Voteable =
incrementScore: ->
score = parseInt(@get("score"), 10)
@set "score", score+1
decrementScore: ->
score = parseInt(@get("score"), 10)
@set "score", score-1
View
clickVote: (event)->
direction = event.direction
oppositeDirection = if direction is "up" then "down" else "up"
if currentUser.hasVoted(@model, direction)
@model.removeVote(direction)
else
if currentUser.hasVoted(@model, oppositeDirection)
@model.removeVote(oppositeDirection)
@nickw
nickw / sinatra_new_relic_1.rb
Created March 18, 2013 21:03
sinatra_new_relic_1.rb sets up New Relic in the config.ru <br> sinatra_new_relic_2.rb sets up New Relic in the Sinatra App
# server.rb
$: << File.expand_path(File.dirname(__FILE__) + "/../lib")
require "sinatra/base"
require "newrelic_rpm"
module CrowdHall
class Server < Sinatra::Base
configure do
set :app_file, __FILE__
define(‘sayHello’, function(name) {
return function(name) {
alert(‘Hi ‘ + name + ‘!’);
}
});