Skip to content

Instantly share code, notes, and snippets.

View restjohn's full-sized avatar

Robert St. John restjohn

View GitHub Profile
@joepie91
joepie91 / es-modules-are-terrible-actually.md
Last active June 8, 2024 13:41
ES Modules are terrible, actually

ES Modules are terrible, actually

This post was adapted from an earlier Twitter thread.

It's incredible how many collective developer hours have been wasted on pushing through the turd that is ES Modules (often mistakenly called "ES6 Modules"). Causing a big ecosystem divide and massive tooling support issues, for... well, no reason, really. There are no actual advantages to it. At all.

It looks shiny and new and some libraries use it in their documentation without any explanation, so people assume that it's the new thing that must be used. And then I end up having to explain to them why, unlike CommonJS, it doesn't actually work everywhere yet, and may never do so. For example, you can't import ESM modules from a CommonJS file! (Update: I've released a module that works around this issue.)

And then there's Rollup, which apparently requires ESM to be u

@guga31bb
guga31bb / nflscrapr.md
Last active August 18, 2023 07:45
Simple guide for using nflscrapR

THIS IS OUTDATED. PLEASE FOLLOW THE FOLLOWING LINK

--> A beginner's guide to nflfastR <--

Basic nflscrapR tutorial

I get a lot of questions about how to get nflscrapR up and running. This guide is intended to help new users build interesting tables or charts from the ground up, taking the raw nflscrapR data.

Quick word if you're new to programming: all of this is happening in R. Obviously, you need to install R on your computer to do any of this. Make sure you save what you're doing in a script (in R, File --> New script) so you can save your work and run multiple lines of code at once. To run code from a script, highlight what you want, right click, and select Run line. As you go through your R journey, you might get stuck and have to google a bunch of things, but that's totally okay and normal. That's how I wrote this thing!

@jeffijoe
jeffijoe / ScrollManager.jsx
Last active November 1, 2023 18:51
Save and restore scroll position in React
/*
The MIT License
Copyright (c) Jeff Hansen 2018 to present.
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 CONNECTION W
@pramukta
pramukta / Catalog Stitching.ipynb
Created April 26, 2017 19:54
Point-in-time mosaic generation using PDAP
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vlucas
vlucas / encryption.js
Last active June 7, 2024 04:27
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
@kciter
kciter / RxAlamofire+ObjectMapper.swift
Created August 11, 2016 02:52
RxAlamofire+ObjectMapper
import UIKit
import RxSwift
import RxAlamofire
import ObjectMapper
class Post: Mappable {
var id: Int = 0
var title: String = ""
required init?(_ map: Map) {
@paambaati
paambaati / launch.js
Last active May 5, 2022 05:35
Debug mocha tests using Visual Studio Code
{
"version": "0.1.0",
// List of configurations. Add new configurations or edit existing ones.
// ONLY "node" and "mono" are supported, change "type" to switch.
"configurations": [
{
// Name of configuration; appears in the launch configuration drop down menu.
"name": "Run app.js",
// Type of configuration. Possible values: "node", "mono".
"type": "node",
@aceontech
aceontech / CoreDataInMemorySetupExampleSpec.m
Created February 7, 2014 10:04
Setting up an in-memory Core Data stack for unit testing. This example uses Specta, but can be easily be adapted for XCTest.
#import <Specta.h>
#define EXP_SHORTHAND
#import <Expecta.h>
#import <CoreData/CoreData.h>
SpecBegin(CoreDataInMemorySetupExample)
__block NSManagedObjectContext *context;
beforeAll(^{
// ObjectModel from any models in app bundle
@asmallteapot
asmallteapot / gist:7241750
Created October 30, 2013 22:56
Returning BOOL values from mocked & stubbed methods using OCMock.
// @property (nonatomic) BOOL enabled;
// someObject = [OCMock partialMockForObject:[[SomeObject alloc] init]];
[[[mock stub] andDo:^(NSInvocation *invocation) {
BOOL enabled = someObject.enabled;
NSValue *returnValue = [NSValue valueWithBytes:&enabled objCType:@encode(BOOL)];
[invocation setReturnValue:&returnValue];
}] enabled];
@willurd
willurd / web-servers.md
Last active June 7, 2024 03:53
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000