Skip to content

Instantly share code, notes, and snippets.

@nicholasglazer
nicholasglazer / variousCountryListFormats.js
Created June 27, 2023 15:10 — forked from incredimike/variousCountryListFormats.js
List of Countries in various Javascript data structures: Alphabetical country lists & Country data objects.
// Lists of countries with ISO 3166 codes, presented in various formats.
// Last Updated: July 30, 2020
// If you're using PHP, I suggest checking out:
// https://github.com/thephpleague/iso3166
// or Laravel: https://github.com/squirephp/squire
//
// JS developers can check out:
// https://www.npmjs.com/package/iso3166-2-db
//
@nicholasglazer
nicholasglazer / ghcPkgUtils.sh
Created June 6, 2020 12:02 — forked from timmytofu/ghcPkgUtils.sh
ghc-pkg-clean and ghc-pkg-reset compatible with both zsh and bash
# unregister broken GHC packages. Run this a few times to resolve dependency rot in installed packages.
# ghc-pkg-clean -f cabal/dev/packages*.conf also works.
function ghc-pkg-clean() {
for p in `ghc-pkg check $* 2>&1 | grep problems | awk '{print $6}' | sed -e 's/:$//'`
do
echo unregistering $p; ghc-pkg $* unregister $p
done
}
# remove all installed GHC/cabal packages, leaving ~/.cabal binaries and docs in place.
@nicholasglazer
nicholasglazer / newegg.py
Created May 11, 2017 01:46 — forked from timtadh/newegg.py
How to extract all of the items (name, price) from Newegg.
import itertools
import requests, lxml, lxml.html
import json
# 7603 Hard Drives
# 7611 RAM
# 6642 random store
def newegg_stores_req():
r = requests.api.get('http://www.ows.newegg.com/Stores.egg/Menus')
return [store['StoreID'] for store in json.loads(r.content)]
@nicholasglazer
nicholasglazer / introrx.md
Created June 29, 2016 14:32 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
var cheerio = require('cheerio');
var Crawler = require('simplecrawler');
var initialTopic = 'SpaceX';
var blacklist = ["#", "/w/", "/static/", "/api/", "/beacon/", "File:",
"Wikipedia:", "Template:", "MediaWiki:", "Help:", "Special:",
"Category:", "Portal:", "Main_Page", "Talk:", "User:",
"User_talk:", "Template_talk:", "Module:"]; //useless special cases from wikipedia
var url = '/wiki/' + initialTopic;
x(url, {
poster: '.image img@src',
videoLink: x('#player@src', 'body script'),
})
(function (err, obj) {
if (err) {
console.log(err);
}
@nicholasglazer
nicholasglazer / javascript_resources.md
Created May 6, 2014 21:57 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage