Skip to content

Instantly share code, notes, and snippets.

View gillesdemey's full-sized avatar
♥️
Be kind to others

Gilles De Mey gillesdemey

♥️
Be kind to others
View GitHub Profile
package main
import (
"fmt"
"time"
)
func pinger(channel chan<- string) {
for {
channel <- "ping"
const fs = require('fs')
const pify = require('pify')
const readFile = pify(fs.readFile)
async function main () {
const results = [
await readFile('foo.txt'),
await readFile('bar.txt')
].join('\n')
@gillesdemey
gillesdemey / index.js
Last active February 7, 2021 02:21
express-jwt-permissions with express-unless
const express = require('express')
const jwt = require('express-jwt')
const permissions = require('express-jwt-permissions')()
const unless = require('express-unless')
const app = express()
const checkAuth = jwt({ secret: process.env.JWTSECRET })
const checkAdmin = permissions.check(['admin'])
checkAdmin.unless = unless
var foo = require('foo')
foo.bar(foo => { baz: 'qux' })
// get tokens for provider from user (profile)
function getTokens (provider, profile) {
var tenant = options.globalSettings.HOARD_TENANT
var secret = options.globalSettings.HOARD_SECRET
var jwt_token = jwt.sign({ sub: profile, iss: tenant }, secret)
return request(`https://auth.waylay.io/tokens/${provider}`, {
headers: { 'authorization': jwt_token }
})

Keybase proof

I hereby claim:

  • I am gillesdemey on github.
  • I am gillesdemey (https://keybase.io/gillesdemey) on keybase.
  • I have a public key whose fingerprint is E6AA 852C 3B21 6897 7093 236B 632B 56C8 98C2 5A23

To claim this, I am signing this object:

@gillesdemey
gillesdemey / server.go
Created June 12, 2016 17:25
HTTP to Kafka bridge
package main
import (
"fmt"
"log"
"net/http"
"github.com/Shopify/sarama"
"goji.io"
"goji.io/pat"
@gillesdemey
gillesdemey / index.js
Last active May 10, 2016 00:54
Pino RingBuffer
var pino = require('./')
var RingBuffer = require('./ringbuffer')
var rb = new RingBuffer({ limit: 10 })
var log = pino(rb)
setInterval(() => {
log.info(new Date())
}, 5)
var _ = require('lodash');
var exec = require('child_process').exec;
/**
* Get a list of NFS mounted drives
*/
function getMountedDrives(types, callback) {
function parseOut(err, stdout, stderr) {
@gillesdemey
gillesdemey / querystring.swift
Last active March 24, 2021 10:53
Retrieve specific query string parameter from NSURL
func getQueryStringParameter(url: String, param: String) -> String? {
let url = NSURLComponents(string: url)!
return
(url.queryItems? as [NSURLQueryItem])
.filter({ (item) in item.name == param }).first?
.value()
}