Skip to content

Instantly share code, notes, and snippets.

@joewest
joewest / gist:8602228
Created January 24, 2014 17:40
Center a subview in a superview using Auto Layout's visual format language O_o
UIView *superview = self.view;
NSDictionary *variables = NSDictionaryOfVariableBindings(label, superview);
NSArray *constraints =
[NSLayoutConstraint constraintsWithVisualFormat:@"V:[superview]-(<=1)-[label]"
options: NSLayoutFormatAlignAllCenterX
metrics:nil
views:variables];
[self.view addConstraints:constraints];
constraints =
@joewest
joewest / gist:6997432
Last active December 25, 2015 15:19
Drawing a CGGradient in Monotouch
var bounds = Bounds;
var context = UIGraphics.GetCurrentContext ();
// Gradient using CGGradient
PointF start = new PointF (0.0f, 0.0f);
PointF end = new PointF (0.0f, bounds.Height-(bounds.Height*0.20f));
CGGradient gradient;
using (var rgb = CGColorSpace.CreateDeviceRGB ()) {
float[] color1 = new float[] { 0.0f, 0.0f, 0.0f, 0.0f }; // Black Clear
float[] color2 = new float[] { 0.0f, 0.0f, 0.0f, 1.0f }; // Black
@joewest
joewest / gist:3745557
Created September 18, 2012 20:12
Ember update for Sept 18 2012
aug 27
Application must call initialize (this is breaking)
disconnectOutlet method added, used rarely
ember-bootstrap project has moved https://github.com/emberjs-addons/ember-bootstrap
dagda1 article on routing http://www.thesoftwaresimpleton.com/blog/2012/08/20/routing_update/
sept 10
add currentPath to Ember.StateManager and therefore the router as shorthand for calling currentState.path
APPNAME = 'wh'
require 'json'
require 'rake-pipeline-web-filters'
WebFilters = Rake::Pipeline::Web::Filters
class LoaderFilter < WebFilters::MinispadeFilter
def generate_output(inputs, output)
inputs.each do |input|
@joewest
joewest / gist:1879042
Created February 21, 2012 21:21
config.ru for rake-pipeline with proxy support
require 'rake-pipeline'
require 'rake-pipeline/middleware'
require 'net/http'
require 'net/https'
require 'uri'
module Rack
class Proxy
def initialize(app, project, opts={})
@joewest
joewest / gist:1870565
Created February 20, 2012 18:35
add to .bashrc file to make git project directories reveal their current branch
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\[\033[00m\]\u@\h\[\033[01;34m\] \W \[\033[31m\]\$(parse_git_branch) \[\033[00m\]$\[\033[00m\] "
@joewest
joewest / gist:1701702
Created January 30, 2012 00:58 — forked from bobspryn/gist:1549100
AssetFile
require "json"
require "uglifier"
require "rake-pipeline-web-filters"
# this gives you concat, coffee_script, and minispade methods
require "rake-pipeline-web-filters/helpers"
class HandlebarsFilter < Rake::Pipeline::Filter
def initialize(&block)
block ||= proc { |input| input.sub(/\.handlebars$/, '.js') }
@joewest
joewest / ls-r.sh
Created January 28, 2012 17:06
Assetfile and dir structure
require "rake-pipeline-web-filters"
output "assets"
input "." do
match "{assets,tmp}/**/*" do
filter PipelineFinalizingFilter
end
match "app/**/*.js" do
@joewest
joewest / gist:1678702
Created January 25, 2012 21:02
Assetfile
require "rake-pipeline-web-filters"
input "."
output "assets"
match "{assets,tmp}/**/*" do
filter PipelineFinalizingFilter
end
match "app/**/*.js" do
@joewest
joewest / didRequestRange.js
Created January 13, 2012 20:14
Ember.PaginationSupport
App.collectionController = Em.ArrayProxy.create(Ember.PaginationSupport, {
content: [],
fullContent: App.store.findAll(App.Job),
totalBinding: 'fullContent.length',
didRequestRange: function(rangeStart, rangeStop) {
var content = this.get('fullContent').slice(rangeStart, rangeStop);
this.replace(0, this.get('length'), content);
}
});