Skip to content

Instantly share code, notes, and snippets.

View JoshuaKGoldberg's full-sized avatar
🌴
Mostly on vacation through 5/20. Expect little.

Josh Goldberg ✨ JoshuaKGoldberg

🌴
Mostly on vacation through 5/20. Expect little.
View GitHub Profile
@banksean
banksean / mersenne-twister.js
Created February 10, 2010 16:24
a Mersenne Twister implementation in javascript. Makes up for Math.random() not letting you specify a seed value.
/*
I've wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace
so it's better encapsulated. Now you can have multiple random number generators
and they won't stomp all over eachother's state.
If you want to use this as a substitute for Math.random(), use the random()
method like so:
var m = new MersenneTwister();
@anandsunderraman
anandsunderraman / setChromeOptions.js
Last active May 10, 2024 15:17
Selenium Web Driver Set Chrome Options
//import the selenium web driver
var webdriver = require('selenium-webdriver');
var chromeCapabilities = webdriver.Capabilities.chrome();
//setting chrome options to start the browser fully maximized
var chromeOptions = {
'args': ['--test-type', '--start-maximized']
};
chromeCapabilities.set('chromeOptions', chromeOptions);
var driver = new webdriver.Builder().withCapabilities(chromeCapabilities).build();
@remojansen
remojansen / class_decorator.ts
Last active September 14, 2023 14:54
TypeScript Decorators Examples
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}
@azizur
azizur / Creating a static copy of a dynamic website.md
Last active April 27, 2024 06:08
Creating a static copy of a dynamic website

The command line, in short…

wget -k -K -E -r -l 10 -p -N -F --restrict-file-names=windows -nH http://website.com/

…and the options explained

  • -k : convert links to relative
  • -K : keep an original versions of files without the conversions made by wget
  • -E : rename html files to .html (if they don’t already have an htm(l) extension)
  • -r : recursive… of course we want to make a recursive copy
  • -l 10 : the maximum level of recursion. if you have a really big website you may need to put a higher number, but 10 levels should be enough.
@domenic
domenic / redirecting-github-pages.md
Created February 10, 2017 19:28
Redirecting GitHub pages after a repository move

Redirecting GitHub Pages after a repository move

The problem

You have a repository, call it alice/repo. You would like to transfer it to the user bob, so it will become bob/repo.

However, you make heavy use of the GitHub Pages feature, so that people are often accessing https://alice.github.io/repo/. GitHub will helpfully redirect all of your repository stuff hosted on github.com after the move, but will not redirect the GitHub Pages hosted on github.io.

The solution

@joyrexus
joyrexus / README.md
Last active February 24, 2024 15:16
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@DustinCampbell
DustinCampbell / using-msbuildworkspace.md
Created April 10, 2018 21:36
Using MSBuildWorkspace

Introduction

Roslyn provides a rich set of APIs for analyzing C# and Visual Basic source code, but constructing a context in which to perform analysis can be challenging. For simple tasks, creating a Compilation populated with SyntaxTrees, MetadataReferences and a handful of options may suffice. However, if there are multiple projects involved in the analysis, it is more complicated because multiple Compilations need to be created with references between them.

To simplify the construction process. Roslyn provides the Workspace API, which can be used to model solutions, projects and documents. The Workspace API performs all of the heavy lifting needed to parse SyntaxTrees from source code, load MetadataReferences, and construct Compilations and add references between them.

@JoshuaKGoldberg
JoshuaKGoldberg / LogicMathLol.ts
Last active May 3, 2023 18:25
Silly Binary Arithmetic in TypeScript's Type System
type Bit = 0 | 1;
type BitOr<A extends Bit, B extends Bit> =
[A, B] extends [0, 0] ? 0 :
[A, B] extends [0, 1] | [1, 0] | [1, 1] ? 1 :
Bit
;
type BitAnd<A extends Bit, B extends Bit> =
[A, B] extends [0, 0] | [1, 0] | [0, 1] ? 0 :
@JoshuaKGoldberg
JoshuaKGoldberg / binary.ts
Last active August 6, 2019 21:51
Silly Binary Logic in TypeScript's Type System
type Bit = 0 | 1;
type BitFlip<A> = A extends 0
? 1
: 0;
type BitOr<A, B> = [A, B] extends [0, 0]
? 0
: 1;
@JoshuaKGoldberg
JoshuaKGoldberg / README.md
Last active November 25, 2019 17:03
Codecademy Public CLA

Contribution License Agreement

This Contribution License Agreement ("Agreement") is agreed to by the party signing below (“You”), and conveys certain license rights to Ryzac, Inc and its affiliates (“RyzacInc”) for Your contributions to RyzacInc open source projects. This Agreement is effective as of the latest signature date below.

1. Definitions

"Code" means the computer software code, whether in human-readable or machine-executable form, that is delivered by You to RyzacInc under this Agreement. “Project” means any of the projects owned or managed by RyzacInc in which software is offered under a license approved by the Open Source Initiative (OSI) (www.opensource.org) and documentation offered under an OSI or a Creative Commons license (https://creativecommons.org/licenses). “Submit” is the act of uploading, submitting, transmitting, or distributing code or other content to any Project, including but not limited to communication on electronic mailing lists, source code control systems, and