Skip to content

Instantly share code, notes, and snippets.

@wesbos
wesbos / logger.js
Created January 8, 2024 15:55
console.log line numbers in Node.js
// Use like this: node --import logger.js yourapp.js
import path from 'path';
const { log } = console;
[`debug`, `log`, `warn`, `error`, `table`, `dir`].forEach((methodName) => {
const originalLoggingMethod = console[methodName];
console[methodName] = (...args) => {
const originalPrepareStackTrace = Error.prepareStackTrace;
Error.prepareStackTrace = (_, stack) => stack;
import pandas as pd
import numpy as np
def get_dataset(size):
# Create Fake Dataset
df = pd.DataFrame()
df['size'] = np.random.choice(['big','medium','small'], size)
df['age'] = np.random.randint(1, 50, size)
df['team'] = np.random.choice(['red','blue','yellow','green'], size)
df['win'] = np.random.choice(['yes','no'], size)
// 1. Shorten the console log
const log = console.log.bind(document)
log("does it work?")
log("yes")
log(5)
// 2. Merge two arrays into one
const array1 = ["One", "Two", "Three"]
const array2 = ["Four", "Five", "Six"]
We can't make this file beautiful and searchable because it's too large.
Entity,Code,Year,Coal (% of total),Nuclear (Rate),Natural gas (Rate),Oil (Rate),Hydroelectric (Rate),Other renewables (excluding hydro) (Rate)
Albania,ALB,1971,0,0,0,42.8571428571429,57.1428571428571,0
Albania,ALB,1972,0,0,0,37.9310344827586,62.0689655172414,0
Albania,ALB,1973,0,0,0,33.7837837837838,66.2162162162162,0
Albania,ALB,1974,0,0,0,31.5789473684211,68.4210526315789,0
Albania,ALB,1975,0,0,0,28.0898876404494,71.9101123595506,0
Albania,ALB,1976,0,0,0,25.4901960784314,74.5098039215686,0
Albania,ALB,1977,0,0,0,23.4782608695652,76.5217391304348,0
Albania,ALB,1978,0,0,0,22.5806451612903,77.4193548387097,0
Albania,ALB,1979,0,0,0,21.1678832116788,78.8321167883212,0
<div id="app"></div>
<script>
// fileA.js
let currentEffect
class Dep {
constructor() {
this.subscribers = new Set()
}
@bartleby
bartleby / iOS URL Schemes
Created August 22, 2018 17:48
iOS URL Schemes
URL Schemes
Apple
 
Apple Music     — music://geo.itunes.apple.com/us/albums/<albumID>
                – music://geo.itunes.apple.com/us/artists/<artistID>
 
Apple News      — applenews://
App Store       — itms-apps://itunes.apple.com/app/<appID>
Apple TV        — videos://

Visual Studio Code shortcuts I use often

Navigation

Sidebar:

  • Cmd-Shift-F: search
  • Cmd-Shift-E: files

Navigating in current editor:

dialog {
position: fixed;
top: 50%;
left: 50%;
right: auto;
padding: 30px;
transform: perspective(500px) translate(-50%, -50%);
background: linear-gradient(to bottom, #FFF, #F4F4F4) #FFF;
border: none;
border-radius: 3px;
@psiborg
psiborg / Docker.md
Last active December 7, 2020 19:45
Docker commands #docker #geospatial

Basics

docker version
docker info

docker login
docker logout

docker image ls
docker container ls --all