Skip to content

Instantly share code, notes, and snippets.

View ashblue's full-sized avatar

Ash Blue ashblue

View GitHub Profile
@ashblue
ashblue / movement.lua
Last active December 17, 2015 03:49
Shows all possible movement tiles.Written in Lua for Corona SDK
cs = cs or {}
local StepSimple = require('scripts.models.step-simple')
local Movement = {}
function Movement:new()
local o = display.newGroup()
o.open = nil
o.discovered = nil
o.valid = nil
@ashblue
ashblue / worpress-wysiwyg-test.html
Created April 11, 2013 09:27
WordPress WYSIWYG test content
To use this drop it into any content area with a WYSIWYG in the HTML view. Do not post into the visual view or the sky will fall. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent pellentesque vestibulum diam, id placerat nisi tempor quis. Proin erat metus, accumsan in sagittis vitae, suscipit a eros. Nam interdum pellentesque felis consequat condimentum. Maecenas nec augue justo. Vestibulum vehicula sodales diam nec volutpat.
<!--more-->
<h1>Header 1</h1>
<h2>Header 2</h2>
<h3>Header 3</h3>
<h4>Header 4</h4>
<h5>Header 5</h5>
<h6>Header 6</h6>
<h2>YouTube Auto Convert Video</h2>
@ashblue
ashblue / num-set-commas.js
Created April 1, 2013 20:05
Turns a number into a more readable format with commas
/**
* Turns a number into a more readable format with commas
* @param {number} num Number for conversion
* @returns {string} Readable number such as 700,345,384
*/
function setCommas (num) {
var letters = (num).toString().split(''),
count = 0,
readableNum = '';
@ashblue
ashblue / custom-date.js
Created April 1, 2013 20:02
Custom JavaScript prototype class for generating dates
var wk = wk || {};
$(document).ready(function () {
var _monthNames = [
'January',
'February',
'March',
'April',
'May',
'June',
@ashblue
ashblue / helloworld.rake
Last active December 14, 2015 02:59
Rails 3 "Hello World" rake job
# Rails 3
# Place in lib/tasks/helloworld.rake
# Call via "rake hello:world"
# Primary name of the rake job you'll call
namespace :hello do
# Task of the rake job, can support multiple tasks
task :world do
print 'hello world'
end
@ashblue
ashblue / number-to-string-comma.js
Created December 12, 2012 00:09
Converts numbers into a string with commas
/**
* Turns a number into a more readable format with commas
* @param {number} num Number for conversion
* @returns {string} Readable number such as 700,345,384
*/
function setCommas (num) {
var letters = (num).toString().split(''),
count = 0,
readableNum = '';
@ashblue
ashblue / point-in-circle-test.js
Created October 24, 2012 20:42
Detects if the vertex point's x and y are inside of a circle
/**
* Detects if the vertex point's x and y are inside of a circle. Only works with
* plain symetrical circles, not ovals
* @link Adapted from http://stackoverflow.com/questions/2212604/javascript-check-mouse-clicked-inside-the-circle-or-polygon#answer-2212678
* @param {array|number} point Point to test, formatted as [x, y]
* @param {array|number} circleCenter Center of the circle formatted as [x, y]
* @param {number} radius Radius of the circle, which calculates as half its with or height
* @returns {boolean} True if the point is contained in the circle
*/
function pointInCircle (point, circleCenter, radius) {
@ashblue
ashblue / nodejs-recursive-directory.js
Created October 19, 2012 05:06
NodeJS recursive directory listing without a module package
/**
* Goes through the given directory to return all files and folders recursively
* @author Ash Blue [email protected]
* @example getFilesRecursive('./folder/sub-folder');
* @requires Must include the file system module native to NodeJS, ex. var fs = require('fs');
* @param {string} folder Folder location to search through
* @returns {object} Nested tree of the found files
*/
// var fs = require('fs');
function getFilesRecursive (folder) {
@ashblue
ashblue / move-point-at-angle.js
Created October 9, 2012 17:12
Move point at an angle
/**
* Moves a vertex at an angle for a specific distance, 0 degrees points up and 180 degrees points down
* @param {array} point Location on a cartesian graph formatted as [x, y]
* @param {number} angle Angle at which a point should move in radians
* @param {number} distance How far should the point move at the given angle in pixels?
* @returns {array} Newly moved point formatted as [x, y]
*/
function movePointAtAngle (point, angle, distance) {
return [
point[0] + (Math.sin(angle) * distance),
@ashblue
ashblue / angle-between-points.js
Created October 7, 2012 02:14
Angle between points
/**
* Calculates the angle between two separate points. 0 degrees points up and 180 degrees points down
* @link https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/atan2
* @link http://stackoverflow.com/questions/3309617/calculating-degrees-between-2-points-with-inverse-y-axis
* @param {object} start Beginning vertex formatted as {x, y}
* @param {object} end End vertex formatted as {x, y}
* @returns {number} Returns a counterclockwise angle, measured in radians
*/
function angleBetweenPoints (start, end) {
// find angle