Skip to content

Instantly share code, notes, and snippets.

@badsyntax
badsyntax / example.js
Created March 28, 2014 11:34
Atom editor view (space-pen) without using CoffeeScript. NodeJs util.inherits is not compatible with CofeeScripts __extends. This is most frustrating. For now, we have to use the CS version.
var View = require('atom').View;
/** CofeeScript's version of inheritance */
var __hasProp = {}.hasOwnProperty;
var __extends = function(child, parent) {
for (var key in parent) {
if (__hasProp.call(parent, key)) child[key] = parent[key];
}
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
@lukemorton
lukemorton / syncInterval.js
Created December 8, 2011 10:55
Syncronous (safe) setInterval()
// Syncronous setInterval
// Usage:
// var interval = new SyncInterval(function () {
// console.log('bob');
// }, 500);
// interval.stop();
// Written by Luke Morton, Richard Willis
function SyncInterval(fn, wait, scope) {
var t = this;
wait = wait || 1000;
@senko
senko / create-new-lxc.sh
Created March 1, 2013 13:00
Set up a new LXC virtual machine
#!/bin/bash
#
# Initialize new virtual server using LXC and set up networking and HTTP proxy
#
# Written by: Deni Bertovic <deni.bertovic@dobarkod.hr>
#
# Released into Public Domain. You may use, modify and distribute it as you
# see fit.
#
# This script will:
@badsyntax
badsyntax / .bashrc
Last active July 14, 2016 03:50
My new bash PS1 prompt (on osx)
alias ls='ls -G'
source /usr/share/git-core/git-prompt.sh
source /usr/share/git-core/git-completion.bash
GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWCOLORHINTS=true
GIT_PS1_SHOWUNTRACKEDFILES=true
PS1="\n\[\e[01;34m\]┌─(\[\e[01;35m\]\u@${HOSTNAME%%.*}\[\e[01;34m\])"'$(__git_ps1 "──(\[\e[01;31m\]%s\[\e[01;34m\])")'"\[\e[01;34m\]\n\[\e[01;34m\]└─(\[\e[01;32m\]\w\[\e[01;34m\])──(\[\e[01;32m\]$ \[\e[01;37m\]"
@ahasbini
ahasbini / Logger.java
Created October 12, 2019 13:37
Logger wrapper to show Gradle plugin logs in quite mode for effortless development and debugging
import org.gradle.api.logging.LogLevel;
import org.gradle.api.logging.Logging;
import org.slf4j.Marker;
/**
* Created by ahasbini on 11-Oct-19.
*/
public class Logger implements org.gradle.api.logging.Logger {
private static boolean useQuietLogs = false;
@julienma
julienma / README.md
Last active November 10, 2021 13:04
How to install Discourse 2.4+ on Dokku (2019)
.closed.octicon.octicon-issue-closed {
color: var(--color-danger-fg) !important;
}
.gh-header-meta .State--merged, .State--merged[title="Status: Closed"] {
background-color: var(--color-danger-fg) !important;
}
.TimelineItem-badge.color-bg-done-emphasis {
background-color: var(--color-danger-fg) !important;

Cheat sheet: public prototype methods and accessors

const getterKey = Symbol('getterKey');
const setterKey = Symbol('setterKey');
const syncMethodKey = Symbol('syncMethodKey');
const syncGenMethodKey = Symbol('syncGenMethodKey');
const asyncMethodKey = Symbol('asyncMethodKey');
const asyncGenMethodKey = Symbol('asyncGenMethodKey');
@badsyntax
badsyntax / s3Etag.ts
Last active December 19, 2021 07:10
Generate an S3 ETAG for multipart uploads in Node.js
/**
* Generate an S3 ETAG for multipart uploads in Node.js
* An implementation of this algorithm: https://stackoverflow.com/a/19896823/492325
* Author: Richard Willis <willis.rh@gmail.com>
*/
import fs from 'node:fs';
import crypto, { BinaryLike } from 'node:crypto';
const defaultPartSizeInBytes = 5 * 1024 * 1024; // 5MB