Skip to content

Instantly share code, notes, and snippets.

@tmcw
tmcw / turf.md
Created November 22, 2018 20:56

Okay, Thanksgiving day Turf deep dive. Let's do this.

The problem: a refactored Turf relies on tree shaking to make it possible to include subsections of the module without including the whole thing. But tree shaking isn't working.

Approach

Remove indirection

We bundle from ES6 import/export modules into a single module bundle. Instead, set module: 'src/index.js' to remove a potential problem - Rollup bundling.

#!/bin/bash
set -e
CONTENTS=$(tesseract -c language_model_penalty_non_dict_word=0.8 --tessdata-dir /usr/local/share/tessdata/ "$1" stdout -l eng | xml esc)
hex=$((cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@ParagDoke
ParagDoke / convert_ics_timezone.py
Created August 6, 2017 09:23
Convert ics files with aware datetimes to new timezone
#!/usr/bin/env python
# vim:filetype=python:expandtab:tabstop=4:shiftwidth=4:
"""
Copied from https://gist.github.com/deybhayden/1980583#file-convert_ics_timezone-py
I observed that dtstart.dt datetime objects were aware (not naive).
There was no need to identify oldtz. Original author's comments left below.
Parag Doke
Asia/Kolkata :-)
-----
@joncamfield
joncamfield / The PGP Hotel.md
Last active March 23, 2023 12:48
A way to explain PGP (and/or public key crypto more broadly) using a hotel/apartment metaphor.

This is a draft!

Please give feedback, especially where the description is confusing or breaks the mental model of a hotel/apartment setup. As written, this is mean for fellow digisec trainers to leverage in their explanations, and is not (yet) a document to help people learning PGP by themselves.

There are a ton of ways people have described PGP in specific and public key cryptography more generally - from mixing paint (http://gizmodo.com/5888567/how-to-understand-encryption-using-paint-and-clocks, http://maths.straylight.co.uk/archives/108) to magic lock-boxes and Romeo and Juliet (https://www.level-up.cc/leading-trainings/training-curriculum/activity/love-story). I present another, which uses the experience of a hotel (or, alternatively, apartment buildings with front desk staff) as an analogy which can stretch to cover not just cryptography, but also digital signatures. This is written to explain PGP, but could be adapted for S/MIME and other public key crypto approaches.

The PGP Hotel

You an

@brunosan
brunosan / index.md
Last active June 15, 2018 23:57
This is a list inspired by some of our current or potential lines of work at the World Bank Innovation Labs. The “Innovations in Big Data Analytics” program helps to strengthen the World Bank capabilities to effectively use big data in its operational and strategic work.

This is a list inspired by some of our current or potential lines of work at the World Bank Innovation Labs. The “Innovations in Big Data Analytics” program helps to strengthen the World Bank capabilities to effectively use big data in its operational and strategic work.

We are always looking for great Data Scientists. If you can solve any of these [using open software], you'll be heads down helping us from day one. Email us to brunosanchez@worldbank.org

(This list is updated frequently).

1. Nightlights from Satellite

We are building an open stack to process nightly data from satellite and query light output from all known villages. Currently we are doing 20 years of nightly data for 600,000 villages in India.

@baptx
baptx / twitter_api_1.1_backup.js
Last active July 29, 2022 10:00
Twitter API 1.1 tweets / favorites (likes) / following / followers backup in web browser
/* Twitter API 1.1 tweets / favorites (likes) / following / followers backup in web browser
* Get your access keys to use Twitter API 1.1: https://dev.twitter.com/docs/auth/tokens-devtwittercom
* You can change Twitter API URL and Twitter screen_name, then execute script from a trusted web page without CSP protection like about:blank in a web browser console (F12 or Ctrl+Shift+K shortcut)
* A textarea will appear so you can copy/paste to save data as a CSV file or search tweets / users in your web browser (Ctrl+F shortcut)
* You can then view your backup in a spreadsheet editor like LibreOffice Calc
* You can also compare the backup with another one to see who unfollowed you, who changed their Twitter username by looking at the user ID or which tweet you retweeted / favorited was deleted (e.g. with the Linux diff command)
*
* Note about the tweets backup:
* Usually you will search tweets that you retweeted using Twitter web version (https://twitter.com/search) with a search like "from:your_username f
javascript:!function e(r,o,t){function n(a,s){if(!o[a]){if(!r[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(i)return i(a,!0);throw new Error("Cannot find module '"+a+"'")}var d=o[a]={exports:{}};r[a][0].call(d.exports,function(e){var o=r[a][1][e];return n(o?o:e)},d,d.exports,e,r,o,t)}return o[a].exports}for(var i="function"==typeof require&&require,a=0;a<t.length;a++)n(t[a]);return n}({1:[function(e,r){function o(e,r){if("function"!=typeof r)throw new Error("Bad callback given: "+r);if(!e)throw new Error("No options given");var a=e.onResponse;if(e="string"==typeof e?{uri:e}:JSON.parse(JSON.stringify(e)),e.onResponse=a,e.verbose&&(o.log=i()),e.url&&(e.uri=e.url,delete e.url),!e.uri&&""!==e.uri)throw new Error("options.uri is a required argument");if("string"!=typeof e.uri)throw new Error("options.uri must be a string");for(var s=["proxy","_redirectsFollowed","maxRedirects","followRedirect"],d=0;d<s.length;d++)if(e[s[d]])throw new Error("options."+s[d]+" is not supported");if(e.callba
@jazzychad
jazzychad / gist:07c0c6da5709202e8106
Created December 18, 2014 22:10
git update commands, osx
cd /tmp
curl -o git-2.2.1.tar.gz "https://www.kernel.org/pub/software/scm/git/git-2.2.1.tar.gz"
curl -o git-2.2.1.tar.sign "https://www.kernel.org/pub/software/scm/git/git-2.2.1.tar.sign"
# if you want to verify the tar signature
gpg --keyserver hkp://keys.gnupg.net --recv-keys 6092693E
gunzip git-2.2.1.tar.gz
gpg --verify git-2.2.1.tar.sign
@konklone
konklone / 1-government-hsts.rb
Last active May 21, 2018 10:57
Script that detects government domains in Chrome's HSTS preload list.
#!/usr/bin/env ruby
# Script by Eric Mill to detect government domains in the Chrome HSTS Preload list.
#
# The Chrome HSTS Preload list is a hardcoded set of domains for which the browser
# will *only* ever access the site using HTTPS. If an http:// link to that site is
# encountered, the browser will just rewrite the URL to https:// before following
# it.
#
# This list is also incorporated into Firefox and Safari, making it a nice list to
@michaelrhodes
michaelrhodes / gh-pages-toggle.bookmarklet
Last active September 6, 2020 00:43
A bookmarklet for toggling between github repositories and their github pages.
javascript:(function(){(function(){if(/github.io$/.test(location.host)){var%20paths=location.href.match(/^.+\/\/(.+)\.github\.io\/([^\/]+)?\/?.*$/).slice(1);location.href="https://github.com/"+paths[0]+"/"+(paths[1]||'')}else%20if(location.host=="github.com"){var%20paths=location.pathname.substr(1).split("/");location.href="http://"+paths[0]+".github.io/"+paths[1]}})()})();