Skip to content

Instantly share code, notes, and snippets.

@pstjvn
pstjvn / App.js
Created May 7, 2011 12:33
Local music player app
window.addEvent('domready', function() {
//
// augment omni grid to allow finding the next song
//
omniGrid.implement({
findNext: function(randompos) {
if (randompos) {
ci = Math.floor(Math.random() * this.elements.length);
} else {
ci = this.getSelectedIndices()[0] + 1;
@pstjvn
pstjvn / example.js
Created May 26, 2011 14:41
OOEventDispatcher example
(function() {
var BindKeyboard = new Class({
handleKeyboardInput: function(code) {
switch (code) {
case 37:
return 'left';
case 38:
return 'up';
case 39:
return 'right';
@pstjvn
pstjvn / cssbrowserselector.js
Created September 16, 2011 19:36
css browser selector (Raphael Lima)
function css_browser_selector(u) {
var ua = u.toLowerCase(),
is = function(t) {
return ua.indexOf(t) > -1
},
g = 'gecko',
w = 'webkit',
s = 'safari',
o = 'opera',
m = 'mobile',
@pstjvn
pstjvn / jsre.txt
Created October 17, 2011 11:20
JS indent keystroked for Gedit
indent:
^.*\)\s?{$
unindent:
^\s*}$
keys
}
<?php
/**
* Packs some useful methods to be used in the Application models.
*/
class App extends Database {
protected $_uniqueKey;
public function __construct() {
$this->_uniqueKey = 'id';
parent::__construct();
<html>
<head><title>Hoisting</title></head>
<body>
<script>
var F = function() {
console.log('F');
F2();
}
function a() {
F();
@pstjvn
pstjvn / code.gs
Created July 19, 2014 16:33
GAS issue
function onOpen() {
var ui = SpreadsheetApp.getUi();
var utilities = ui.createMenu('Utilities');
utilities
.addItem('Open', 'openDialog')
.addToUi();
}
@pstjvn
pstjvn / dart name spacing
Created April 22, 2015 10:42
How I arrange items in class
PointerAgent.internal(): super.internal() {
_startPoint = new Point(0, 0);
_currentPoint = new Point(0, 0);
_lastPoint = new Point(0, 0);
_longPressDelay = new Delay(1500, _fireLongPress);
_raf = new AnimationFrame(mutate: (_) {_handleAnimationFrame(_);});
_initEventListeners();
}
AnimationFrame _raf;
@pstjvn
pstjvn / 2phaseraf.js
Last active August 29, 2015 14:25
2 phase RAF
(function(global) {
var tasks = [[], []];
var doubleBufferIndex = 0;
var requestFrame = false;
var taskId = 0;
var running = false;
function requestAnimationFrame_() {
if (requestFrame) return;
@pstjvn
pstjvn / example-controller.js
Last active August 29, 2015 14:26
Angular + message bus + external app
goog.provide('test.angular.MainController');
goog.require('goog.string');
goog.require('test.angular.Service');
/**
* Main controller.
*