Skip to content

Instantly share code, notes, and snippets.

View lcaballero's full-sized avatar

Lucas Caballero lcaballero

View GitHub Profile
@lcaballero
lcaballero / go-cli
Created June 15, 2015 05:07
An example of Go cli usage. Using codegangsta/cli
func main() {
app := cli.NewApp()
app.Name = "cli"
app.Version = "0.0.1"
app.Usage = "Fight the lack of Go knowledge"
app.Commands = []cli.Command {
{
Name: "web",
Aliases: []string{"s"},
Usage: "Start the web server.",
@lcaballero
lcaballero / basic-tasks-in-go
Last active August 29, 2015 14:22
Basic tasks in Go... (read file, output json, print to stdout).
package main
import (
"fmt"
"io/ioutil"
"encoding/json"
)
type Data struct {
Id string `json:"id"`
@lcaballero
lcaballero / bg-image-ui-view
Created June 8, 2015 06:08
Snippet of code that put's an image in the background of a UIImageView and scales it appropriately to the main window dimentions.
UIScreen* mainScreen = [UIScreen mainScreen];
CGRect frame = mainScreen.bounds;
MyUIView* view = [[MyUIView alloc] initWithFrame:frame];
UIImage* background = [UIImage imageNamed:@"[email protected]"];
UIImageView* bgView = [[UIImageView alloc] initWithImage:background];
bgView.frame = frame;
@lcaballero
lcaballero / gist:1b48ec42a818babb8aa8
Created April 27, 2015 22:54
Translate a style.css
#!/bin/bash
mkdir -p dest/temp
sed -e '
s/:before[ ]*{//
/^[^.]/d
/^$/d
' src/site/styles/style.css > dest/temp/icons.txt
@lcaballero
lcaballero / dc-names
Created April 22, 2015 02:06
Dc Character Names
Oliver Queen Green Arrow
Alan Scott Green Lantern
Will Everett Amazing Man
Irwin Schwab Ambush Bug
Buddy Baker Animal Man
Arthur Curry Aquaman
Roy Harper Red Arrow
Ray Palmer Atom
@lcaballero
lcaballero / gen-completions
Created April 18, 2015 20:49
Example generating bash completions.
yargs = require 'yargs'
args = yargs
.options(
t:
alias: "tstuff"
description: "Does t stuff"
b:
alias: "batman"
@lcaballero
lcaballero / git-cherry-local-dir
Last active August 29, 2015 14:13
One-liner that commit's a change via a SHA from one local git dir to another.
# This one-liner commits a change from another local dir to the current repo.
# It uses a patch file to export the change and the does a 3 way commit.
# Found here: http://stackoverflow.com/questions/5120038/is-it-possible-to-cherry-pick-a-commit-from-another-git-repository
$ git --git-dir=../some_other_repo/.git \
format-patch -k -1 --stdout <commit SHA> | \
git am -3 -k
@lcaballero
lcaballero / angular-inspect-cheats
Created January 19, 2015 17:48
Some angular cheats.
// Additional references: http://ionicframework.com/blog/angularjs-console/
// Get the scope of the element selected under the Chrome developer tool tab
c = angular.element($0).scope()
// Get the 'MyService' from the angular injector
angular.element(document.body).injector().get('MyService')
@lcaballero
lcaballero / git-add-empty-dir
Created October 15, 2014 23:12
A git file used to keep an empty directory.
# Ignore everything in this directory
*
# Except this file
!.gitignore
@lcaballero
lcaballero / toLookup
Last active August 29, 2015 14:07
A lodash mixin that maps an array of items to a map where.
_.mixin
###
Turns an array of values into an associated object where the keys are
properties found on items of the array. For instance, turning a list of
users into a map of IDs to the Person.
Examples:
# Simple/typical usage
lookup = _.toLookup(items, 'property')