Skip to content

Instantly share code, notes, and snippets.

@milafrerichs
milafrerichs / AppleBlue.m
Created April 11, 2012 17:53
Default Apple Blue iOS Color
[UIColor colorWithRed:50.0/255.0 green:79.0/255.0 blue:133.0/255.0 alpha:1.0]
@milafrerichs
milafrerichs / button.m
Created April 11, 2012 17:54
Left aligned button on iOS
button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
button.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
@milafrerichs
milafrerichs / pageIDlink.t3s
Created April 11, 2012 17:54
Typo3 Link with Page ID
var EventGarbageCollection = function ( context ) {
var instance = this;
this.collection = [];
this.context = context;
this.context.addEventListener('close', function ( ) {
instance.empty();
});
};
EventGarbageCollection.prototype = {
collect : function ( evt, method ) {
@milafrerichs
milafrerichs / haml_rack.rb
Created December 3, 2012 12:00
Sample Rack App with Haml Templates
class HelloApp
def self.call(env)
require 'haml'
@name = "Test"
template = File.read(File.join("views", "index.haml"))
haml_engine = Haml::Engine.new(template)
output = haml_engine.render(binding)
[200, {'Content-Type' => 'text/html'}, [output]]
end
end
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@milafrerichs
milafrerichs / split_array.coffee
Created November 4, 2013 11:13
Split an array into two halfs
[firstHalf, secondHalf] = [[], []]
for item, index in phases
(if index % 2 then firstHalf else secondHalf).push item
@milafrerichs
milafrerichs / split_array_in_chunks.coffee
Created November 4, 2013 11:17
Split array into chunks of arrays changed to coffeescript from http://stackoverflow.com/a/10456644
Array::chunk = (chunkSize) ->
array = this
[].concat.apply [], array.map((elem, i) ->
(if i % chunkSize then [] else [array.slice(i, i + chunkSize)])
)
@milafrerichs
milafrerichs / nokigiri_searcher.rb
Created January 18, 2014 15:15
A little nokogiri helper I wrote to search and get text or attributes from HTML documents
class NokogiriSearcher
def initialize(html)
@doc = Nokogiri::HTML(html)
end
def search(searchText)
@doc.search(searchText)
end
def first_text_from_search(searchText)
search(searchText).first.text().strip()
end
drawControl.setDrawingOptions({
polygon: {
shapeOptions: {
color: color
}
},
marker: {
options: {
icon: L.mapbox.marker.icon({'marker-color': color}),
draggable: true