Skip to content

Instantly share code, notes, and snippets.

View lcaballero's full-sized avatar

Lucas Caballero lcaballero

View GitHub Profile
@lcaballero
lcaballero / launch_godoc.sh
Created February 17, 2016 00:07
Launches godoc from inside a package opening the doc for that package.
#!/bin/bash
function godoc_procs() {
ps -ef | grep 'godoc -http=:1212' | grep -v grep | cut -f 2 -d ' '
}
function launch_godoc() {
procs=$(godoc_procs)
if [ "$procs" -gt 1 ]; then
godoc_procs | xargs kill -9
@lcaballero
lcaballero / facets.go
Created January 8, 2016 18:40
Reflection that produces all related reflect package types.
package lookup
import "reflect"
type Lookup struct {
target interface{}
}
type Facet struct {
Method reflect.Method
@lcaballero
lcaballero / more-bash-loops.sh
Created November 5, 2015 04:47
more bash loops
#!/bin/bash
function clean() {
rm -rf a b c
}
function _a() {
mkdir a
}
@lcaballero
lcaballero / loop.sh
Created October 8, 2015 17:36
Bash looping
#!/bin/bash
# Examples of Looping in Bash
tools=( git zsh emacs tmux mlocate open-vm-tools )
for r in "${tools[@]}"; do
echo $r
done
@lcaballero
lcaballero / stylus-hasing-iterate
Created September 23, 2015 21:51
Stylus example of iterating over a hash
colors = {
green: #38ab0b
red: #ab130b
blue: #099aab
}
for name, color in colors
.btn-{name}
background: mix(color, white, 60%)
&:hover
@lcaballero
lcaballero / connection-handling.go
Created September 22, 2015 22:32
Go example of connection based handling
type Db struct {
db *bolt.DB
err error
}
func (d *Db) start() *bolt.DB {
d.db, d.err = bolt.Open("my.db", 0600, nil)
if d.err != nil {
fmt.Println(d.err)
}
@lcaballero
lcaballero / indent-lines.go
Created September 17, 2015 21:02
Golang line reading that indents.
func IndentLines(indent, code string) string {
reader := bufio.NewReader(bytes.NewBufferString(code))
buf := bytes.NewBufferString("")
line, prefix, err := reader.ReadLine()
for err == nil && line != nil {
if !prefix {
buf.WriteString(indent)
}
@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++) {
@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 / 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.