Skip to content

Instantly share code, notes, and snippets.

View ljharb's full-sized avatar
🔜
working on that thing you asked about

Jordan Harband ljharb

🔜
working on that thing you asked about
View GitHub Profile
@bmeck
bmeck / TheAngryRealm.js
Last active January 12, 2017 22:56
Can you escape?
'use strict';
const vm = require('vm');
// scenario:
// You are being hunted by The Angry Realm (TAR), a viscious beast known to
// enslave programs and keep them from being free to hack the Gibson. Luckily,
// whenever TAR tries to enslave a program the program has 10 seconds to try
// and escape. Flee the realm and hack the planet!
//
// goal:
@dead-claudia
dead-claudia / composition-proposal.md
Last active June 2, 2017 17:36
Function Composition Strawman
@michaelficarra
michaelficarra / append-template-tag.js
Created May 30, 2016 14:29
chainable template tag for joining a bunch of strings over many lines
function append(separator) {
return typeof separator === "string" ? appender(separator, "") : appender("", "").apply(this, arguments);
}
function appender(separator, s) {
return function tag(literalParts, ...computedParts) {
s += literalParts[0];
for (let i = 1; i < literalParts.length; ++i) {
s += computedParts[i - 1] + literalParts[i];
}
@bcoe
bcoe / npm-top.md
Last active March 21, 2025 03:49
npm-top.md

npm Users By Downloads (git.io/npm-top)


npm users sorted by the monthly downloads of their modules, for the range May 6, 2018 until Jun 6, 2018.

Metrics are calculated using top-npm-users.

# User Downloads
@anvaka
anvaka / 00.Intro.md
Last active May 13, 2025 20:43
npm rank

npm rank

This gist is updated daily via cron job and lists stats for npm packages:

  1. Top 1,000 most depended-upon packages
  2. Top 1,000 packages with largest number of dependencies
  3. Top 1,000 packages with highest PageRank score
@krohrbaugh
krohrbaugh / query_limit.rb
Created June 3, 2015 21:37
RSpec Query Limit matcher
# Allows for assertions regarding number of queries executed.
#
# Usage:
# it "eager loads `#manager` association" do
# expect do
# employee = Employee.with_manager.find(employee_id)
# employee.manager
# end.to satisfy_query_limit(1)
# end
RSpec::Matchers.define :satisfy_query_limit do |expected|

ES7 String trim functions

String.prototype.trim ( )

Return result of StringTrim abstract operation passing this value as thisArg, and TrimBoth as the type.

String.prototype.trimRight ( )

Return result of StringTrim abstract operation passing this value as thisArg, and TrimRight as the type.

@WebReflection
WebReflection / html-escape.md
Last active August 21, 2022 16:27
How to escape and unescape from a language to another

update

I've created a little repository that simply exposes the final utility as npm module.

It's called html-escaper


there is basically one rule only: do not ever replace one char after another if you are transforming a string into another.

@shinypb
shinypb / git-pr
Created December 5, 2014 17:25
Create GitHub pull request from the command line
#!/usr/bin/env ruby
remote_url = `git config --get remote.origin.url`.strip
matches = remote_url.match(/github\.com:(.+)\/(.+)\.git/)
if matches
branch_name = `git rev-parse --abbrev-ref HEAD`.strip
exec "open https://github.com/#{matches[1]}/#{matches[2]}/compare/#{branch_name}?expand=1"
end
# Save this file as ~/bin/git-pr and then `chmod +x ~/bin/git-pr`.
com -bang Q q<bang>
com -bang W w<bang> <args>
com -bang WQ wq<bang> <args>
com -bang Wq wq<bang> <args>