Skip to content

Instantly share code, notes, and snippets.

View lcaballero's full-sized avatar

Lucas Caballero lcaballero

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / yum-cheat-sheet
Created June 26, 2015 21:01
Yum cheat sheet.
`rpm -i some-pacakge.rpm` This doesn't downlaod or install all dependencies. Instead that process must be done manually by the user.
`yum install some-package` Finds the package and it's dependencies, queries meta-data to determine size, then prompts to install y/n.
`/etc/yum.conf` Holds references and values to control yum. Like cachedir and logfile, etc.
`/etc/yum.repo.d` Holds conf for various repository descriptions.
`yum clean` Cleans out various parts of the locally stored information.
`yum makecache` To create the information i your local database for the enabled repos.
`yum remove some-package` To remove some-package.
`rpm -e some-package` Will also remove some-package. Errors out if package is required dependency of another installed package.
`rpm -e --test some-package` Will test to see if the package can be removed.
`yum remove some-package` Will walk the dependencies, show which packages will be removed, and prompt y/n.
@lcaballero
lcaballero / karma-setup.md
Created July 23, 2015 21:32
Notes on setting up Karma

Notes about setting up karma

  • the versions between jasmine and karma are kind of wonky. Likely because Jasmine isn't keeping up with the other changes to karma.
  • karma or mocha, or something I was using, doesn't like coffee even though processors by default includes coffee.
  • PHantomJS really sticks to the 30sec timeout even if all the tests have been run.
@lcaballero
lcaballero / regexes
Created September 4, 2015 00:53
Find \num
matches = [
[ "abc", false ],
[ "a\\1d", true ]
]
re = /\\[0-9]/;
for (var i = 0; i < matches.length; i++) {