Skip to content

Instantly share code, notes, and snippets.

View genghisjahn's full-sized avatar

Jon Wear genghisjahn

View GitHub Profile
// PointerTest project main.go
package main
import (
"fmt"
)
func main() {
@genghisjahn
genghisjahn / fizzbuzzpy.py
Last active December 28, 2015 22:09
FizzBuzz exercise in python.
__author__ = 'genghisjahn'
num=1
result = ""
while num<=100:
if(num % 3 == 0 and num % 5 == 0):
result="FizzBuzz"
else:
if(num % 3 == 0):
@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

@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\]'