Skip to content

Instantly share code, notes, and snippets.

View dotproto's full-sized avatar

Simeon Vincent dotproto

View GitHub Profile
@dotproto
dotproto / bit.js
Created May 5, 2016 18:36
Playing with some ideas for working with bitfields in JS
// name - human readable name for the bit field
// index - Bit offset for the field (zero based)
function BitField(name, index) {
this.name = name;
this.index = Math.pow(2, parseInt(index));
}
BitField.prototype.valueOf = function valueOf() {
return this.index;
};
@dotproto
dotproto / prototypes_tests.js
Last active February 14, 2024 01:54
Object prototype tests
// http://ejohn.org/blog/objectgetprototypeof/
function instanceOf(object, constructor) {
while (object != null) {
if (object == constructor.prototype) {
return true;
}
object = Object.getPrototypeOf(object);
}
return false;
}
/*--------------------------------------------------------------
>>> TABLE OF CONTENTS:
----------------------------------------------------------------
// 0 - Bootstrap variables and mixins
1.0 - Reset
2.0 - Typography
3.0 - Elements
4.0 - Utilities
5.0 - Main
5.1 - Structure
/*
Theme Name: Black n White
Theme URI: http://zacklive.com/new-black-and-white-wordpress-theme/300/
Description: A black and white WordPress Theme, simple and elegant design, widget ready with right sidebar. Fixed the sidebar bug. With control panel, you can set your own RSS feed and header logo. Wordpress 2.7 compatible, Supporting threaded (nested) comments, sticky-post and comment pages.
Version: 2.0.1
Author: Zack
Author URI: http://zacklive.com/
Tags: black, white, two-columns, fixed-width, threaded-comments, sticky-post
Chang Log:
14/Aug/2009: Control panel added.
@dotproto
dotproto / index.html
Created September 10, 2015 18:35
Content editable example
<html>
<head>
<style>
/* We're using floats to prevent spaces from appearing between
* the elements that make up the URL. Alternatives include flex,
* or simply removing the spaces form the HTML. See this link
* for more information:
* https://css-tricks.com/fighting-the-space-between-inline-block-elements/
*/
.url-wrap span {
@dotproto
dotproto / List.js
Last active February 14, 2024 01:54
An extension of Array with some additional helper methods I wanted.
function List () {}
List.prototype = []
List.prototype.constructor = List
List.prototype._return = function _return (val) {
if (val.length <= 1)
val = val[0]
return val
}
@dotproto
dotproto / example.js
Last active February 14, 2024 01:54
Retrieve a list of custom for your Angular module
var deps = require('./getModuleDeps');
console.table(deps('myModule'));
/* Example output (ASCII-fied)
--------------------------------------------------------------
| (index) | provider | type | name |
|---------|--------------------|-------------|---------------|
| 0 | "$compileProvider" | "directive" | "myDirective" |
@dotproto
dotproto / getPushIdTimestamp.js
Last active February 14, 2024 01:54
Convert a Firebase Push ID into Unix time (https://gist.github.com/mikelehen/3596a30bd69384624c11/)
var getPushIdTimestamp = (function getPushIdTimestamp() {
var PUSH_CHARS = '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
return function getTimestampFromId(id) {
var time = 0;
var data = id.substr(0, 8);
for (var i = 0; i < 8; i++) {
time = time * 64 + PUSH_CHARS.indexOf(data[i]);
}

Keybase proof

I hereby claim:

  • I am svincent on github.
  • I am simeon (https://keybase.io/simeon) on keybase.
  • I have a public key whose fingerprint is 9C9B 5CCA 4B4A A1EE 69E3 2BCF 0CE9 6BFE 064E 3BFC

To claim this, I am signing this object:

@dotproto
dotproto / apply.js
Last active February 14, 2024 01:55
Function application as a service
function buildApply() {
var args = Array.prototype.slice.call(arguments, 0);
var fn = args.shift();
// proxy function
return function bindProxy() {
var proxyArgs = Array.prototype.slice.call(arguments, 0);
return fn.apply(null, args.concat(proxyArgs));
}
}