Skip to content

Instantly share code, notes, and snippets.

var p = new Promise( function(resolve,reject){
resolve(374);
});
p.then(function fulfilled(message){
foo.bar();
console.log(message); // never reached
},
function rejected(err){
// never reached
@paralysedforce
paralysedforce / .vimrc
Created August 8, 2017 02:05
My vimrc
"Vundle Setup
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'christoomey/vim-tmux-navigator'
call vundle#end()
filetype plugin indent on
set autoread
"""""""""""""""""""""
anonymous
anonymous / REAPER_Commandline_Notes.md
Created June 21, 2017 18:20
REAPER Commandline Reference Notes

REAPER Commandline Reference Notes

Since there is not much documentation on this yet, here are some notes:

batchconvert

OS/X HINT: use absolute filenames for input, otherwise the project file will be found but not the referenced files

Fileformat:

In a recent discussion I had with a friend about Haskell and Scala, they brought up the fact that they sometimes miss Scala's partial functions. In Scala, these are a trait of their own somewhat different from what Haskellers usually understand by "partial function". In particular, you can check if a value is in the domain of the partial function before applying it to the function.

Interestingly enough, partial functions are also supported in Haskell - they just happen to be hidden away in some more obscure parts of the base library. What follows is my attempt to make a module that brings this functionality out and makes it more accessible. Since this is meant to be a literate Haskell source, let's start with some preamble.

{-# LANGUAGE TypeOperators, NoImplicitPrelude, GeneralizedNewtypeDeriving #-}

module Data.Function.Partial where

import Prelude hiding (id, (.), ($))
@shitpoet
shitpoet / haml.lua
Created April 7, 2017 19:34
basic HAML lexer for TextAdept
-- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE.
-- HAML LPeg lexer.
local l = require('lexer')
local token, word_match = l.token, l.word_match
local P, R, S, V = lpeg.P, lpeg.R, lpeg.S, lpeg.V
local M = {_NAME = 'haml'}
-- Whitespace.
# DATA PROVIDED TO US. STRUCTURE CANNOT BE MODIFIED! WELCOME TO THE REAL WORLD PRINCESS
sizes = [
{
"name": "item_1",
"size_in_mL": "100mL",
"alternate_identifier": "axc45"
},
{
"name": "item_2",
@simonw
simonw / recover_source_code.md
Last active September 28, 2024 08:10
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
const insert = (fn = (a, b) => a < b, item, list = []) => {
if (!list.length) {
return [item];
}
if (list.length === 1) {
return fn(item, list[0]) ? [item, list[0]] : [list[0], item];
}
let min = 0;
let max = list.length - 1;
while (true) {
@jherax
jherax / is-private-mode.js
Last active February 14, 2025 11:03
Detect if the browser is running in Private mode - Promise based (last update: Feb 2020)
/**
* Lightweight script to detect whether the browser is running in Private mode.
* @returns {Promise<boolean>}
*
* Live demo:
* @see https://output.jsbin.com/tazuwif
*
* This snippet uses Promises. If you want to run it in old browsers, polyfill it:
* @see https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.min.js
*
@math2001
math2001 / minimap_setting.py
Last active August 14, 2021 17:34
A plugin to hide the minimap using a setting on sublime text.
# -*- encoding: utf-8 -*-
import sublime
import sublime_plugin
class MinimapSetting(sublime_plugin.EventListener):
def on_activated(self, view):
show_minimap = view.settings().get('show_minimap')
if show_minimap: