Skip to content

Instantly share code, notes, and snippets.

View PIXI.WebGLSpriteBatch.prototype.flush.js
/**
* Renders the content and empties the current batch.
*
* Modified for {@link https://github.com/photonstorm/phaser-ce/issues/194 WebGL: INVALID_VALUE: vertexAttribPointer: index out of range (Ubuntu)}.
*
* @method PIXI.WebGLSpriteBatch#flush
*/
PIXI.WebGLSpriteBatch.prototype.flush = function () {
// If the batch is length 0 then return as there is nothing to draw
if (this.currentBatchSize === 0) {
@samme
samme / phaser-sprite-vs-sprite-collision.md
Last active Aug 31, 2017
Phaser sprite vs. sprite collision
View phaser-sprite-vs-sprite-collision.md

Results of collide(sprite1, sprite2) or overlap(sprite1, sprite2).

Body 1 Body 2 collide overlap embedded touching.none overlapX/Y separation¹ acceleration¹
sprite.exists=false false false
enable=false false false
checkCollision.none=true false false
immovable=true true true false ≠ 0 no no
moves=false true true false ≠ 0 yes no²
bounce³ is 0
@samme
samme / html-attributes.md
Last active Apr 6, 2019
Boolean and boolean-like attributes in HTML
View html-attributes.md

Boolean attributes

The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value. If the attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace. The values "true" and "false" are not allowed on boolean attributes. To represent a false value, the attribute has to be omitted altogether.

  • allowfullscreen
  • async
  • autofocus
  • autoplay
  • checked
@samme
samme / phaser-sprite-lifecycle.md
Last active Sep 2, 2017
Phaser Sprite Lifecycle
View phaser-sprite-lifecycle.md
alive exists fresh health renderable visible
sprite.exists = false
sprite.exists = true ✔️ ✔️
sprite.kill()
sprite.revive(…) ✔️ ✔️ 1* ✔️
sprite.reset(…) ✔️ ✔️ ✔️ 1* ✔️ ✔️
group.create(…) ✔️* ✔️* ✔️*
group.createMultiple(…) * * *
group.resetChild(…, x, y) ✔️ ✔️ ✔️ 1 ✔️ ✔️
View Object.assign.coffee
Object.assign ?= (target, sources...) ->
unless target?
throw new TypeError "Cannot convert undefined or null to object"
output = Object target
for source in sources when source?
for own key of source
output[key] = source[key]
View jquery.quantumpubsub.js
/* jQuery Quantum Pub/Sub
* -- from --
* jQuery Tiny Pub/Sub v0.7 (http://benalman.com)
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function( $ ) {
var o = $( {} ),
fn = $.fn,
proxy = $.proxy;
@samme
samme / ∞.js
Created May 31, 2014
Infinity arithmetic
View ∞.js
1 / 0
//-> Infinity
-1 / 0
//-> -Infinity
0 / 0
//-> NaN
Infinity === Infinity
@samme
samme / install.sh
Created Mar 27, 2014
Install image_optim and external binaries (OS X)
View install.sh
# https://github.com/toy/image_optim
gem install image_optim
brew install advancecomp gifsicle jhead jpegoptim jpeg optipng pngcrush
npm install -g svgo
@samme
samme / middleman-build-quiet.sh
Created Sep 5, 2013
Show only changed files when building a middleman project (http://middlemanapp.com/getting-started/)
View middleman-build-quiet.sh
bundle exec middleman build | grep -E '\b(create|delete|error|update)\b'
@samme
samme / _column-grid-background.mixin.scss
Last active Dec 21, 2015
Column-grid-background mixin for Compass. In some cases it seems more accurate than http://compass-style.org/reference/compass/layout/grid_background/#mixin-column-grid-background​​​, and the output is smaller.
View _column-grid-background.mixin.scss
@mixin column-grid-background(
$total : null, // unused
$column : $grid-background-column-width,
$gutter : $grid-background-gutter-width,
$offset : $grid-background-offset,
$column-color : $grid-background-column-color,
$gutter-color : $grid-background-gutter-color
) {
$column-stop: 100% * $column / ($column + $gutter);