Skip to content

Instantly share code, notes, and snippets.

View webhacking's full-sized avatar
Hyper focusing

hax0r webhacking

Hyper focusing
View GitHub Profile
Rich-Harris /
Last active May 6, 2024 10:24
Top-level `await` is a footgun

Edit — February 2019

This gist had a far larger impact than I imagined it would, and apparently people are still finding it, so a quick update:

  • TC39 is currently moving forward with a slightly different version of TLA, referred to as 'variant B', in which a module with TLA doesn't block sibling execution. This vastly reduces the danger of parallelizable work happening in serial and thereby delaying startup, which was the concern that motivated me to write this gist
  • In the wild, we're seeing (async main(){...}()) as a substitute for TLA. This completely eliminates the blocking problem (yay!) but it's less powerful, and harder to statically analyse (boo). In other words the lack of TLA is causing real problems
  • Therefore, a version of TLA that solves the original issue is a valuable addition to the language, and I'm in full support of the current proposal, which you can read here.

I'll leave the rest of this document unedited, for archaeological

btfak /
Created May 26, 2016 09:41
How to use Hexo and deploy to GitHub Pages
staltz /
Last active May 27, 2024 03:11
The introduction to Reactive Programming you've been missing
denji /
Last active May 25, 2024 13:32
NGINX tuning for best performance

Moved to git repository:

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

branneman /
Last active April 27, 2024 04:16
Better local require() paths for Node.js

Better local require() paths for Node.js


When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

mavropalias / gist:3135341
Created July 18, 2012 09:55
Node.js Amazon Cloudformation template
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Node.js server",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access",
"Type" : "String"
bellbind /
Created December 11, 2011 14:21
[python]tower of hanoi
def hanoi_imp(n, curr, dest, rest):
if n == 0: return
hanoi_imp(n - 1, curr, rest, dest)
print("move %n from %s to %s" % (n, curr, dest))
hanoi_imp(n - 1, rest, dest, curr)
def hanoi_fun(n, curr, dest, rest):
return [] if n == 0 else (
hanoi_fun(n - 1, curr, rest, dest) +
DHS / PHP Countries Array
Created November 4, 2011 18:51
PHP array of all country names
$countries = array("Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegowina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia (Hrvatska)", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Island
mbijon / xss_clean.php
Last active November 1, 2022 03:23
XSS filtering in PHP (cleans various UTF encodings & nested exploits)
* XSS filter, recursively handles HTML tags & UTF encoding
* Optionally handles base64 encoding
* ***DEPRECATION RECOMMENDED*** Not updated or maintained since 2011
* This was built from numerous sources