Skip to content

Instantly share code, notes, and snippets.

@sTiLL-iLL
sTiLL-iLL / sniffColors
Created August 20, 2013 08:30
Compare the color values of individual pixels by calculating the vector positioning between individual pixels within the standard ternary groupings "(R,G,B)".. Use this to detect nudity, etc...
public static unsafe void sniffColors(Bitmap bmp,
byte r, byte g, int b, int heft)
{
BitmapData dta = image.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height),
ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
int bPxl=3;
byte* chk1=(byte*)imageData.Scan0.ToPointer();
int trn=imageData.Stride;
int hgt=imageData.Height;
int wdt=imageData.Width;
@sTiLL-iLL
sTiLL-iLL / datalist examples
Last active December 21, 2015 02:29
datalist experiments....
// month type options
<input type="month" list="months" />
<datalist id="months">
<option label="Eiji's birthday">1976-02</option>
<option label="End of last century">2000-12</option>
<option>2010-01</option>
<option label="Now">2012-11</option>
</datalist>
// week options
@sTiLL-iLL
sTiLL-iLL / funCyLib.js
Last active December 20, 2015 15:08
more abstractions...
function map(func, array) {
var len = array.length;
var rst = new Array(len);
for (var i = 0; i < len; i++)
rst[i] = func(array[i]);
return rst;
}
function reduce(func, start, array) {
var len = array.length;
@sTiLL-iLL
sTiLL-iLL / 4EveryOne.js
Created August 4, 2013 18:48
4 all Items in a list loop logic
// on every "yada" in "yada"....
function onEachIn(object, action) {
try {
for (var property in object) {
if (Object.prototype.hasOwnProperty.call(object, property))
action(property, object[property]);
}
} catch (e) {
throw e;
@sTiLL-iLL
sTiLL-iLL / forEvery.js
Last active December 20, 2015 14:59
some home-made "underscore" type constructs
// my for-each thing
function forEeach(array, action) {
try {
var len = array.length;
for (var i = 0; i < len; i++)
action(array[i]);
} catch (e) {
throw e;
}
@sTiLL-iLL
sTiLL-iLL / myEvent.js
Last active December 20, 2015 14:29
custom eventing
//create event
var minE = new CustomEvent("yourEventName", {
detail: {
"key": value
},
bubbles: true,
cancelable: true
});
//add handler
@sTiLL-iLL
sTiLL-iLL / img2canvas.js
Created August 3, 2013 12:12
img 2 canvas
// Converts image to canvas; returns new canvas element
function Img2Cnvs(image) {
var canvas = document.createElement("canvas");
canvas.width = image.width;
canvas.height = image.height;
canvas.getContext("2d").drawImage(image, 0, 0);
return canvas;
@sTiLL-iLL
sTiLL-iLL / cloneIt.js
Created August 3, 2013 11:37
kustom klone method
function clone(src) {
function mixem(src, dst, fnc) {
var i, em, nm, j = {};
for(nm in src){
j = src[nm];
if(!(nm in dst) || (dst[nm] !== j && (!(nm in em) || em[nm] !== j))){
dst[nm] = fnc ? fnc(s) : j;
}
}
@SunboX
SunboX / inlineworker.js
Created June 24, 2013 12:21
Create web workers without a separate worker JS files. Source: http://jsbin.com/owogib/8/
function worker() {
setInterval(function() {
postMessage({foo: "bar"});
}, 1000);
}
var code = worker.toString();
code = code.substring(code.indexOf("{")+1, code.lastIndexOf("}"));
var blob = new Blob([code], {type: "application/javascript"});
@sTiLL-iLL
sTiLL-iLL / clock2.html
Last active December 18, 2015 02:29
Widget inHTML and JS (jquery-ui) smooth animated clock
<!-- clock widget exmple -->
<!DOCTYPE html>
<html>
<head runat="server">
<meta charset="utf-8">
<title></title>
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>