Skip to content

Instantly share code, notes, and snippets.

View Silverwolf90's full-sized avatar

Cyril Silverman Silverwolf90

  • London, UK
View GitHub Profile
@Silverwolf90
Silverwolf90 / guardAccessOfEmptyValues.js
Created June 16, 2021 19:20
guardAccessOfEmptyValues
const DeepProxy = require('proxy-deep');
const { isSymbol, isPlainObject } = require('lodash');
// Empty values trigger access errors
const isEmptyValue = (value) => (
value === undefined ||
value === ''
);
// Check whether the value should be returned
// Is this possible to do?
const ListComponent = ({ items, Actions }) => (
<ul>
{items.map(item => (
<li key={item.id}>
{item.name} <Actions item={item} />
</li>
))}
</ul>
pod 'React', :path => './node_modules/react-native', :subspecs => [
'Core',
'RCTText',
'RCTImage',
'RCTNetwork',
'RCTWebSocket',
'RCTAnimation',
# Add any other subspecs you want to use in your project
]
import {
reduce, mergeWith, isArray, isNumber, every,
cond, add, ary, head, tail, concat, rest,
} from 'lodash/fp';
@Silverwolf90
Silverwolf90 / pattern-matching.js
Last active August 31, 2015 22:19
Simplistic pattern matching in less than 25 lines using switch statement
'use strict';
const types = {
[Number ] : 'number',
[String ] : 'string',
[Boolean] : 'boolean',
[Object ] : 'object'
};
function of(...typesToCheck) {
def scale_on_board(scale,fretboard):
for string_index, string in enumerate(fretboard):
for fret, pitch in enumerate(string):
if pitch in scale:
fretboard[string_index][fret] += "*";
return fretboard
MAX_STRINGS = 6
MAX_FRETS = 12
def note_filter(key):
if key in ['C','G','D','A','E','B','F#','C#']:
return ['C','C#','D','D#','E','F','F#','G','G#','A','A#','B',]
MAX_STRINGS = 6
MAX_FRETS = 12
def note_filter(key):
if key in ['C','G','D','A','E','B','F#','C#']:
return ['C','C#','D','D#','E','F','F#','G','G#','A','A#','B',]
// Get the rendering context
var canvas = $("div.sandbox div.sandbox canvas")[0];
var renderer = new Vex.Flow.Renderer(canvas,
Vex.Flow.Renderer.Backends.CANVAS);
var ctx = renderer.getContext();
var stave = new Vex.Flow.Stave(10, 0, 500);
stave.setContext(ctx).draw();