Skip to content

Instantly share code, notes, and snippets.

View simplyluke's full-sized avatar

Luke Wright simplyluke

View GitHub Profile
@simplyluke
simplyluke / main.go
Created March 18, 2023 14:57
ice backend
package main
import (
"net/http"
"os"
"strconv"
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
_ "github.com/joho/godotenv/autoload"
@simplyluke
simplyluke / errors.py
Last active March 19, 2018 16:26
flask json errors
# App error handling
@app.errorhandler(404)
def page_not_found(e):
return jsonify(error=404, text=str(e)), 404
@app.errorhandler(500)
def internal_server_error(e):
return jsonify(error=500, text=str(e)), 500
@simplyluke
simplyluke / mc-sub.js
Created February 11, 2018 21:00
Mailchimp Ajax subscribe
$('#mc-embedded-subscribe-form').submit(function(e) {
e.preventDefault();
$('#loading_gif_mc').show();
$('#mc_embed_signup').hide();
$.ajax({
type: $('#mc-embedded-subscribe-form').attr('method'),
url: $('#mc-embedded-subscribe-form').attr('action'),
data: $('#mc-embedded-subscribe-form').serialize(),
cache: false,
dataType: 'json',
@simplyluke
simplyluke / auth.py
Created April 2, 2017 23:32
flask auth
import os
from flask import Flask, request, session, url_for, redirect, \
render_template, abort, g, flash
from flask_bcrypt import Bcrypt
app = Flask(__name__)
bcrypt = Bcrypt(app)
app.config.from_object(os.environ['APP_SETTINGS'])
@simplyluke
simplyluke / homework.py
Last active January 3, 2016 01:59
the bridge problem
def higher(x):
a = (x-252.0)**2.0
b = a/(-824.0)
return b + 136 - 59
def lower(x):
a = (x-252.0)**2.0
b = a/(-538.1695)
return b + 118 - 59
@simplyluke
simplyluke / gist:8191381
Last active January 1, 2016 19:38
RP Application API Design

Outline: RESTful API to manage the infrastructure of the application. Create users/goals/points via API and build mobile applications on top of it. I'm not too familiar with developing apps in this way, but it does not seem overly complicated. Pleae correct anything obviously wrong with this plan, still a noob

Users

Endpoints:

Users:

  • get /users, returns all users
  • get /users/:id, returns user
@simplyluke
simplyluke / gist:8078644
Created December 22, 2013 04:59
Code club facebook solicitation
Austin High Students: I'm looking to start a code club in which we teach some programming skills and also collaborate in small groups on interesting projects.
I'm looking for 1 or 2 people to help me start this and a teacher to sponsor the club (they don't need to be overly involved in it, but AHS requires one). You don't need to be a programmer to help lead this, but you do need to have a desire to learn and help.
I'm working with a non-profit trying to enable starting these kinds of clubs with some very talented educators and coders in LA to help provide the materials.
If you know anyone who you think would be interested or teachers who may be able to sponsor it please let me know.
@simplyluke
simplyluke / gist:7557842
Last active December 28, 2015 20:29
.vimrc
:set number
:syntax on
:colorscheme solarized
:set tabstop=2
:set shiftwidth=2
:set expandtab
@simplyluke
simplyluke / gist:7557856
Created November 20, 2013 04:43
pgp public key - luke@simplyluke.com
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: SKS 1.1.0
mQINBFHcY3gBEAC6+EYoo80RApDi6RGtuyt9czBKcxms9WdlVrTOEULvZ9INY56ugCTC+R5T
l49pj97NE3R12QAZdchd7XsqFWeeTr3jUMQo2FMZ3LX+yzoqDCjKkIQwe9S9iqjwgn3KmQbV
9akB/W1lXuQXhAHQ6IDVKBjvKPZiDndNLpaJ4Eu45HZtTBitM9g7gTRAE+MetmQf5xD9a/ar
RUi8Gwm1OTT7HE85p6rxY4U5w8pk/9ffhCfoTvcOfHF/TZUf+8+W0L0p0dI5t1IlnpJ6Sc5I
xFeOkPZIHnl3k6EKMKO/2FH287OrUGgzIoczR/8Evy+u6jR6kTg3pgAd+Z+EZqIa8crE9EXl
ymJUhH3KjZUJJnhBAsB6LGxproELaVTFTYSHRUmbDM8qE31Be6FkMgRRAOcIQBTBZYXAN+c6
D29ACMGGi5ZY52x1Hef+jNGT8qTAEsN8QNjcUV7nkWrZ26KRKM76s3x4QzJRI+fdSTqt84AJ
func fizzBuzz(n: Int) -> String {
if n % 3 == 0 && n % 5 == 0 {
return "FizzBuzz"
} else if n % 5 == 0 {
return "Buzz"
} else if n % 3 == 0 {
return "Fizz"
} else {
return String(n)
}