Skip to content

Instantly share code, notes, and snippets.

View smolck's full-sized avatar

smolck

View GitHub Profile
@stevedonovan
stevedonovan / css.lua
Created August 30, 2011 10:31
A little Lua DSL for generating CSS
--[[
A Lua module that defines a little DSL for generating CSS
-- csstest.lua
require 'css'
width = 500
lmargin = 50
leftm = 150
gap = 10
@zester
zester / gist:5163313
Created March 14, 2013 17:27
Using Skia With GLFW (Or any other framework that provides an OpenGL context [GLUT,SDL,etc...])
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
#include "glfw/glfw.h"
#include "skia/include/gpu/GrContext.h"
#include "skia/include/gpu/GrRenderTarget.h"
#include "skia/include/gpu/GrGLInterface.h"
#include "skia/include/gpu/SkGpuDevice.h"
@birkir
birkir / bmw-ibus.cpp
Created May 14, 2013 15:14
BMW I-Bus monitor and decoder
/**
* BMW IBus Daemon reads BMW IBus data through serial port. It detects
* BMW board monitor(at least BM53) unit and steering wheel button presses
* from IBus data, maps them to key events and injects them to system event
* queue via uinput.
*
* It also can be configured to inject key events only in certain state like
* TAPE or AUX which can be useful if you want to hijack for example TAPE
* mode for other use.
*
@vukicevic
vukicevic / Draw Bitmap From Int Array
Last active October 31, 2023 08:50
Generate a monochrome bitmap image in JavaScript using a byte-array. The image is generated such that every bit in the array is shown as either a black (1) or white (0) pixel.
/**
* depth: 1 - monochrome
* 4 - 4-bit grayscale
* 8 - 8-bit grayscale
* 16 - 16-bit colour
* 32 - 32-bit colour
**/
function drawArray(arr, depth) {
var offset, height, data, image;
@adrianseeley
adrianseeley / compute.html
Last active July 12, 2024 20:13
WEBGL COMPUTE SHADER SETUP
<!DOCTYPE html>
<html>
<canvas id="c" width="128" height="128"></canvas>
<script src="glutil.js"></script>
<script id="vshader" type="text/plain">
attribute vec2 vtxpos;
varying vec2 texpos;
void main() {
texpos = (vtxpos / 2.) + vec2(0.5, 0.5);
gl_Position = vec4(vtxpos, 0, 1);
@adrianseeley
adrianseeley / glutil.js
Last active March 22, 2023 06:10
QP GPU (queue-pee gee-pee-you, or just Q-P for short) Quantum Particles via Graphics Processing Unit
window.onerror = function (msg, url, lineno) {
alert(url + '(' + lineno + '): ' + msg);
}
function createShader (str, type) {
var shader = gl.createShader(type);
gl.shaderSource(shader, str);
gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS))
throw gl.getShaderInfoLog(shader);
@adrianseeley
adrianseeley / GPU_MSDA_FF_ANN.html
Last active April 27, 2021 18:18
A Sinus Activated Multi-Stochastic-Descending/Ascending (MSD/A) Feed Forward Artificial Neural Network (ANN) Computed by GPU via JavaScript and WebGL GLSL (GATO 2014) :: Fiddle: http://jsfiddle.net/Hnv8H/
<!DOCTYPE html>
<html>
<pre id="page" style="font-family: monospace; white-space: pre-wrap;">
<h3>A Sinus Activated Multi-Stochastic-Descending/Ascending (MSD/A) Feed Forward Artificial Neural Network (ANN) Computed by GPU via JavaScript and WebGL GLSL (GATO 2014)</h3>This web page attempts to outline an implementation for solving non-linearly-separable (NLS) classification and function approximation problems using a sinus activated feed forward neural network, trained via multi-stochastic-descension/ascension (MSD/A), and evaluated using the GPU via JavaScript and WebGL GLSL source code.
In order to overcome NLS using MSD/A, a sinus activation function: <b>sin(x)</b>, has been used in place of sigmoid: <b>1 / (1 + exp(-x))</b>, hyper-tangent: <b>htan(x)</b>, and/or averaging: <b>sum / count</b>, activation functions.
Although ANNs capable of overcoming NLS problems are said to be capable of entering any computationally complete state, actually finding and entering a specific state required to solve a real
@jasonkit
jasonkit / lena.js
Last active August 14, 2023 13:17
Using WebGL to do Gaussian Blur
var canvas_in = document.getElementById("canvas_in");
var canvas_out = document.getElementById("canvas_out");
var img = new Image();
img.onload = function() {
var w = this.width;
var h = this.height;
canvas_in.width = canvas_out.width = w;
canvas_in.height = canvas_out.height = h;
@azu
azu / profile.js
Created December 31, 2015 06:06
Electron startup time
// LICENSE : MIT
"use strict";
// call from node
exports.start = function () {
global.profile_startTime = Date.now();
};
// call from renderer
exports.stop = function () {
var ms = Date.now() - require('remote').getGlobal('profile_startTime');
console.log("profile", ms + "ms");
@andrewrk
andrewrk / 3let.py
Created February 15, 2016 03:27
origin of the zig programming language name. https://github.com/andrewrk/zig/
import string
import random
vowels = "aoeuiy"
def m():
c1 = vowels[random.randint(0,len(vowels)-1)]
c2 = string.ascii_lowercase[random.randint(0,len(string.ascii_lowercase)-1)]
c3 = string.ascii_lowercase[random.randint(0,len(string.ascii_lowercase)-1)]
print('z' + c1 + c2 + c3)
m()