Skip to content

Instantly share code, notes, and snippets.

@boyter
boyter / puzzle.py
Last active April 9, 2017 18:27
Friday Quiz Solution
# Three people are playing the following betting game.
# Every five minutes, a turn takes place in which a random player rests and the other two bet
# against one another with all of their money.
# The player with the smaller amount of money always wins,
# doubling his money by taking it from the loser.
# For example, if the initial amounts of money are 1, 4, and 6,
# then the result of the first turn can be either
# 2,3,6 (1 wins against 4);
# 1,8,2 (4 wins against 6); or
# 2,4,5 (1 wins against 6).
# Snippet 1
###########
# Copy the build folder(containing the html files) to a folder in flask's static
# directory and serve this way:
@app.route('/<dir>/<filename>', defaults={'static': True})
def build_dir(dir='',filename='index.html'):
path = join(dir,filename)
return app.send_static_file(path)
@jeffgodwyll
jeffgodwyll / recursive_x_mod
Created March 2, 2015 23:42
When I move my android sdk folder onto an NTFS disk, I tend to loose the executable bit. This is to remedy the situation a whole lot better.
# Run in project root
# Recursively add executable bit to all files without a dot filename
find -type f -not -name "*.*" -exec chmod +x \{\} \;
# Recursively add exec bit to all files with .so in filename
find -type f -name "*.so*" -exec chmod +x \{\} \;
# Recursively add exec bit to all files with .so in filename
find -type f -name "*.jar*" -exec chmod +x \{\} \;
#!/usr/bin/python
'''
Convert Blogger xml-exported file to markdown
Primarily from https://gist.github.com/larsks/4022537 with some modifications
'''
import os
import sys
import argparse
import iso8601
import re
@merqurio
merqurio / login.py
Last active April 24, 2019 19:20
Flask login using Google App Engine User Service
# import dependencies
from functools import wraps
from google.appengine.api import users
from flask import redirect, request
USERS = ["any@gmail.com", "any@googleapps.com"]
#Set's the login to Google Users Service
def login_required(func):
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@quchen
quchen / trolling_haskell
Last active February 24, 2024 01:30
Trolling #haskell
13:15 <xQuasar> | HASKELL IS FOR FUCKIN FAGGOTS. YOU'RE ALL A BUNCH OF
| FUCKIN PUSSIES
13:15 <xQuasar> | JAVASCRIPT FOR LIFE FAGS
13:16 <luite> | hello
13:16 <ChongLi> | somebody has a mental illness!
13:16 <merijn> | Wow...I suddenly see the error of my ways and feel
| compelled to write Node.js!
13:16 <genisage> | hi
13:16 <luite> | you might be pleased to learn that you can compile
| haskell to javascript now
@malarkey
malarkey / Contract Killer 3.md
Last active April 16, 2024 21:44
The latest version of my ‘killer contract’ for web designers and developers

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008

…………………………

@larsks
larsks / blogger2scriptogram.py
Created November 6, 2012 04:23
Convert Blogger posts to Markdown for use with Scriptogr.am
#!/usr/bin/python
import os
import sys
import argparse
import iso8601
import re
import subprocess
import logging
import json