Skip to content

Instantly share code, notes, and snippets.

View genghisjahn's full-sized avatar

Jon Wear genghisjahn

View GitHub Profile
@genghisjahn
genghisjahn / sort_sequential.py
Created February 18, 2014 03:32
Determines if a list of integers are seqential (n,n+1,n+2, etc..)
def _sequential_ints(self, item_vals):
prev = 0
result = False
item_vals.sort()
for i in item_vals:
if prev > 0:
if i - prev != 1:
break
prev = i
else:
def _sequential_ints(self, item_vals):
return len(item_vals) == len(set(item_vals)) == max(item_vals) - min(item_vals) + 1
"""
len(item_vals) returns the number of items in the list.
len(set(item_vals)) returns the unique number of items in the list
If those == then we know there are no dupes in the list.
Lastly, if there are no dupes and the max value minus the min value (+1)
equals the len(item_vals), then we know that each int is sequential and that there are no duplicates.
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 */
@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"
@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:

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 / 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

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 / 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() {
@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)
}