Skip to content

Instantly share code, notes, and snippets.

View MarkVillacampa's full-sized avatar
:octocat:
just setting up my gthb

Mark Villacampa MarkVillacampa

:octocat:
just setting up my gthb
View GitHub Profile
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
@andreif
andreif / bridge.rb
Created May 8, 2012 18:47
bridgesupport
require "hpricot"
require "fileutils"
module BridgeSupport
class Parser
def initialize(path_from, path_to)
@doc = open(path_from) {|f| Hpricot(f).search('signatures').first}
if @doc and @doc.children
FileUtils.mkdir_p File.dirname(path_to)
o = open(path_to, 'w')
@colinta
colinta / my_application_controller.rb
Created May 15, 2012 00:20
glowing custom font
# from BubbleWrap
def rgba_color(r, g, b, a=1)
UIColor.colorWithRed((r/255.0), green:(g/255.0), blue:(b/255.0), alpha:a)
end
class MyApplicationController < UIViewController
def viewDidLoad
font = UIFont.fontWithName('Inconsolata', size:20)
@0xced
0xced / XCDFakeCarrier.m
Last active March 5, 2023 22:07
Hack to choose the displayed carrier name in the iOS simulator
//
// Copyright (c) 2012-2015 Cédric Luthi / @0xced. All rights reserved.
//
#import <Foundation/Foundation.h>
#if TARGET_OS_SIMULATOR
static const char *fakeCarrier;
static const char *fakeTime;
a = 3
a.class.instance_eval do
define_method :my_method, ->(arg1 = :my_arg, *args, &block) do
p "arg1 #{arg1} args #{args.inspect}"
block.call
end
end
(main)> a.my_method(:my_arg_really, 1, 2, 3, 4, 5) do
(main)> p "Hello!"
@nikcub
nikcub / README.md
Created October 4, 2012 13:06
Facebook PHP Source Code from August 2007
@steipete
steipete / gist:3933090
Created October 22, 2012 18:13
Simple main thread usage detector that I'm using in PSPDFKit to find performance problems early on.
// Smart little helper to find main thread hangs. Enable in appDidFinishLaunching.
// Only available with source code in DEBUG mode.
@interface PSPDFHangDetector : NSObject
+ (void)startHangDetector;
@end
@implementation PSPDFHangDetector
+ (void)startHangDetector {
#ifdef DEBUG
@amrox
amrox / hack.sh
Created November 2, 2012 06:50 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/3999124/hack.sh | sh
#
@puffnfresh
puffnfresh / SpacesDemo.m
Created November 11, 2012 07:19
Demo of Spaces API discovered via reverse engineering
#include <Carbon/Carbon.h>
typedef uint64_t CGSConnection;
extern CGSConnection _CGSDefaultConnection(void);
#define CGSDefaultConnection _CGSDefaultConnection()
typedef uint64_t CGSSpace;
typedef enum _CGSSpaceType {
kCGSSpaceUser,
kCGSSpaceFullscreen,
@jspahrsummers
jspahrsummers / gist:4305792
Last active April 29, 2021 01:55
CGRectDivideWithPadding illustrations

Simple visual illustrations of how CGRectDivideWithPadding works.

Slicing from CGRectMinXEdge
  +-------+---------+------------>
e |       |         |
d | slice | padding | remainder…
g |       |         |
e |       |         |