Skip to content

Instantly share code, notes, and snippets.

View MasterOdin's full-sized avatar

Matthew Peveler MasterOdin

View GitHub Profile

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@MasterOdin
MasterOdin / pig_latin.py
Last active August 29, 2015 14:01
Turns a phrase into pig latin following the rules described on https://en.wikipedia.org/wiki/Pig_Latin
# simple check for if something is a "vowel"
def isVowel(letter):
return letter in ["a","e","i","o","u","y"]
# only phrases that contain only alpha characters is accepted
valid = False
while not valid:
phrase = raw_input("Enter a phrase ==> ")
valid = phrase.replace(" ","").isalpha()
@MasterOdin
MasterOdin / python_qr
Created August 4, 2014 23:19
Python QRServer API Script
import requests
import urllib
from PIL import Image
from StringIO import StringIO
base = "http://forums.somethingawful.com/showthread.php?"
base = base + "threadid=3571852&pagenumber=204#lastpost"
url = urllib.quote(base)
r = requests.get("http://api.qrserver.com/v1/create-qr-code/?data=" + url + "&size=200x200")
print r.status_code
@MasterOdin
MasterOdin / cracker.py
Last active August 29, 2015 14:07
Brute Force Postgres Role Password Checker
import md5
import string
import time
'''
# Brute force solves a md5 hash (for a postgres user role)
# Assumes that password is only [a-zA-Z]
'''
def getNextCharacter(string,pos,characters):
### Keybase proof
I hereby claim:
* I am MasterOdin on github.
* I am masterodin (https://keybase.io/masterodin) on keybase.
* I have a public key whose fingerprint is B60F B57C 9D18 D1AC 25A2 4BDD CA5E 164E 9A4E FBFB
To claim this, I am signing this object:
@MasterOdin
MasterOdin / .gitignore
Last active August 29, 2015 14:09
.gitignore template for all my projects
#==================
# OS X #
#==================
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
@MasterOdin
MasterOdin / AdjacencyChecker.java
Created February 29, 2016 20:38
Given a matrix of 1s and 0s, determine the adjacency of the 1s with each other. (Created to solve http://stackoverflow.com/questions/34524153/algorithm-or-java-code-for-searching-patterns-in-matrix)
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class AdjacencyChecker {
public static void main(String[] args) {
int[][] matrix = {{1,1,1,0,0},{1,0,0,0,1},{1,1,1,0,0},{0,0,0,1,1}};
List<Integer> list = new ArrayList<>();
for (int i = 0; i < matrix.length; i++) {
@MasterOdin
MasterOdin / LipsumGenerator.php
Created April 17, 2016 03:13
A PHP utility for generating Lorem Ipsum dummy text using the feed available from http://www.lipsum.com
<?php
namespace MasterOdin\Gists;
/**
* Class LipsumGenerator
* @package MasterOdin\Gists
*
* Provides a way to generate dummy text to be used on a page using
* http://www.lipsum.com as the generator. More convinent than
@MasterOdin
MasterOdin / elevator.py
Created September 18, 2016 18:01 — forked from elliotchance/elevator.py
The Elevator Game
import random
import time
class Person:
WAITING = 0
IN_ELEVATOR = 1
DONE = 2
def __init__(self, from_floor, to_floor):
self.from_floor = from_floor
@MasterOdin
MasterOdin / sample
Created April 19, 2017 13:15
init.d sample script
#!/bin/sh
### BEGIN INIT INFO
# Provides: sample
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO