Skip to content

Instantly share code, notes, and snippets.

View sindresorhus's full-sized avatar
🌴
On vacation

Sindre Sorhus sindresorhus

🌴
On vacation
View GitHub Profile
@ceejbot
ceejbot / esm_in_node_proposal.md
Last active July 17, 2023 02:45
npm's proposal for supporting ES modules in node

ESM modules in node: npm edition

The proposal you’re about to read is not just a proposal. We have a working implementation of almost everything we discussed here. We encourage you to checkout and build our branch: our fork, with the relevant branch selected. Building and using the implementation will give you a better understanding of what using it as a developer is like.

Our implementation ended up differing from the proposal on some minor points. As our last action item before making a PR, we’re writing documentation on what we did. While I loathe pointing to tests in lieu of documentation, they will be helpful until we complete writing docs: the unit tests.

This repo also contains a bundled version of npm that has a new command, asset. You can read the documentation for and goals of that comma

Various command line applications use an Interpreter Directive to define how they should be run.

#! js -m foo
#! node foo
@sindresorhus
sindresorhus / average.swift
Last active October 17, 2017 10:56 — forked from fcanas/average.swift
Abstracted average function in Swift
extension Sequence where Element: ExpressibleByIntegerLiteral {
private func abstractAverage<T>(sum: (T, T) -> T, div: (T, T) -> T) -> T where Element == T {
var i: T = 0
var total: T = 0
for value in self {
total = sum(total, value)
i = sum(i, 1)
}
@fcanas
fcanas / average.swift
Created October 7, 2017 00:19
Abstracted average function in swift
extension Sequence where Element: BinaryFloatingPoint {
func average() -> Element {
return abstractAverage(sequence: self, sum: +, div: /)
}
}
extension Sequence where Element: SignedInteger {
func average() -> Element {
return abstractAverage(sequence: self, sum: +, div: /)
}
}
@soffes
soffes / Rakefile
Last active January 16, 2023 16:37
Programmatically build and sign a Developer ID macOS app
TEAM_ID = 'XXXXXXXXXX'
APP_NAME = 'My App'
SCHEME_NAME = APP_NAME
desc 'Create a beta build'
task :build do
# Ensure clean git state
unless system 'git diff-index --quiet HEAD --'
abort 'Failed. You have uncommitted changes.'
end
// clang++ -std=c++11 lol.cc -o lol
#include <iostream>
using namespace std;
int main() {
int lol = 10;
int l​ol = 10;
int l​o​l = 10;
int l​​ol = lol + l​ol + l​o​l;
@egmontkob
egmontkob / Hyperlinks_in_Terminal_Emulators.md
Last active April 17, 2024 01:21
Hyperlinks in Terminal Emulators
@bomberstudios
bomberstudios / sketch-diff-in-git.md
Last active November 8, 2019 17:58
How to diff your .sketch files in Git

Using sketchtool to diff your .sketch files using text

Requirements

You need to have SketchTool installed somewhere in your path.

Setup

Add this in your ~/.gitconfig file (for some reason, it won't work in a local .gitconfig file):

@vvo
vvo / should-I-pin-npm-dependencies?.md
Last active March 8, 2017 22:12
About authoring frontend libraries, building them, publishing to npm and dependencies

You have a nice library published on npm but asking yourselve if you should declare your dependencies as lodash: "3.10.0" (known as "pin" a dependency) or lodash: "^3.10.0"?

As library authors we should not pin dependencies but ask our users to do use npm shrinkwrap in their own app.

Here's why:

Pinning dependencies will result in duplicated code and modules in builds

If you pin your dependencies the issue is that anyone using your module will may not benefit from shared dependencies. If your module user has lodash: "^3.11.0" then since you declared

@paulirish
paulirish / how-to-view-source-of-chrome-extension.md
Last active April 17, 2024 21:44
How to view-source of a Chrome extension

Option 1: Command-line download extension as zip and extract

extension_id=jifpbeccnghkjeaalbbjmodiffmgedin   # change this ID
curl -L -o "$extension_id.zip" "https://clients2.google.com/service/update2/crx?response=redirect&os=mac&arch=x86-64&nacl_arch=x86-64&prod=chromecrx&prodchannel=stable&prodversion=44.0.2403.130&x=id%3D$extension_id%26uc" 
unzip -d "$extension_id-source" "$extension_id.zip"

Thx to crxviewer for the magic download URL.