Skip to content

Instantly share code, notes, and snippets.

View robotlolita's full-sized avatar
🐴
everything happens so much oh no

Quil robotlolita

🐴
everything happens so much oh no
View GitHub Profile
const Validation = require('folktale/validation');
const { Success, Failure } = Validation;
// valida se uma string não é vazia
const hasText = (value, name) =>
if (value != "") Success(value)
else Failure([{ code: 'required', name }]);
// valida se uma selecao não é vazia
const hasSelection = (value, name) =>

Unclutter calendar:

javascript:void (() => { Array.from(document.querySelectorAll('.calendar .item')).filter(x => !/\b(green|yellow)\b/.test(x.className)).forEach(x => x.parentNode.removeChild(x)); Array.from(document.querySelectorAll('.browse__content .section')).filter(x => { const a = x.querySelector('h2'); return x.textContent.trim() === a.textContent.trim() }).forEach(x => x.parentNode.removeChild(x)) })()
var fs = require("fs");
var helpers = require("./helpers");
var path = require("path");
function readFile(path, options) {
return new Promise(function(resolve, reject) {
fs.readFile(path, options, function(err, data) {
if (err) reject(err);
else resolve(data);
})
'use strict';
var promise = {
state: 'pending',
value: null,
dependencies: [],
then: function(expression) {
var async = require('async');
async.eachSeries(array, function(item, callback){
callAsyncFunction(item, function(error, data) {
if (error) {
return callback(error);
} else {
async.eachSeries(arrayTwo, function(sItem, sCallback) {
count++;
callAnotherAsyncFunction(item + sItem, function(error, data) {
@robotlolita
robotlolita / 0_reuse_code.js
Created November 4, 2015 23:28
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
// Logic MUST BE identical to the synchronous way:
// https://gist.github.com/melissamarima/2b9e8594892103dbc02c
var mongoose = require('mongoose');
var collectionASchema = new mongoose.Schema({field1: Number, field2: Number});
var collectionBSchema = new mongoose.Schema({field1: Number, field2: Number});
collectionASchema.index({field1: 1});
collectionBSchema.index({field1: -1});
mongoose.model('collectionA', collectionASchema);
mongoose.model('collectionB', collectionBSchema);
@robotlolita
robotlolita / map.st
Last active August 28, 2015 20:24 — forked from joepie91/map.js
Bluebird map + bhttp
(* Assume bhttp-get is available here somehow *)
let HTTP = {
def get: url
(* This would actually need to be imported properly. Yeah, FFI sucks, but oh well... *)
Task from-promise: (FFI invoke: bhttp-get in-context: unit with-arguments: [FFI export: url])
}
do {
response <- HTTP get: "http://somesite.com/all-the-urls.txt";
@robotlolita
robotlolita / a.js
Last active August 29, 2015 14:24 — forked from notblizzard/a.js
exports.commands = {
mb: 'musicbox',
musicbox: function (target, room, user) {
if (!this.canBroadcast()) return;
var parts = target.split(',');
if (!target) return this.sendReply("/musicbox link, link, link - parses it to be in a music box");
var parsedParts = parts.map(parse);
Promise.all(parsedParts).then(function(parts) {
var str = parts.join('');
this.sendReply('str is ' + str);
function pipeline(fs, val, done) {
if (fs.length === 0) done(null, val)
else fs[0](val, function(err, val) {
if (err) done(err)
else pipeline(fs.slice(1), val, done)
})
}
pipeline([
asyncFunctionOne,