Skip to content

Instantly share code, notes, and snippets.

View wassname's full-sized avatar
🙃

Michael J Clark wassname

🙃
View GitHub Profile
@wassname
wassname / Isometric cubes using svg tranforms.markdown
Last active December 11, 2022 15:55
Isometric cubes using svg tranforms

Isometric cubes using svg tranforms

Isometric cubes using svg tranforms. This uses SVG transforms: skew, rotate, and scale, to make isometric cubes of any projections angle (26.6, 30, 45). Good for making SVG sprites for isometric games.

A Pen by M Clark on CodePen.

License.

@wassname
wassname / moveToXYZ.js
Created November 13, 2015 05:58
moveToXY for the Phaser Isometric Plugin
/**
* Move the given display object towards the x/y coordinates at a steady velocity.
* If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.
* Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms.
* Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course.
* Note: The display object doesn't stop moving once it reaches the destination coordinates.
* Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all)
*
* @method Phaser.Physics.IsoArcade#moveToXY
* @param {any} displayObject - The display object to move.
@wassname
wassname / placeAboveOverlaps.js
Last active December 26, 2015 15:03
For Phaser.Plugin.IsoArcarde, this helps displayObject placement by moving it above others. This is done by moving them up until they no longer overlap with anything.
/*
* For Phaser.Plugin.IsoArcard, this helps displayObject placement by moving it above others. This is
* done by moving them up until they no longer overlap with anything.
* @method Phaser.Physics.IsoArcade#placeAboveOverlaps
* @param {any} displayObject - The display object to move.
* @param {any} groupCollision - The the group of displayObjects to check for overlaps with.
* @param {number} [startZ=displayObject.isoZ] - The speed it will move, in pixels per second (default is 60 pixels/sec)
*/
function placeAboveOverlaps(displayObject,groupCollision,startZ){
var overlap
@wassname
wassname / get_ucwa_tokens.js
Last active December 18, 2015 11:36
Uses casperjs or ghost.py to get lync api tokens from https://ucwa.skype.com/login/explore
/*
* Uses casperjs to get api tokens from https://ucwa.skype.com/login/explore
*
* @outputs:
* this will output ucwaTokens.json to current directory
*
* If debug is true, then it will output screenshots to ./debug-images/<name>.png
*
*
* @run
@wassname
wassname / Dockerfile
Last active December 26, 2015 13:43
optional apt-get caching for docker
# configure apt to not install reccomendations
ENV DEBIAN_FRONTEND noninteractive
RUN echo 'APT::Install-Recommends 0;' >> /etc/apt/apt.conf.d/01norecommends \
&& echo 'APT::Install-Suggests 0;' >> /etc/apt/apt.conf.d/01norecommends
RUN apt-get update \
&& apt-get install -y netcat \
&& rm -rf /var/lib/apt/lists/*
# This uses the apt proxy only if present. It checks on port 3142 of the host/gateway, and returns DIRECT for no proxy,
@wassname
wassname / Dockerfile
Last active November 30, 2022 08:56
Cache your pip wheels in docker using devpi, with graceful fails
# This code will use the devpi cache if it can be found
# otherwise fail with a few complaints
RUN export HOST_IP=$(ip route| awk '/^default/ {print $3}') \
&& mkdir -p ~/.pip \
&& echo [global] >> ~/.pip/pip.conf \
&& echo extra-index-url = http://$HOST_IP:3141/app/dev/+simple >> ~/.pip/pip.conf \
&& echo [install] >> ~/.pip/pip.conf \
&& echo trusted-host = $HOST_IP >> ~/.pip/pip.conf \
&& cat ~/.pip/pip.conf
@wassname
wassname / docker-machine-hostnames.sh
Created January 15, 2016 00:17
Bash script to update hostfile to mache docker-machines
#!/bin/bash
sethost () { # set up docker hostnames
# replace everything in line with the right IP, with $IP $MACHINE
D_MACHINE=$1
echo "Update host file for machine=$D_MACHINE"
DATE=$(date -u +%s)
echo "backing up hosts to /tmp/hosts-$(date -u +%s)"
cp /etc/hosts /tmp/hosts-$(date -u +%s)
@wassname
wassname / 1.generate_dockerignore.py
Last active July 21, 2022 13:50
Convert .gitignore to .dockerignore: quick and dirty.
"""
Convert .gitignore to .dockerignore: quick and dirty.
This is a quick and dirty script to convert this:
`__pycache__/`
Into this:
```
__pycache__
*/__pycache__
@wassname
wassname / ascii_trie.py
Last active February 4, 2016 08:50
Visualize a list of search suggestions as an ascii trie.
"""
Visualize a list of search suggestions as an ascii trie.
Inputs:
- searches: a list of strings, each representing a sentance
Usage:
>>>searches=[
'online calculator',
'online photo editor',
@wassname
wassname / jsPromises.js
Created February 9, 2016 00:00
Wait for a jQuery selector in the browser using promises
/**
* This is too show the use of waiting for a jquery selector in the browser
* using promises. Much like how webdriverio works from outside the browser.
*
* Tested with jQuery v1.11.3 and chrome Version 48.0.* (64-bit)
**/
/**
* Wait for a jquery css selector