Skip to content

Instantly share code, notes, and snippets.

View divanvisagie's full-sized avatar
🦕
It's a UNIX system, I know this!

Divan Visagie divanvisagie

🦕
It's a UNIX system, I know this!
View GitHub Profile
@divanvisagie
divanvisagie / background.js
Created June 11, 2013 11:08
Chrome packaged app template
chrome.app.runtime.onLaunched.addListener( function(){
chrome.app.window.create( 'window.html', {
'bounds' : {
'width' : 400,
'height' : 500
}
} );
} );
@divanvisagie
divanvisagie / WebSql.js
Created June 12, 2013 09:15
Template for client side sqlite
/* Storage */
var MyProject = {};
MyProject.webdb = {};
MyProject.webdb.db = null;
MyProject.webdb.open = function(){
var dbSize = 5 * 1024 * 1024; // 5MB
MyProject.webdb.db = openDatabase( 'myDb' , '1.0' , 'MyProject client side data' , dbSize ); //
@divanvisagie
divanvisagie / webdb.js
Last active December 18, 2015 09:59
Devtools snippet for working with webSql
/*
Created By: Divan Visagie
Created On: 2013/06/12
License: MIT
Version: 0.0.1
*/
var webdb = {};
webdb.db = null;
webdb.dbDetails = { //set default db details
@divanvisagie
divanvisagie / objc.js
Created June 15, 2013 17:28
A snippet with different usage examples in NodObjC. Not all of this works but the concepts are mainly correct
var $ = require( 'NodObjC' );
// First you import the "Foundation" framework
$.import( 'Foundation' );
$.import( 'Cocoa' );
// Setup the recommended NSAutoreleasePool instance
var pool = $.NSAutoreleasePool( 'alloc' )( 'init' );
// NSStrings and JavaScript Strings are distinct objects, you must create an
@divanvisagie
divanvisagie / Animal.cpp
Created June 16, 2013 11:21
Simple C++ setup example with inheritance and callbacks
//
// File.cpp
// PlayGround
//
// Created by Divan Visagie on 2013/06/16.
// Copyright (c) 2013 Divan Visagie. All rights reserved.
//
#include "Animal.h"
@divanvisagie
divanvisagie / SOUT.js
Last active December 18, 2015 14:49
A static object that provides a print function that prints to stdout but keeps track of the amount of characters and will automatically insert /b characters. Usage: SOUT.print( 'Something' );
var SOUT = {
outputLength : 0,
lastOutLength : 0,
print : function( stOut ){
SOUT.outputLength = SOUT.lastOutLength;
@divanvisagie
divanvisagie / eventEmitter.js
Created June 21, 2013 05:20
An example of event emission in the browser
function Test(){
var eve = document.createElement('e');
var ev = new CustomEvent( 'testEv', {'':''} );
setInterval( function(){
eve.dispatchEvent( ev );
@divanvisagie
divanvisagie / Index.aspx
Last active December 18, 2015 19:29
A simple bunch of template code for what I think is the best way to build C# .NET web grids. Uses knockout, jquery and requirejs to get the job done. Data is in a compact sql database and is accessed through an ADO.net model
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="KGrids.Index" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>KGrids</title>
<link rel="stylesheet" type="text/css" href="Content/bootstrap.min.css" />
<script src="Scripts/knockout-2.2.1.js"></script>
<script src="Scripts/jquery-2.0.2.min.js"></script>
@divanvisagie
divanvisagie / pinMapper.js
Created June 23, 2013 12:11
Maps pins for johnny-five
five.Board().on("ready", function() {
var pi = [];
var pins = this.firmata.pins;
for ( var i in pins ){
pi.push( pins[i].supportedModes.length );
}
console.log( pi );
@divanvisagie
divanvisagie / ecma_old.js
Created July 9, 2013 12:29
Newer js features for ancient browsers
'use strict';
// Add ECMA262-5 method binding if not supported natively
//
if (!('bind' in Function.prototype)) {
Function.prototype.bind= function(owner) {
var that= this;
if (arguments.length<=1) {
return function() {
return that.apply(owner, arguments);