Skip to content

Instantly share code, notes, and snippets.

View lgarron's full-sized avatar
💭
😼

Lucas Garron lgarron

💭
😼
View GitHub Profile
@lgarron
lgarron / captive-portal-testing.md
Last active August 29, 2015 14:13
Chrome Captive Portal Testing

Add the following line to /etc/hosts (remember to undo this):

127.0.0.1 www.gstatic.com

Run a simple server on port 80. Here's a command you can run from bash:

cat <<EOF | sudo python -
import SocketServer
import SimpleHTTPServer

class CustomHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):

@lgarron
lgarron / gist:aa2b0220a90e1b46aa4a
Last active August 29, 2015 14:15
Google Groups Markdown Link Generator
/*
Convert to a bookmarklet using: http://chriszarate.github.io/bookmarkleter/
*/
prompt("Link", "[" + document.getElementById("t-t").innerHTML + "](" + location.href.replace("?utm_medium=email&utm_source=footer", "") + ")")
@lgarron
lgarron / copyToClipboard.html
Last active December 20, 2023 12:53
Simple `navigator.clipboard.writeText()` polyfill.
<script>
// A minimal polyfill for copying text to clipboard that works most of the time in most capable browsers.
// Note that:
// - You may not need this. `navigator.clipboard.writeText()` works directly in all modern browsers as of 2020.
// - In Edge, this may call `resolve()` even if copying failed.
// - In Safari, this may fail if there is nothing selected on the page.
// See https://github.com/lgarron/clipboard-polyfill for a more robust solution.
//
// License for this Gist: public domain / Unlicense
function writeText(str) {
@lgarron
lgarron / console.log.cpp
Last active May 31, 2019 09:40
Trolling C++ using console.log
/* Vararg code by Daniel Cheng (@zetafunction) */
#include <iostream>
#include <utility>
struct {
template<typename T>
static void log(T&& t) {
std::cout << t << "\n";
}
@lgarron
lgarron / crbug-expand-blockers.js
Created April 11, 2016 22:59
crbug-expand-blockers.js
javascript:document.styleSheets[0].insertRule(".rel_issues a { white-space: normal !important;", 1);[].slice.call(document.querySelector(".rel_issues").querySelectorAll("a")).map(a => a.textContent += " %E2%80%93 " + a.title)
@lgarron
lgarron / dabblet.css
Created December 7, 2016 19:47
hstspreload spinner
html, body {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.spinner {
width: 2em;
height: 2em;
border-radius: 1.25em;
@lgarron
lgarron / dabblet.css
Last active December 8, 2016 19:59
Untitled
html, body {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
font-family: Tahoma, sans-serif;
font-weight: bold;
}
.all {
@lgarron
lgarron / Algorithms.md
Last active June 14, 2018 01:01
Algorithm Representation

In the example below, a "group" is a sequence of moves surrounded in parentheses.

Design goal

A representation of algorithms in JSON that also maps to native data structures and classes in most programming languages.

Desirable properties:

  1. Easy to represent in a programming language with lists and "classes" (objects with pre-defined patterns of properties).
  2. The data structures are straightforward to flatten to/from JSON.
In[121]:= p = NextPrime[RandomInteger[{2^2047, 2^2048}]]
Out[121]= \
2472858022210415099164045402553368874951528885035736322800760410002954\
4038243222193098931418739578329762267040841916783150979034128645102130\
0253513299160810798121444406865510009715543992322555089967015541632378\
0710135209985817236443936777772937122422269799403563157416882656645382\
0161318776579572843028782784167357793642890306031876148210563553196737\
6550335038180588177627102411796625979142817323054655605301722206159897\
4290495880080776782541535829627114438988359115159634994645719944873859\
-----BEGIN CERTIFICATE-----
MIIEMjCCAhqgAwIBAgIJAJTDWlDByBsuMA0GCSqGSIb3DQEBCwUAMH8xCzAJBgNV
BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1TYW4gRnJhbmNp
c2NvMQ8wDQYDVQQKDAZCYWRTU0wxMjAwBgNVBAMMKUJhZFNTTCBJbnRlcm1lZGlh
dGUgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4XDTE3MDMxNjIxMzc1OFoXDTE5MDMx
NjIxMzc1OFowADCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANha8llF
sU36X+ITw2ZX19h8jeKotuqSZODI/GM43Log7yvepkDOQPP5Xz7wCG5WAopV35TB
rD81nA4qivlEsdaih4DQuGizm/WAGWWpS7/0uVthRi2Q3+rm/saEKNIxGr+IHMJY
yPh2jIJofnYFMmVzVy2i7mrZmb+ji4cFR5YMV+vb53m7yBGiH8YIsNsKAwMbflzy
1BWX81sRq9F4V1I1htqzlkaZHQD9ug3InEEBWAt9Mr8+qTGRAmxBiMLHBciXUlhD