Skip to content

Instantly share code, notes, and snippets.

Current endpoints implemented:

GET :8000/v1/ - returns version {"version": "0.0.1"}

POST :8000/v1/story - submits a new story (1)

{"status": "200", "message": "submitted"}

GET :8000/v1/story/list/approved - returns last 10 stories which are approved

1 import os, sys
2 import pygame
3 from pygame.locals import *
4
5 class Game(object):
6
7 def __init__(self, width=640, height=480):
8 pygame.init()
9 self.width = width
10 self.height = height
@ssherar
ssherar / app.py
Last active August 29, 2015 14:21
from flask import Flask, render_template, request, g, redirect
# Set up the app yo
app = Flask(__name__)
# Responds to only GET on the root URL
# and renders the index.tpl as part of the return
# all methods "decorated" witn the @app
# /HAVE/ to return something
@app.route("/", methods=["GET"])
from flask import Flask, render_template, request
import nikeplus
app = Flask(__name__) # creates the application body
@app.post("/nikeplus/activity")
def nike_activity():
data = request.post.data
username = data["username"]
password = data["password"]
<?php
require_once 'NikePlusPHP.php';
function login($user,$pass){
$n = new NikePlusPHP($user, $pass);
return $n;
}
function flatten(array $array) {
$return = array();
@ssherar
ssherar / default.yml
Last active August 29, 2015 14:17
Config for a hook receive library
default:
all:
return: "Request worked"
on_error: "Shit failed {error_msg}"
create:
pulL_repo: true
delete:
pull_repo: true
pull_request:
pull_repo: true
@ssherar
ssherar / commit-msg
Last active August 29, 2015 14:16
Looks for refs, closes or fixes in your commit message
FOUND=$( grep -iE "(refs|closes|fixes)" "$1" )
BRANCH=$( git rev-parse --abbrev-ref HEAD | grep -Eo '[0-9]+' )
if [[ -n $BRANCH ]] && [[ -z $FOUND ]]; then
echo "\033[1;34m > Found an issue within the branch, defaulting to $BRANCH \033[0m"
sed -i "" "2i\\
refs #$BRANCH
" $1
exit 0
elif [[ -z $FOUND ]]; then
def logs(self):
log_path = git.refs.RefLog.path(self.repo.head)
logs = git.refs.RefLog.from_file(log_path)[-5:]
for log in logs:
yield log.time[0], log.message
@ssherar
ssherar / fade.swift
Created March 6, 2015 15:31
Swift - fading the navigationBar to a colour
import UIKit
/// Won't work - will expand the colour from Left hand corner out
self.navigationController?.navigationBar.barTintColor = nil
UIView.animateWithDuration(1.0) {
self.navigationController?.navigationBar.barTintColor = UIColor.blueColor()
}
///Works
self.navigationController?.navigationBar.barTintColor = UIColor.whiteColor()
@ssherar
ssherar / UIColorFromRGB.swift
Last active April 18, 2017 21:05
UIColorFromRGB - adapted from http://stackoverflow.com/a/12397366 for Swift
/**
Returns a UIColor object from a Hexadecimal string with a solid colour
i.e.
UIColorFromRGB("#FF0000") == UIColor.redColor()
UIColorFromRGB("#0000FF") == UIColor.blueColor()
UIColorFromRGB("#GGGGGG") == UIColor.blackColor()
UIColorFromRGB("#Hello") == UIColor.blackColor()