Skip to content

Instantly share code, notes, and snippets.

View cmolina's full-sized avatar
🔥
This is fine 🔥

Carlos Molina A cmolina

🔥
This is fine 🔥
View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active June 26, 2024 12:32
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@existentialmutt
existentialmutt / db_fixtures_export.rake
Last active March 25, 2023 21:10 — forked from kuboon/db_fixtures_export.rake
Generate fixtures from db. Readable by rake db:fixtures:load
# lib/tasks/db_fixtures_export.rake
namespace 'db:fixtures' do
desc "generate fixtures from the current database"
task :export => :environment do
Rails.application.eager_load!
models = defined?(ApplicationRecord) ? ApplicationRecord.descendants : ActiveRecord::Base.descendants
models.each do |model|
puts "exporting: #{model}"
@7yl4r
7yl4r / reusableExceptions.md
Last active July 27, 2021 17:26
info on Java built-in exceptions from perspective of developer looking to reuse built-in exceptions

organized by estimated utility

IllegalArgumentException

Thrown to indicate that a method has been passed an illegal or inappropriate argument.

IndexOutOfBoundsException

Thrown to indicate that an index of some sort (such as to an array, to a string, or to a vector) is out of range.

ArithmeticException

Thrown when the requested mathematical operation is non-sensical or impossible.

@teawithfruit
teawithfruit / tidy5-install-ubuntu.sh
Last active February 22, 2016 20:40
Install tidy5 on Ubuntu.
#!/bin/bash
# Check if user is root
if [ $(id -u) != "0" ]; then
echo "Error: You must be root to run this script, please use root to install the software."
exit 1
fi
apt-get remove libtidy-0.99-0 tidy -y
wget -O /tmp/tidy-5.0.0-64bit.deb http://www.htacg.org/binaries/binaries/tidy-5.0.0.RC1/tidy-5.0.0-64bit.deb
@jboner
jboner / latency.txt
Last active June 25, 2024 12:58
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD