Skip to content

Instantly share code, notes, and snippets.

View dotproto's full-sized avatar

Simeon Vincent dotproto

View GitHub Profile
@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 / 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 / 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 {
/*
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.
/*--------------------------------------------------------------
>>> 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
@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;
}
@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 / inheritance.js
Last active February 14, 2024 01:53
JS Inheritance (ES5)
// == PARENT ===================================================================
// CONSTRUCTOR
// For this demo we'll be inheriting from the Parent class
function Parent() {}
// METHODS
Parent.prototype.foo = function foo() {
return 'FOO';
}
@dotproto
dotproto / tts.js
Last active February 14, 2024 01:53
ES2015 Text to Speech bookmarklet (Ctrl+S). Set up: Copy and paste the contents of this gist into a new bookmark. Use: Select some text and click the bookmarklet to start speaking. Once activated on a page, you can use Ctrl+S to speak the selected text. Speech Synthesis API Info: https://developers.google.com/web/updates/2014/01/Web-apps-that-ta…
javascript: {
/* Adjust voice speed. Default = 1 */
var speed = 2.5;
if (window.runTTS === undefined) {
/* Text to Speech function. Adjust the value of msg.rate to increase/decrease the playback speed. */
window.runTTS = () => {
const text = window.getSelection().toString();
@dotproto
dotproto / property_lookup.js
Last active May 26, 2016 01:11
`lookup` provides a failable wait to retrieve a deep property without throwing (Function version)
var sourceObject = { foo: { bar: { baz: { qux: { value: "Hit!" } } } } };
function lookup(targetObject, targetPath) {
const name = 'o';
const properties = [];
const segments = targetPath.split('.');
for (let i = 1; i <= segments.length; i++) {
const current = `${name}.${segments.slice(0, i).join('.')}`;
properties.push(current);