Skip to content

Instantly share code, notes, and snippets.

View danielpuglisi's full-sized avatar
💭
🤘

Daniel Puglisi danielpuglisi

💭
🤘
View GitHub Profile
@roidrage
roidrage / ebooks.md
Created December 2, 2011 15:15
Self-published and awesome
@ParkinT
ParkinT / uilabel_adjustable.rb
Created July 8, 2012 04:28
RubyMotion class to auto-size font for text in a multi-line UILabel
class UILabel_Adjustable
# Borrowed and modified the excellent example at http://www.11pixel.com/blog/28/resize-multi-line-text-to-fit-uilabel-on-iphone/
# adapting it for RubyMotion
# This applies only to a multi-line label. You can use '.adjustsFontSizeToFitWidth = true' for a single-line label
# usage is:
# text = "It's bad luck to be superstitious"
# text_label = UILabel.alloc.initWithFrame([[20, 20], [70, 120]])
# text_label.numberOfLines = 0 # set 0 for word wrap
# text_label.lineBreakMode = UILineBreakModeWordWrap
@mattlenz
mattlenz / markdown_handler.rb
Created July 27, 2012 01:03
Rails Markdown (Kramdown) Template Handler
# config/initializers/markdown_handler.rb
module MarkdownHandler
def self.erb
@erb ||= ActionView::Template.registered_template_handler(:erb)
end
def self.call(template)
compiled_source = erb.call(template)
"Kramdown::Document.new(begin;#{compiled_source};end, auto_ids: false).to_html"
@ysawa
ysawa / insertAtCaret.js.coffee
Created October 29, 2012 23:21
jQuery insertAtCaret CoffeeScript
jQuery.fn.extend insertAtCaret: (myValue) ->
@each (i) ->
if document.selection
# For browsers like Internet Explorer
@focus()
sel = document.selection.createRange()
sel.text = myValue
@focus()
else if @selectionStart or @selectionStart is "0"
# For browsers like Firefox and Webkit based
# bring up the vagrant VM
sudo apt-get install vagrant
git clone https://bitbucket.org/puffnfresh/vagrant-haskell-heroku.git
cd vagrant-haskell-heroku
vagrant up
vagrant ssh
# run this in vagrant shell
cabal update
cabal install cabal-install
@ericboehs
ericboehs / gist:7125105
Created October 23, 2013 19:30
Poltergeist hack to silence CoreText performance notes from phantomjs
module Capybara::Poltergeist
class Client
private
def redirect_stdout(to)
prev = STDOUT.dup
prev.autoclose = false
$stdout = to
STDOUT.reopen(to)
prev = STDERR.dup
@shiwano
shiwano / _grab.scss
Created July 21, 2012 12:41
grab cursor scss mixins
@charset "UTF-8";
@mixin grab-cursor {
// http://www.google.com/intl/en_ALL/mapfiles/openhand.cur
cursor: url('data:image/vnd.microsoft.icon;base64,AAACAAEAICACAAcABQAwAQAAFgAAACgAAAAgAAAAQAAAAAEAAQAAAAAAAAEAAAAAAAAAAAAAAgAAAAAAAAAAAAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD8AAAA/AAAAfwAAAP+AAAH/gAAB/8AAA//AAAd/wAAGf+AAAH9gAADbYAAA2yAAAZsAAAGbAAAAGAAAAAAAAA//////////////////////////////////////////////////////////////////////////////////////gH///4B///8Af//+AD///AA///wAH//4AB//8AAf//AAD//5AA///gAP//4AD//8AF///AB///5A////5///8='), all-scroll;
// cursor: -webkit-grab;
cursor: -moz-grab;
cursor: -o-grab;
cursor: -ms-grab;
cursor: grab;
@yoavram
yoavram / build_pandoc_for_heroku.sh
Last active April 29, 2017 16:28
How to build pandoc for heroku. This was run on an Ubuntu 12.04 machine with root permission. Regular lines are commands, lines starting with '>' represent the output of a command.
sudo apt-get install vagrant
git clone https://bitbucket.org/puffnfresh/vagrant-haskell-heroku.git
cd vagrant-haskell-heroku
vagrant up
vagrant ssh
cabal update
cabal install cabal-install
cabal --version
> cabal-install version 0.14.0
> using version 1.14.0 of the Cabal library
@subelsky
subelsky / asset.rake
Created March 3, 2013 21:48
Quick rake task to check if assets need to pre-compiled before deployment (since I don't like precompiling during deployment)
namespace :assets do
task :check do
root_dir = File.join(File.dirname(__FILE__),"..","..")
assets_last_modified_at = Dir["#{root_dir}/app/assets/**/**"].map { |p| File.mtime(p) }.sort.last
assets_last_compiled_at = Dir["#{root_dir}/public/assets/**/**"].map { |p| File.mtime(p) }.sort.last
if assets_last_modified_at > assets_last_compiled_at
fail "Assets need to precompiled; last asset modified at #{assets_last_modified_at}"
end
end
@themusicman
themusicman / include-experiments.rb
Created July 5, 2012 23:35
Experiments with Module Includes in Ruby
# I created a generic Rails like ApplicationController so that you can just
# run this code via a command line prompt without the need for Rails
module Recorder
def self.included(base)
base.send(:before_filter, :some_method)
base.send(:after_filter, :another_method)
end