Skip to content

Instantly share code, notes, and snippets.

View r01010010's full-sized avatar

Paloma Jiménez r01010010

  • Barcelona
View GitHub Profile
public class Blade {
// edge (smooth, saw) [0, 3]
// needle/ending (pointy, blunt, hook, flat, ring,)
// damaged (undamaged, damaged) [0, 3]
// shape (straight, curved) [0, 3]
// decoration (undecorated, decorated) [0, 3]
// width (thin, fat) [0, 3]
// inscriptions (uninscribed, symbols, runes, symbols)
// material (wood, metal, stone, bone, glass, plastic, ceramic, paper, cardboard, fabric, leather, rubber, foam, wax, ice, food, other)
// color (red, orange, yellow, green, blue, purple, pink, brown, black, white, gray, other)
// frontend
import { DeepstreamClient } from "@deepstream/client";
const client = new DeepstreamClient("localhost:6020");
client.login();
client.on("connectionStateChanged", (connectionState) => {
if (connectionState === "OPEN") {
const record = client.record.getRecord("sincrypto/users.01");

Role Management

// Source of true data
const actions = {
  d: 'delete',
  w: 'write/edit',
  c: 'create',
  r: 'read',
@r01010010
r01010010 / rxjsFromStreamsource.js
Last active March 20, 2020 00:01
Create RxJS Observable from getUserMedia, createMediaStreamSource and analyserNode (Only Chrome)
import { Observable, of } from 'rxjs'
import { skipWhile } from 'rxjs/operators
// ...
navigator.getUserMedia({
"audio": true
}, (stream) => {
const buf = new Float32Array(1024)
const mediaStreamSource = window.audioContext.createMediaStreamSource(stream)
const analyser = window.audioContext.createAnalyser()
// SOLUTION 1 (good performance)
function flat1(source) {
var s = "[" + JSON.stringify(source).replace(/\[|]/g,'') +"]";
var flattened = JSON.parse(s);
}
console.log(flat1([[1,2,[3]],4, [[1,2,[3]],4], [[1,2,[3]],4], [[1,2,[3]],4]]);
// SOLUTION 2 (for small arrays)
function flat2(source, pos, prevs, final) {
/**
* This module defines the tests for the faqEditor controller.
*/
// Test dependencies
var mockery = require('mockery');
var buster = require('buster');
var assert = buster.referee.assert;
var expect = buster.referee.expect;
var sinon = require('sinon');
@r01010010
r01010010 / post.jade
Last active August 29, 2015 14:12
angular.js
html
head
meta(name="viewport" content="width=device-width, initial-scale=1")
//
HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries
//if lt IE 9
script(src='https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js')
script(src='https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js')
link(href='/public/css/bootstrap.css', rel='stylesheet')
link(href='/public/css/app.css', rel='stylesheet')
@r01010010
r01010010 / preserve_this_in_prototype.js
Last active August 29, 2015 14:12
Preserve 'this' in prototype function
var EValidator = require('evalidator');
var mainObject = {
propertyObject: new PropertyObject(),
ev: new SuperEValidator()
};
/**
* EValidator extension object
* @constructor
@r01010010
r01010010 / require_scopes.js
Last active August 29, 2015 14:12
Require scopes
/** WHY IS THIS IN NODE.JS ? **/
// file1.js
var _ = require('underscore');
require('./routes/document'); // _ will be NOT VISIBLE in document
// file2.js
_ = require('underscore');
require('./routes/document'); // _ will be VISIBLE in document
@r01010010
r01010010 / why.js
Last active August 29, 2015 14:12
Calling a defined in file var from a callback... undefined!
require('another_file.js');
var whatever = 8;
function foo(){
// calling a function from another file
foo_with_callback(function(returned_value){
console.log(whatever) // whatever is undefined <--- WHY ???
});