Skip to content

Instantly share code, notes, and snippets.

View pito-svk's full-sized avatar
💜
Working from home

Peter Parada pito-svk

💜
Working from home
View GitHub Profile
@lattner
lattner / async_swift_proposal.md
Last active April 21, 2024 09:43 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift

Async/Await for Swift

Introduction

Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.

This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.

@sebmarkbage
sebmarkbage / Enhance.js
Last active January 31, 2024 18:33
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@reu
reu / pub-sub.js
Created April 9, 2013 01:51
node.js redis pub-sub example
var redis = require("redis")
, subscriber = redis.createClient()
, publisher = redis.createClient();
subscriber.on("message", function(channel, message) {
console.log("Message '" + message + "' on channel '" + channel + "' arrived!")
});
subscriber.subscribe("test");
@BoyCook
BoyCook / ServerITSpec.js
Last active May 14, 2019 18:28
Integration testing a node.js web app with Mocha
var should = require('should');
var request = require('request');
var url = 'http://localhost:8080';
var HttpServer = require('./server').HttpServer;
var server;
describe('HttpServer', function () {
before(function (done) {
server = new HttpServer({port: 8080}).start(done);
@abesto
abesto / curry.bash
Last active February 28, 2024 18:32
Partial application in Bash
function curry() {
exportfun=$1; shift
fun=$1; shift
params=$*
cmd=$"function $exportfun() {
more_params=\$*;
$fun $params \$more_params;
}"
eval $cmd
}