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
@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";
// 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 / 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
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) {
'use strict';
var promise = {
state: 'pending',
value: null,
dependencies: [],
then: function(expression) {
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);
})
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) =>