Skip to content

Instantly share code, notes, and snippets.

View gilbert's full-sized avatar
🪐
Security in space

Gilbert gilbert

🪐
Security in space
View GitHub Profile
@msteen
msteen / print-lezer-tree.ts
Last active May 1, 2024 21:05
Print Lezer Trees
// MIT License
//
// Copyright (c) 2021 Matthijs Steen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@barneycarroll
barneycarroll / .js
Last active August 2, 2019 21:10
Functor Mithril!
import m from './functor-mithril'
function Async(){
let cache
return ({content, setup, teardown}, dom) => {
if(content && !cache && teardown)
dom(node => {
void node.clientHeight
@db0sch
db0sch / regenerate_credentials.md
Last active October 31, 2023 20:30
How to regenerate the master key for Rails 5.2 credentials

If your master.key has been compromised, you might want to regenerate it.

No key regeneration feature at the moment. We have to do it manually.

  1. Copy content of original credentials rails credentials:show somewhere temporarily.
  2. Remove config/master.key and config/credentials.yml.enc
  3. Run EDITOR=vim rails credentials:edit in the terminal: This command will create a new master.key and credentials.yml.enc if they do not exist.
  4. Paste the original credentials you copied (step 1) in the new credentials file (and save + quit vim)
  5. Add and Commit the file config/credentials.yml.enc
@leighman
leighman / Main.purs
Last active April 9, 2023 18:21 — forked from oxbowlakes/3nightclubs.scala
A Tale of 3 Nightclubs
module Main where
import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, logShow)
import Data.Either (Either(..))
import Data.Foldable (elem, notElem)
import Data.Int (toNumber)
import Data.Traversable (traverse)
import Data.Validation.Semigroup (invalid)
@flintinatux
flintinatux / component.js
Created July 23, 2016 18:12
Component wrapper for mithril 1.x. Registers lifecycle methods as streams, so that components may be contructed as single-closure factories that return view functions.
const m = require('mithril')
const stated = hook => vnode => vnode.state[hook](vnode)
const oninit = Comp => vnode => {
vnode.state.oncreate = m.prop()
vnode.state.onremove = m.prop()
vnode.state.view = Comp(vnode)
}
@getify
getify / 1.js
Last active June 17, 2016 16:37
Exploring how a gen-runner works... using a recursive promise chain
// commented `run(..)`:
function run(it) {
// return a promise for the generator completing
return Promise.resolve()
.then( function handleNext(value){
// run to the next yielded value
var next = it.next( value );
return (function handleResult(next){
@JAForbes
JAForbes / readme.md
Last active January 13, 2021 00:06
Data Driven Entity Component System

Entities and Components

An entity is just a number.

There is a graph of components, indexed by the entity id.

All state is stored in one place.

var components = { Position: {}, Velocity:{}, Spite: {}, Timer: {}, ScreenShake: {}, RemoveComponents: {} }
@plurch
plurch / upsert.js
Created March 2, 2016 05:29
PostgreSQL 9.5 Upsert using Knex.js
exports.knex = require('knex')({
client: 'pg',
connection: {
host : '127.0.0.1',
user : 'your_database_user',
password : 'your_database_password',
database : 'myapp_test'
}
});
@abeyer
abeyer / SlackMessage.class
Created February 25, 2016 22:50
Post to slack webhooks from salesforce process builder
public with sharing class SlackMessage {
public class Params {
@InvocableVariable(label='Message' required=true)
public String msg;
}
@InvocableMethod(
label='Send a message to Slack'
description='Send the Message argument as text to a Slack webhook endpoint.'
@oxyflour
oxyflour / hindley-milner.ts
Last active May 3, 2024 01:32
a typescript implement of hindley-milner type inference
// a typescript implement of hindley-milner type inference
// reference http://smallshire.org.uk/sufficientlysmall/2010/04/11/a-hindley-milner-type-inference-implementation-in-python/
/// <reference path="./lib.es6.d.ts" />
// ...
interface AstNode {
}
class Id implements AstNode {