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";
/*
[DESAFIO / LANGUAGE WAR] Implemente um programa na sua linguagem favorita onde o usuário digita um número x, e o programa calcula o somatório dos x primeiros números pares da sequência fibonacci, e imprime a soma dos algarismos desse número.
Por exemplo, quando x = 5, a resposta é 17, pois:
1. A sequência fibonacci é 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,...
2. Os 5 primeiros números pares são 0, 2, 8 e 34, 144.
3. O somatório disso é 188.
4. Somando os algarismos, 1+8+8 = 17
var models = [{
name: 'Jonathan',
location: 'Earth'
}, {
name: 'Joe',
location: 'Mars'
}]
var ps = models.map(function(model) {
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,
@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);
var sDate = new Date()
, today = new Date()
, str = ""
, node;
sDate.setFullYear(2011, 0, 1);
if (sDate > today) {
str = sDate.getFullYear() }
else {
var http = require('http');
var fs = require('fs');
var url = require('url');
var settingsPath='settings2.json';
var Server = function(path){
this.readSettings(path);
}
// put inside a .js file, referenced on the page by the resource's URI
// Create a local variable to hold `jQuery', so you type less.
// Using $ is stupíd, since that symbol is (by ES5 specs) reserved for
// machine-generated code.
void function(j) {
function get_data() {
// use functions to abstract code sections
function get_item(i) { return data[i].high + '<br>' + ~~(Math.random() * 111) }
function update(idx) { return j('#high').html(get_item(idx)) }
function process(data){ return j.each(data, update) }
@robotlolita
robotlolita / gist:1126695
Created August 5, 2011 00:53 — forked from jido/gist:1126681
How JS scoping messes with capture
var a = {};
a.foo = function() {
return "foo";
}
a.bar = function() {
return "bar";
}
@robotlolita
robotlolita / about.md
Created August 10, 2011 16:50 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer