Skip to content

Instantly share code, notes, and snippets.

@heartAndRain
heartAndRain / CancelableAsyncTask.ts
Created October 23, 2018 07:44
CancelableAsyncTask
export default class CancelableAsyncTask {
private do: (...args: any[]) => Promise<any>;
private running: boolean;
private args: any[];
constructor(doPromise: (...args: any[]) => Promise<any>, ...args: any[]) {
this.do = doPromise;
this.running = false;
this.args = args;
}
private afterTimeDo(
@jperkin
jperkin / README.md
Created April 11, 2016 09:45
pkgsrc rsync

Issue

pkgsrc binary package repositories must be consistent. They contain a file pkg_summary which contains metadata about all packages currently in the repository. This file is then used by binary package managers such as pkgin to offer easy downloading and installing of packages to users.

Unlike many other package managers, pkgsrc will rebuild all dependents of a package if it is rebuilt. This is to ensure consistency and avoid nasty surprises at runtime, and many times this has exposed issues that other package managers would not detect until much later. The drawback is that an update to a package such as OpenSSL means that many thousands of packages are rebuilt against the newer OpenSSL package, even though the packages themselves haven't changed at all.

When packages are rebuilt, the package file itself and the details in pkg_summary must match, otherwise binary package managers will fail when trying to install packages, either because the package has been changed but the pkg_summary in

@renchap
renchap / README.md
Last active October 12, 2022 17:14
One-line certificate generation/renews with Letsencrypt and nginx

Prerequisites : the letsencrypt CLI tool

This method allows your to generate and renew your Lets Encrypt certificates with 1 command. This is easily automatable to renew each 60 days, as advised.

You need nginx to answer on port 80 on all the domains you want a certificate for. Then you need to serve the challenge used by letsencrypt on /.well-known/acme-challenge. Then we invoke the letsencrypt command, telling the tool to write the challenge files in the directory we used as a root in the nginx configuration.

I redirect all HTTP requests on HTTPS, so my nginx config looks like :

server {
@alexkirsz
alexkirsz / ForceCaseSensitivityPlugin.js
Last active February 23, 2017 13:38
Force case sensitivity in webpack
/*
The MIT License (MIT)
Copyright (c) 2015 Alexandre Kirszenberg
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTI
@addyosmani
addyosmani / notes.md
Last active August 10, 2022 03:59
Notes on streaming JS & long-term code compilation caching in Chrome

Re: http://blog.chromium.org/2015/03/new-javascript-techniques-for-rapid.html

V8 Optimisations to enable fast page startup

As mentioned in our Chromium blog post, Chrome 41 introduces support for streaming parsing of JavaScript files using the async or defer attributes. This is where the V8 parser will parse any incoming JavaScript piece-by-piece so the compiler can immediately begin compiling the AST when script loading has completed. This lets us do something useful while waiting for the page to load. Compare:

This means parsing can be removed from the critical path when loading up the page. In these cases such scripts are parsed on a separate thread as soon as the download begins, allowing parsing to complete very soon after the download has completed (milliseconds), leading to pages (potentially) loading much faster.

@robdmoore
robdmoore / setup-cordova-phonegap.ps1
Last active September 13, 2023 16:04
Scripted/Automated installation script to set up Cordova/PhoneGap and Android on Windows
# Run this in an elevated PowerShell prompt
<# This script worked on a fresh Windows Server 2012 VM in Azure and the following were the latest versions of each package at the time:
* Chocolatey 0.9.8.27
* java.jdk 7.0.60.1
* apache.ant 1.8.4
* android-sdk 22.6.2
* cordova 3.5.0-0.2.6
* nodejs.install 0.10.29
#>
# Note: there is one bit that requires user input (accepting the Android SDK license terms)
@staltz
staltz / introrx.md
Last active July 22, 2024 09:31
The introduction to Reactive Programming you've been missing
@jdx
jdx / boot.js
Last active March 16, 2023 18:08
zero-downtime node.js app runner
// This script will boot app.js with the number of workers
// specified in WORKER_COUNT.
//
// The master will respond to SIGHUP, which will trigger
// restarting all the workers and reloading the app.
var cluster = require('cluster');
var workerCount = process.env.WORKER_COUNT || 2;
// Defines what each worker needs to run
@palpha
palpha / on-parentheses-in-fsharp.md
Last active August 20, 2021 05:53
On parentheses in F#

There's a blog post currently making the rounds, about a developer's experience of using F# for anything serious for the first time: http://www.knowing.net/index.php/2014/02/13/notes-on-my-first-real-f-program/

Among other things, it touches the subject of parentheses. This is a subject that seems to be widely misunderstood, and the blog post exhibits one such misunderstanding by calling parentheses in F# optional.

I will try to bring some sanity to the table, but am fully aware that I don't know a fraction of what I would need to know in order to call myself an expert in F#. Comments and corrections are very welcome (bergius on Twitter).

Parentheses in F#

TL;DR: It's all about precedence and associativity. It has nothing to do with differences between methods and functions. It is not the parentheses that are optional, but the spaces between parentheses and other things.

@eyecatchup
eyecatchup / ascii-binary-converter.js
Last active November 6, 2023 20:03
JavaScript native ASCII to Binary / Binary to ASCII convert functions.
// ABC - a generic, native JS (A)scii(B)inary(C)onverter.
// (c) 2013 Stephan Schmitz <eyecatchup@gmail.com>
// License: MIT, http://eyecatchup.mit-license.org
// URL: https://gist.github.com/eyecatchup/6742657
var ABC = {
toAscii: function(bin) {
return bin.replace(/\s*[01]{8}\s*/g, function(bin) {
return String.fromCharCode(parseInt(bin, 2))
})
},