Skip to content

Instantly share code, notes, and snippets.

View myles's full-sized avatar
🦖

Myles Braithwaite myles

🦖
View GitHub Profile
@myles
myles / README.md
Last active December 13, 2023 22:52
Backwards port of Django 5.0's update_or_create function

Backwards port of Django's 5.0 update_or_create

The update_or_create model function was updated in Django 5.0 with a create_defaults argument that allows only used during create operations.

@myles
myles / README.md
Last active September 15, 2023 23:02
Colly & Go vs. BeautifulSoup & Python

Colly & Go vs. BeautifulSoup & Python

> time go run cryptocoinmarketcap.go
2017/12/19 17:26:38 Scraping finished, check file "cryptocoinmarketcap-go.csv" for results
        2.24 real         0.84 user         0.45 sys

> time python3 cryptocoinmarketcap.py
WARNING:root:Scraping finished, check file cryptocoinmarketcap-py.csv for results
 3.51 real 2.94 user 0.07 sys
@myles
myles / csv_spliter.py
Last active August 14, 2017 15:31
Quick Python script for splitting large CSV files using Pandas and NumPy.
#!/usr/bin/env python3
import argparse
import math
import os.path
import pandas as pd
import numpy as np
def main(filepath):
@myles
myles / fabfile.py
Created July 11, 2017 19:25
Fabric File for deploying a Laravel website
import datetime
from fabric.api import cd, env, task, run
from fabric.contrib.project import rsync_project
from fabric.utils import puts
env.hosts = ['127.0.0.1']
env.user = 'serverpilot'
env.app_dir = '~/apps/laravel/'
env.releases_dir = '~/.releases/laravel'
@myles
myles / fabfile.py
Created June 27, 2017 13:21
Trellis Fabric File for Transferring Production to Staging
import datetime
import yaml
from ansible_vault.api import Vault
from fabric.api import env, execute, get, local, put, run, task
env.user = 'root'
env.now = datetime.datetime.now().strftime('%Y-%m-%dT%H-%M-%S')
env.roledefs = {
@myles
myles / happy_valentines_day.py
Last active February 14, 2017 15:47
happy_valentines_day.py
#!/usr/bin/env python3
import argparse
def encode(secret):
binary = bin(int.from_bytes(secret.encode(), 'big'))
return binary[2:].replace('0', '❤️').replace('1', '💜')
def decode(code):
@myles
myles / App.js
Created January 26, 2017 16:41
Playing around with WordPress REST API and React
import WordPress from 'wpcom';
import { css } from 'glamor'
import React from 'react';
let PostStyle = css({
borderBottomColor: '#ccc',
borderBottomStyle: 'solid',
borderBottomWidth: '1px',
margin: '1em 0',
<html>
<head><title>Fuzzy Search</title>
<script id="algorithm">
// YOUR CODE HERE !
</script>
@myles
myles / Makefile
Created August 22, 2016 12:46 — forked from toolmantim/Makefile
An example of using Make instead of Grunt for fast, simple and maintainable front-end asset compilation.
# A simple Makefile alternative to using Grunt for your static asset compilation
#
## Usage
#
# $ npm install
#
# And then you can run various commands:
#
# $ make # compile files that need compiling
# $ make clean all # remove target files and recompile from scratch
@myles
myles / pptx-to-png.sh
Last active November 9, 2017 18:23
Convert a bunch of PowerPoint files to PNG files.
for pptx in *.pptx;
do
libreoffice --headless --convert-to pdf $pptx
convert -density 400 `basename $pptx`.pdf -resize 2000x1500 `basename $pptx`%d.jpg
rm `basename $pptx`.pdf
done