Skip to content

Instantly share code, notes, and snippets.

@andytwoods
andytwoods / add_homeIP_to_RDS_securitygroup.py
Created July 23, 2018 13:09
small script to add home ip address to AWS RDS security group.
# step 1, create a new security group and associate it with your existing RDS, alongside existing SGs (modify your DB instance to do this).
# step 2, add profile and security_group_id info below.
# step 3, python add_homeIP_to_RDS_securitygroup.py
import boto3
from botocore.exceptions import ClientError
import requests
profile = "xxxxx"
security_group_id = "sg-xxxxxxxxxxxxxxx"
@andytwoods
andytwoods / del_migrations.bat
Created May 24, 2018 10:38
delete all django migration files in migration folders, via bat file, for windows
FOR /d /r . %%d IN (migrations) DO @IF EXIST "%%d\0*.py" del "%%d\0*.py"
@andytwoods
andytwoods / buttons_menu_template.html
Last active March 11, 2018 11:31
CommandMixin (frontend buttons do stuff in CBV)
//give the buttons the 'run-command' class. Specify the command they run via data-command parameter. If you want to send data to the
//backend, suffix your command with () and add a js function with the same name as your commmand somewhere (that returns the data for
//backend. E.g. data-command='hello()' and function hello(){return 'hi!'}
<div class="col-md">
<a class="btn btn-sm run-command" data-command="worker_job_complete" id="worker_job_complete_button" role="button">
ongoing</a>
@andytwoods
andytwoods / languageMutate.js
Last active June 10, 2017 17:43
translate obj of strings into obj of random strings of 30+ languages. Useful perhaps for generative testing.
//all complete example sentences from http://kermitproject.org/utf8.html
//UTF-8 Sampler / The Kermit Project / Columbia University / kermit@kermitproject.org
//@AndyTWoods created below.
//eg mutateWords({a:'abc',b:'def'}) returning eg {a:'οσa',b:'ᚔकाλ'}
var mutateWords = function(obj, preserve_length) {
if(!preserve_length) preserve_length = true
var many_languages_example = {
@andytwoods
andytwoods / interweave.js
Created April 25, 2017 19:09
interweave two arrays. Can be different sizes.
export default function interleave(arr1, arr2){
"use strict";
let combined = []
let arr1_len = arr1.length
let arr2_len = arr2.length
while(arr1_len>0 || arr2_len >0){
if(arr1_len>0){
combined.push(arr1.shift())
arr1_len--
}
@andytwoods
andytwoods / LICENSE-MIT
Last active March 27, 2024 21:04 — forked from electricg/LICENSE-MIT
Stopwatch in javascript
Copyright (c) 2010-2015 Giulia Alfonsi <electric.g@gmail.com>
Modified work Copyright 2017 Andy Woods
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
@andytwoods
andytwoods / index.js
Created July 21, 2016 12:31
requirebin sketch
//https://github.com/Qix-/color-convert
var convert = require('color-convert');
//https://github.com/zschuessler/DeltaE
var DeltaE = require('delta-e');
function dist_hex(hex1, hex2){
var lab1= convert.hex.lab.raw(hex1);
var lab2= convert.hex.lab.raw(hex2);
return DeltaE.getDeltaE00( clean_lab(lab1), clean_lab(lab2) );
}
package com.Start.MobileStart
{
import flash.display.Sprite;
import flash.display.Stage;
import flash.display.StageOrientation;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.system.Capabilities;