Skip to content

Instantly share code, notes, and snippets.

View mstudio's full-sized avatar

Alex Motzenbecker mstudio

View GitHub Profile
@mstudio
mstudio / copy.as
Created November 29, 2011 21:49
AS3: Copy display Object
public static function copy(d:DisplayObject, w:Number, h:Number, smoothing : Boolean = true): Bitmap
{
var data:BitmapData = new BitmapData(w, h, true, 0xffffff);
var bmp:Bitmap = new Bitmap(data);
bmp.smoothing = smoothing;
bmp.bitmapData.draw(d);
return bmp;
}
@mstudio
mstudio / clear-canvas.js
Created February 14, 2012 21:13
HTML5 clear canvas
// this:
context.clearRect(0, 0, width, height);
// or:
canvas.width = canvas.width;
@mstudio
mstudio / isCreditCard
Created March 8, 2012 19:18
Exercise 4
function isCreditCard(CC) {
if (CC.length > 19)
return (false);
var sum = 0; var mul = 1; var l = CC.length; var digit; var tproduct;
for (var i = 0; i < l; i++) {
digit = CC.substring(l - i - 1, l - i);
var main = function() {
var _index;
function iterate() {
console.log(_index);
if (_index > 1)
setTimeout(iterate, 1000);
_index--;
}
@mstudio
mstudio / hwk1
Created March 9, 2012 17:03
hwk1
//functional
function logCar(object) {
this.color = object.color;
this.make = object.make
console.log('I\'m a ' + this.color + ' ' + this.make);
}
// object-oriented
(function(window){
@mstudio
mstudio / Chinese New Year
Last active January 2, 2016 15:39
Chinese New Year Dates and Animals (1924-2015) source: http://en.wikipedia.org/wiki/Chinese_zodiac
dates = [{
date : 'Feb 5 1924',
animal : 'Rat'
},
{
date : 'Jan 24 1925',
animal : 'Ox'
},
{
date : 'Feb 13 1926',
@mstudio
mstudio / threejs.md
Last active June 29, 2017 15:15
ThreeJS Resources
@mstudio
mstudio / index.html
Last active September 7, 2018 13:53
D3 Transitions
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<style>
body {
font: 10px sans-serif;
}
div {
@mstudio
mstudio / cloudSettings
Last active July 16, 2019 16:43
Alex - vscode settings
{"lastUpload":"2019-07-16T16:43:35.573Z","extensionVersion":"v3.4.0"}
@mstudio
mstudio / withData.js
Created October 2, 2019 20:39
React HOC to load data and show Carbon v10 loader
/**
* withData HOC - loads any data as Promise.all, shows loading icon and passes data along via props to children
*/
import React, { Component } from 'react';
import { Loading } from 'carbon-components-react';
import ErrorModal from '../ErrorModal/ErrorModal';
import RequestUtils from '../../utilities/RequestUtils';
/**