Skip to content

Instantly share code, notes, and snippets.

@pix0r
pix0r / CustomTextView.h
Created July 10, 2011 18:51
CustomTextView (UITextView subclass with border)
//
// CustomTextView.h
//
// Created by Mike Matz on 7/10/11.
// Copyright 2011 Flying Yeti. All rights reserved.
//
#import <Foundation/Foundation.h>
@andredublin
andredublin / gist:1441363
Created December 7, 2011 03:46
activerecord rpsec pg error
Failure/Error: Unable to find matching line from backtrace
ActiveRecord::StatementInvalid:
PGError: ERROR: syntax error at or near "IDENTITY"
LINE 1: TRUNCATE TABLE RESTART IDENTITY CASCADE;
^
: TRUNCATE TABLE RESTART IDENTITY CASCADE;
@csoma
csoma / gist:de71e151607940d6e523
Last active December 22, 2015 17:08
Remove GitHub Wiki page elements before printing

GitHub Wiki updated Bookmarklet (Sep 2014)

Note: Will not work with Firefox, see bug #866522

Wiki - Hides extra panels:


javascript:(function(e,a,g,h,f,c,b,d)%7Bif(!(f=e.jQuery)%7C%7Cg%3Ef.fn.jquery%7C%7Ch(f))%7Bc=a.createElement(%22script%22);c.type=%22text/javascript%22;c.src=%22https://ajax.googleapis.com/ajax/libs/jquery/%22+g+%22/jquery.min.js%22;c.onload=c.onreadystatechange=function()%7Bif(!b&&(!(d=this.readyState)%7C%7Cd==%22loaded%22%7C%7Cd==%22complete%22))%7Bh((f=e.jQuery).noConflict(1),b=1);f(c).remove()%7D%7D;a.documentElement.childNodes%5B0%5D.appendChild(c)%7D%7D)(window,document,%221.3.2%22,function($,L)%7B$('%23header,%20.pagehead,%20.breadcrumb,%20.commit,%20.meta,%20%23footer,%20%23footer-push,%20.wiki-actions,%20%23last-edit,%20.actions,%20.header,%20%23wiki-rightbar,%20.gh-header-actions,%20.sunken-menu-contents,%20.site-footer').remove();%20$('%23files,%20.file').css(%7B%22background%22:%22none%22,%20%22border%22:%22none%22%7D
@garbados
garbados / player.rb
Last active January 2, 2016 12:39
Solution to ryanb/ruby-warrior intermediate difficulty, on epic.
## PERFORMANCE (1/7/13)
#
# CONGRATULATIONS! You have climbed to the top of the tower and rescued the fair maiden Ruby.
# Your average grade for this tower is: A
#
# Level 1: S
# Level 2: A
# Level 3: A
# Level 4: B
# Level 5: A
@v2keener
v2keener / tampermonkey-basic-injection-w-jQuery.js.sublime-snippet
Last active April 1, 2016 08:26
Snippet: Base TamperMonkey injection script with jQuery via Google APIs
// ==UserScript==
// @name ${1:Some fancy name}
// @namespace ${2:https://gist.github.com/9665787}
// @version 0.1
// @description ${3:Some description}
// @match /* ALLOW TAMPERMONKEY TO FILL THIS IN *OR* COPY FROM TAMPERMONKEY */
// @copyright 2014+, ${4:Gustavo Keener}
// ==/UserScript==
// Add jQuery, unless it already exists
-- inspired by: https://groups.google.com/d/msg/elm-discuss/2LxEUVe0UBo/ZgJ_ldUH6ygJ
-- thanks for the help: http://learnyouahaskell.com/functors-applicative-functors-and-monoids
module UserDecoder where
import Date exposing (Date)
import User exposing (User)
import Json.Decode as Js exposing ((:=))
-- Applicative's `pure`:
module LiquidPresenters
class Plan < SimpleDelegator
def to_liquid
@to_liquid ||= HashWithIndifferentAccess.new({
id: self.id,
name: self.name,
description: self.description,
status: self.status,
class_id: self.plan_class_id
})
@kurenn
kurenn / gist:4421177
Last active March 29, 2017 21:16
This gist shows how to make a polymorphic association for users in rails which have an specific role, such as Member, Admin...works with devise
##Userable
module Userable
def self.included(base)
base.has_one :user, :as => :userable, :dependent => :destroy, :autosave => true
base.validate :user_must_be_valid
base.alias_method_chain :user, :autobuild
base.extend ClassMethods
base.define_user_accessors
end
@nixpulvis
nixpulvis / term_size.rb
Last active October 18, 2017 11:50
Get the terminal window size. Not in a bullshit ENV dependent manor.
# From the tty_ioctl man page in Linux.
#
# TIOCGWINSZ struct winsize *argp
# Get window size.
#
# TIOCSWINSZ const struct winsize *argp
# Set window size.
#
# The struct used by these ioctls is defined as
#
require 'non_digest_assets'
namespace :assets do
task :non_digested do
NonDigestAssets.new.generate
end
end