Skip to content

Instantly share code, notes, and snippets.

Simeon Vincent dotproto

Block or report user

Report or block dotproto

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dotproto
dotproto / silver.js
Created Sep 7, 2017
Reflect + some customizations
View silver.js
export default var Silver = Object.create(Reflect, {
// ownEntries has a similar API to Object.entries, but it uses the same
// enumeration logic as Reflect.keys
ownEntries: {
writable: true,
enumerable: false,
configurable: true,
value: function(obj) {
return Reflect.ownKeys(obj).map(key => [key, obj[key]]);
}
@dotproto
dotproto / look_into.md
Last active Aug 26, 2017
Stuff I should look into.
View look_into.md

Project ideas

  • Project boilerplate that has all the basics set up including
    • Set up CI - or at least provide instructions to make it as painless as possible
    • Watch task for linter
    • Watch task for unit tests
    • Integration test
    • Using headless Chrome to do screenshot diffing for CSS regressions
    • Precommit hooks and/or CI hooks for prettier
@dotproto
dotproto / defaults.js
Created Jul 10, 2017
Ways of handling parameter defaults in JS
View defaults.js
/*
I was just reading through Eric Elliott's ["10 Tips for Better Redux Architecture"](https://medium.com/javascript-scene/10-tips-for-better-redux-architecture-69250425af44) and found myself a little thrown by some of his sample code. Rather than justshrug it off, I took a few minutes to break down the pros/cons of his appoach and a couple other implimentations I was kicking around.
*/
// Eric's original implimentation
const createChat_v1 = ({
id = 0,
msg = '',
user = 'Anonymous',
timeStamp = 1472322852680
View hash-utils.js
// Generate a random hex string of the specified length
var randomHashReadable = function(length = 32) {
const hashLength = Math.ceil(length / 2);
const buffer = crypto.getRandomValues(new Uint8Array(hashLength));
const hex = [].slice.call(buffer).map(val => val.toString(16).padStart(2, '0'));
return hex.join('').substring(0, length);
};
var randomHash = (length = 32) => {
return hex = [].slice.call(crypto.getRandomValues(new Uint8Array(Math.ceil(length / 2)))).map(val => val.toString(16).padStart(2, '0')).join('').substring(0, length);
@dotproto
dotproto / linked-list.js
Last active Jun 6, 2017
Linked List implementation that behaves like a stack (last in, first out)
View linked-list.js
const VOID = Symbol('VOID');
class LinkedItem {
constructor(value) {
this.value = value;
this.next = null;
}
}
class LinkedList {
@dotproto
dotproto / demo.js
Created Mar 15, 2017
Observable -> BehaviorSubject
View demo.js
// Open http://reactivex.io/rxjs/manual/overview.html to run this code
var timer = new Rx.Observable((obs) => {
var counter = 0;
var int = setInterval(() => obs.next(++counter), 1000);
return () => {
clearInterval(int);
obs.complete();
}
});
View setup.js
// TODO: I was going through various alternative forms when I realized I was spending too much time on this.
let data = {
"a": "alpha",
"b": "beta,",
"c": "gamma",
"d": "delta",
"e": "epsilon",
"g": "eta",
"h": "theta",
@dotproto
dotproto / class-to-element.js
Created Feb 8, 2017
Hlper that attempts to convert a custom element class' name into a valid custom element name.
View class-to-element.js
// PCENChar comes from the Custom Element spec
// PCEN = Potential Custom Element Name
// https://www.w3.org/TR/custom-elements/#custom-elements-core-concepts
const PCEN_CHAR = /[-a-z._0-9\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u10000-\uEFFFF]/
const VALID_PCEN = new RegExp(`^[a-z]${PCEN_CHAR.source}*-${PCEN_CHAR.source}*$`)
const CAPS = /([A-Z])/g
const INNER_CAPS = /((?!^|[a-z]))([A-Z])/g
function classNameToElementName(Class) {
@dotproto
dotproto / functional_helpers.js
Last active Dec 15, 2016
Helper functions I didn't realize I wanted until I wrote them a few times in several different projects. Uses ES6 module syntax.
View functional_helpers.js
// ====================
// = OBJECT HELPERS =
// ====================
export const set = (obj, prop, val) => {
obj[prop] = val
return obj
}
export const extractObj = (obj, prop) =>
Object.keys(obj).map(key =>
View .gitconfig
[alias]
# List all aliases
aliases = ! git config --get-regexp ^alias\\. | sed -e s/^alias\\.// -e s/\\ /\\ =\\ /
# Edit your git configuration (cfg)
cfg = config -e --global
# Show the (last) commit
last = log -1
# last = show HEAD
You can’t perform that action at this time.