Skip to content

Instantly share code, notes, and snippets.

View jdx's full-sized avatar
quite busy for the next month or two, will be back at mise again though!

jdx

quite busy for the next month or two, will be back at mise again though!
View GitHub Profile
@jdx
jdx / min_max_heap.py
Last active February 16, 2020 17:25
max heap in python
from collections import namedtuple
from typing import TypeVar, Generic, Optional, List, Union, Tuple, Callable, Any
T = TypeVar("T")
class Heap(Generic[T]):
x: List[T]
def __init__(self, key: Callable[[T], Any] = lambda x: x, order="min"):
apt-get update
apt-get install -y wget
wget https://cli-assets.heroku.com/branches/stable/heroku-linux-amd64.tar.gz
mkdir -p /usr/local/lib /usr/local/bin
tar -xvzf heroku-linux-amd64.tar.gz -C /usr/local/lib
ln -s /usr/local/lib/heroku/bin/heroku /usr/local/bin/heroku
heroku version
@jdx
jdx / nd.go
Last active September 28, 2018 06:26
nd pseudocode
package lib
import "path/filepath"
type Project struct {
Root string
YarnLock interface{}
PackageLock interface{}
Dependencies []*Dependency
@jdx
jdx / get-all-github-status-checks.ts
Last active July 13, 2019 15:38
a set of scripts to migrate github status checks from legacy travis to github app (run with ts-node)
// run this second
import GitHub from '@octokit/rest'
import * as _ from 'lodash'
import * as fs from 'fs-extra'
import pMap from 'p-map'
import repos from '../repos.json'
let statuses: {[repo: string]: string[]}
@jdx
jdx / client.go
Last active November 11, 2022 10:51
basic IPC example connecting node and golang together with unix socket (named pipe)
package main
import (
"io"
"log"
"net"
"time"
)
func reader(r io.Reader) {
@jdx
jdx / add-user.js
Created August 22, 2018 16:29
add npm users to org members
#!/usr/bin/env node
const Client = require('npm-registry-client')
const reg = new Client()
const uri = 'https://registry.npmjs.org/npm'
const csv = require('csv')
const fs = require('fs')
const PARAMS = {auth: {token: process.env.NPM_PASS}, org: 'heroku'}
csv.parse(fs.readFileSync('users.csv'), (err, csv) => {
[
{
"id": "debug",
"description": "Outputs debugging info\n",
"pluginName": "heroku-debug",
"pluginType": "user",
"hidden": false,
"aliases": [],
"flags": {},
"args": []
yarn run v1.5.1
$ make
Producer
✓ required methods
✓ should create producer with default options
declare namespace NodeJS {
interface Global {
'my-object': {
errlog?: string
debug?: boolean
context?: any
}
}
}