Skip to content

Instantly share code, notes, and snippets.

if Rails.env.development? || Rails.env.cucumber?
module ActionView
module Partials
def render_partial_with_annotations(options = {})
begin
if partial_path = options[:partial]
allocated_objects_before = ObjectSpace.allocated_objects
%{\n<!-- START PARTIAL: "#{partial_path}" -->\n#{render_partial_without_annotations(options)}\n<!-- #{ObjectSpace.allocated_objects - allocated_objects_before} objects allocated END PARTIAL: "#{partial_path}" -->\n}
else
@idoru
idoru / appending stderr and stdout to different logfiles and still output to stderr and stdout
Created October 6, 2010 18:25
send stdout and stderr to files but also still output stdout and stderr
(ruby -e 'STDERR.puts("stderr output") ; STDOUT.puts("stdout output") ' | tee -a stdout_logfile.txt) 3>&1 1>&2 2>&3 | tee -a stderr_logfile.txt
@idoru
idoru / XCode_SwapBetweenSpec.scpt
Created November 17, 2010 05:36
[Not compatible with XCode 4] Ever wanted to switch between Cedar specs and your implementation with a single keystroke? Well, there's a user script for that!
(*
SwapBetweenSpec.scpt
Get into the BDD groove with this Xcode user script which quickly toggles between your implementation (or header)
and its Cedar Spec. Bind it to your favorite shortcut key and enjoy the cycle.
Be sure to add this User Script to Xcode as an Applescript, not a shell script:
1. Paste the contents of the gist into ~/Library/Application Support/Developer/Shared/Xcode/User Scripts/SwapBetweenSpec.scpt
2. When adding to script in the "Edit User Scripts" window of Xcode, choose "Add Script File..." and not "New Shell Script" and then choose the file from (1)
3. Set Input to "No Input"
@idoru
idoru / convert-assets.sh
Created March 13, 2011 20:55
Automate the creation of low fidelity assets from Retina assets. Uses CoreImageTool by Marc Liyanage (http://www.entropy.ch/software/macosx/coreimagetool/)
#!/bin/sh
#Get CoreImageTool from http://www.entropy.ch/software/macosx/coreimagetool/
CONVERTER=/usr/local/bin/CoreImageTool
for FILE in $(find . -name \*-hd.png)
do
TARGET=$(echo $FILE | sed -e s@-hd\.png@\.png@)
echo $FILE \=\> $TARGET
$CONVERTER load pic $FILE filter pic CILanczosScaleTransform scale=0.5 store pic $TARGET public.png
@idoru
idoru / gist:962723
Created May 9, 2011 15:21
.gitignore for xcode 4 projects
.DS_Store
*.swp
*~.nib
build/
*.pbxuser
*.perspective
*.perspectivev3
@idoru
idoru / gist:1014467
Created June 8, 2011 14:01
Applescript for an Automator service that switches between specs and implementations
on run {input, parameters}
tell application "Xcode"
set my_workspace to active workspace document
set workspace_projects to projects of my_workspace
set currentFullPath to ""
set projectDir to ""
set reverseDocumentList to (reverse of (source documents as list))
@idoru
idoru / aerobuild.sh
Created June 19, 2011 21:33
bump version, build & archive, tag git version and publish iOS app builds to testflight
#!/bin/sh
#
# aerobuild.sh
#
# What does this do?
# ==================
# - Bumps build numbers in your project using agvtool
# - Builds your app and packages it for testing/ad-hoc distribution
# - Commits build number changes to git
@idoru
idoru / .zshrc
Created July 25, 2011 01:39
.zsh with oh-my-zsh + personalized prompt customization
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
# Set to this to use case-sensitive completion
@idoru
idoru / SwapToSpec.applescript
Created July 8, 2012 03:18
XCode behavior script for quickly opening corresponding Cedar spec and vice-versa
#!/usr/bin/osascript
(*
What does this script do?
This script lets you quickly open the Cedar spec for the corresponding class header/implementation that is currently open in Xcode. If the spec is open, it opens the implementation instead.
How do I use it?
Save this script somewhere.
Start Xcode and go to Xcode > Behaviors > Edit Behaviors…
@idoru
idoru / gist:3102360
Created July 13, 2012 02:41
Clang with ARC bug: Incorrect Template substitution failure
Summary:
When ARC is enabled, C++ candidate templates are ignored due to an incorrectly diagnosed substitution failure.
Steps to Reproduce:
Compile the following main.mm file, with and without ARC:
#import <Foundation/Foundation.h>
template <typename T>