Skip to content

Instantly share code, notes, and snippets.

View flovilmart's full-sized avatar
📈

Florent Vilmart flovilmart

📈
View GitHub Profile
@flovilmart
flovilmart / frmwrk.js
Created September 8, 2020 01:17
frmwrk.js
// Makes a sync middleware
const make = (name) => {
return (ctx, next) => {
ctx.calls = ctx.calls || 0
ctx.calls += 1;
console.log(`Doing ${name} PRE`);
return next(ctx);
}
}
@flovilmart
flovilmart / index.ts
Created July 13, 2019 15:20
TS: Optionals
class Optional<T> {
private val: T;
private is_none: boolean;
private constructor(value: T, is_none: boolean = false) {
this.val = value;
this.is_none = is_none;
}
static none<U>(): Optional<U> {
{% for type in types.implementing.Buildable %}
extension {{ type.name }} {
class Builder {
{% for member in type.variables %}
private var {{ member.name }}: {{member.typeName}}?
{% endfor %}
{% for member in type.variables %}
func set({{ member.name }}: {{member.typeName}}) -> Builder {
self.{{ member.name }} = {{ member.name }}
$ curl http://localhost:8080/app1
# logs
# main middleware
# app1 middleware
$ curl http://localhost:8080/app2
# logs
# main middleware
# app2 middleware
@flovilmart
flovilmart / Crash
Created April 10, 2017 14:17
iOS 10 only crash
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000009e040bec8
Crashed: main
0 libobjc.A.dylib 0x18b8e97f4 objc_object::release() + 8
1 CoreFoundation 0x18ce5a9a4 common_removeAllObjects + 156
2 CoreFoundation 0x18cd4e9e0 -[__NSArrayM dealloc] + 28
3 libobjc.A.dylib 0x18b8ea134 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 836
4 CoreFoundation 0x18cd46b18 _CFAutoreleasePoolPop + 28
5 CoreFoundation 0x18ce16ce4 __CFRunLoopRun + 1580
6 CoreFoundation 0x18cd46d94 CFRunLoopRunSpecific + 424
@flovilmart
flovilmart / How to use:
Created March 26, 2017 21:24
GraphQL Parse Schema
mutation {
NewClass {
create(foo: "hello", bar: false, increment: 1) {
objectId, foo, bar, increment
}
}
}
mutation {
create(className: "NewClass", params: {foo: "Bar", bar: true, increment: 10}) {
[ec2-user@ip-172-31-14-143 ~]$ cat npm-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/opt/elasticbeanstalk/node-install/node-v4.3.0-linux-x64/bin/node',
1 verbose cli '/opt/elasticbeanstalk/node-install/node-v4.3.0-linux-x64/bin/npm',
1 verbose cli 'install',
1 verbose cli 'sse4_crc32' ]
2 info using [email protected]
3 info using [email protected]
4 verbose config Skipping project config: /home/ec2-user/.npmrc. (matches userconfig)
5 verbose install initial load of /home/ec2-user/package.json
8454 info install [email protected]
8455 verbose unsafe-perm in lifecycle false
8456 info [email protected] Failed to exec install script
8457 verbose stack Error: [email protected] install: `node-gyp rebuild`
8457 verbose stack Exit status 1
8457 verbose stack at EventEmitter.<anonymous> (/opt/elasticbeanstalk/node-install/node-v4.3.0-linux-x64/lib/node_modules/npm/lib/utils/lifecycle.js:214:16)
8457 verbose stack at emitTwo (events.js:87:13)
8457 verbose stack at EventEmitter.emit (events.js:172:7)
8457 verbose stack at ChildProcess.<anonymous> (/opt/elasticbeanstalk/node-install/node-v4.3.0-linux-x64/lib/node_modules/npm/lib/utils/spawn.js:24:14)
8457 verbose stack at emitTwo (events.js:87:13)
@flovilmart
flovilmart / _PushStatus
Created February 25, 2016 17:34
_PushStatus specification
// PushStatus contains information about a push that was sent by an app. Its
// BSON format is stored directly in Mongo. Its JSON format is the REST format
// exposed to external developers, e.g. "_id" is mapped to "objectId",
// "_created_at" is mapped to "createdAt", etc.
type PushStatus struct {
// ObjectID is a string matching the standard Parse object id format.
ObjectID string `bson:"_id" json:"objectId"`
// CreatedAt contains the current modification time for this object.
CreatedAt TimeString `bson:"_created_at" json:"createdAt"`
@flovilmart
flovilmart / Example.swift
Created February 17, 2016 12:46
Authenticate with custom OAuth example
import Parse
import Bolts
class AuthDelegate:NSObject, PFUserAuthenticationDelegate {
func restoreAuthenticationWithAuthData(authData: [String : String]?) -> Bool {
return true
}
}
let configuration = ParseClientConfiguration { (configuration) -> Void in