Skip to content

Instantly share code, notes, and snippets.

View genghisjahn's full-sized avatar

Jon Wear genghisjahn

View GitHub Profile
@genghisjahn
genghisjahn / pipestuff.md
Last active August 29, 2015 14:17
Pipe Command Stuff you need to Memorize

Memorize this stuff!!

  • git br | grep deeplink returns all the branches that have deeplink in the name.
  • find . | grep language finds all the files with the string language in the name.
  • find . -name "*.sql" finds all the files that end with .sql in the name.
  • find . "*user*" | xargs cat finds each file with user in the title and then cats them all.
  • find . -name "*.go" | xargs cat | wc -l finds each file that ends with .go and counts the total lines of code.
@genghisjahn
genghisjahn / demo.go
Created February 9, 2015 03:53
TextLengthDemo
func ProcessText(text string, items []TextLengthItem) string {
firstParts := []string{"This text is %v characters in length.", "Text is %v characters long.", "Text is %v characters in length."}
result_template := "%v %v"
textLength := len(text) + 2
for _, firstPart := range firstParts {
for _, item := range items {
length_sentence := fmt.Sprintf(firstPart, item.Text)
if textLength+len(length_sentence) == item.Value {
return fmt.Sprintf(result_template, text, length_sentence)
}
@genghisjahn
genghisjahn / random.go
Created February 6, 2015 03:42
Sphero Random Roll
package main
import (
"time"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/sphero"
)
func main() {

Keybase proof

I hereby claim:

  • I am genghisjahn on github.
  • I am genghisjahn (https://keybase.io/genghisjahn) on keybase.
  • I have a public key whose fingerprint is 617E C2B6 541C C343 4BE5 5AEF 7C34 BAA9 9CF5 A66F

To claim this, I am signing this object:

@genghisjahn
genghisjahn / colorgitbash.bash
Created June 12, 2014 03:41
Colorful Informative Github Bash Prompt
export PS1='$(git branch &>/dev/null; if [ $? -eq 0 ]; then \
echo "\[\e[0;32m\][GIT: \[\e[0;31m\]$(basename `pwd`); \[\e[0;33m\]$(git branch | grep ^*|sed s/\*\ //) \
$(echo `git status` | grep "nothing to commit" > /dev/null 2>&1; if [ "$?" -eq "0" ]; then \
echo "\[\e[0;32m\]clean"; else \
echo "\[\e[0;31m\]dirty"; fi)\[\e[0;32m\]] \$ "; else \
echo "\[\e[0;31m\][\w]\[\e[m\] \$ "; fi) \[\e[0m\]'
@genghisjahn
genghisjahn / ubunturedisinstall.md
Last active August 29, 2015 14:02
Redis install on base Ubuntu 64 server

From terminal, first run:

sudo aptitude install build-essential

Then do the normal redis install as mentioned on their website.

wget http://download.redis.io/redis-stable.tar.gz

tar xvzf redis-stable.tar.gz

sudo apt-get update # Fetches the list of available updates

sudo apt-get dist-upgrade # for additional major updates/upgrades

sudo apt-get upgrade #to load any updates.

@genghisjahn
genghisjahn / CopySSHKeyToServer.md
Last active August 29, 2015 14:02
How to copy local SSH public key to a server.

Use this so you can SSH into a VM you just made.

On the HOST

For Virtual Box: Put Network Settings from NAT to Bridged Adapter the Host VM. To start headless : Hold shift down and clic start button

On the server you will be SSH'ing into:

@genghisjahn
genghisjahn / main.go
Last active August 29, 2015 14:02
Hash Example
// http://play.golang.org/p/YxTFqTxBPv
package main
import (
"crypto/hmac"
"crypto/rand"
"crypto/sha512"
"encoding/base64"
"encoding/json"
go get code.google.com/p/go.talks/present
go get code.google.com/p/go.tools/cmd/present
cd ~/go/src/code.google.com/p/go.talks/2014
present hellogophers.slide
/* Open your web browser and visit http://127.0.0.1:3999/ */
/* Open up the various .slide files to get an idea of how to format your presentation */