Skip to content

Instantly share code, notes, and snippets.

View rapsacnz's full-sized avatar
🏠
Working from home

Caspar Harmer rapsacnz

🏠
Working from home
View GitHub Profile
@chriskoch
chriskoch / drawString.js
Created April 14, 2010 16:59
draw a multiline string in a html5 canvas element including rotation font fontsize and color
/*
* draw a multiline string rotated in a canvas
*
* @param ctx (M) context of the canvas
* @param text (M) string may contain \n
* @param posX (M) horizontal start position
* @param posY (M) vertical start position
* @param textColor color
* @param rotation in degrees (by 360)
* @param font must be installed on client use websafe
@ThomasBurleson
ThomasBurleson / gist:1017230
Created June 9, 2011 17:26
Cool Techniques with AS3 Closures
// ------------------------------------------------------------------------------------------------
/**
* Why CLOSURES are great!
*
* Think of Closures as Functions within Functions... where nested functions have access to parent function variables
* and arguments. So, you may ask?
*
* Closures allow developers to temporarily cache data!
* Closures can simplify recursion or iterations (aka visitors pattern)
* Closures can solve real-world `callback` problems; especially powerful for asynchronous callbacks.
@brenes
brenes / README.md
Last active July 10, 2024 13:50
CSV de paises, con nombre en castellano, ingles, codigo ISO y prefijo telefónico del país
@ThomasBurleson
ThomasBurleson / gist:1157828
Created August 19, 2011 19:52
AS3 Closures Cleanup
public class Something
{
public function doSomething(index:int) : void
{
// Async closure for timer completion event
function onComplete_doSomething(evt:TimerEvent) : void
{
// Always clean up 1st, then notify listeners
timer.removeEventListener(TimerEvent.TIMER, onComplete_Timer );
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active July 17, 2024 14:20
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@lesleh
lesleh / chunkArray.java
Last active March 10, 2024 20:16
Java function to split an array into chunks of equal size. The last chunk may be smaller than the rest.
// Example usage:
//
// int[] numbers = {1, 2, 3, 4, 5, 6, 7};
// int[][] chunks = chunkArray(numbers, 3);
//
// chunks now contains [
// [1, 2, 3],
// [4, 5, 6],
// [7]
// ]
@dun4n
dun4n / vcard.html
Last active April 26, 2024 04:32
#JavaScript vcard generator example
<!doctype html>
<html>
<head>
<script type="text/javascript" src="vcard2.js"></script>
</head>
<body>
<script type="text/javascript">
// With helper methods
var fooBar = vCard.create(vCard.Version.FOUR)
fooBar.addFormattedname("Mr Foo Bar")
@ilyazub
ilyazub / excel_xml_spreadsheet_example.md
Last active January 4, 2023 03:47
Excel 2003 XML Spreadsheet example

Excel 2003 XML Spreadsheet example

Example

image

spreadsheet.xml

Solved errors

Problem During Load because of wrong ss:ExpandedRowCount.

@yuval-a
yuval-a / js-micro.js
Last active May 16, 2024 21:01
Javascript micro-optimizations
NOTE: This document is OLD - and most of the tips here are probably outdated, since newer versions of Javascript have been
released over the years - with newer optimizations and more emphasis on optimizing newly supported syntax.
// Array literal (= []) is faster than Array constructor (new Array())
// http://jsperf.com/new-array-vs-literal/15
var array = [];
// Object literal (={}) is faster than Object constructor (new Object())
// http://jsperf.com/new-array-vs-literal/26
@miguelmota
miguelmota / text-offset.js
Created March 21, 2015 19:56
Get offset position of text in JavaScript
var characters = document.querySelector('.characters'); // div with text
var charactersText = characters.textContent;
var charAtIndex = 25;
var offsetPosition;
characters.textContent = '';
for (var i = 0; i < charactersText.length; i++) {
var textNode = document.createTextNode(charactersText[i]);
characters.appendChild(textNode);
if (i === charAtIndex) {