Skip to content

Instantly share code, notes, and snippets.

💭
😼

Lucas Garron lgarron

💭
😼
Block or report user

Report or block lgarron

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lgarron
lgarron / copyToClipboard.html
Last active Aug 30, 2019
Simple `navigator.clipboard.writeText()` polyfill.
View copyToClipboard.html
<script>
// A minimal polyfill for `navigator.clipboard.writeText()` that works most of the time in most modern browsers.
// Note that:
// - 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: public domain
function writeText(str) {
return new Promise(function(resolve, reject) {
var success = false;
@lgarron
lgarron / console.log.cpp
Last active May 31, 2019
Trolling C++ using console.log
View console.log.cpp
/* 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 / index.md
Created Feb 4, 2019
Example Solves
View index.md
View js-cubing.md

JS Cubing

if [ ! -d "alg" ]; then
   git clone https://github.com/cubing/alg.js       alg
fi
if [ ! -d "kpuzzle" ]; then
   git clone https://github.com/cubing/kpuzzle.js   kpuzzle
fi
if [ ! -d "twisty" ]; then
   git clone https://github.com/cubing/twisty.js    twisty
@lgarron
lgarron / Algorithms.md
Last active Jun 14, 2018
Algorithm Representation
View Algorithms.md

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.
@lgarron
lgarron / crbug-bookmarklet.js
Last active Jul 6, 2017
Copy a pretty URL version of a Chromium issue (e.g. https://crbug.com/414843).
View crbug-bookmarklet.js
/*
Convert to a bookmarklet using: https://chriszarate.github.io/bookmarkleter/
When you're on a Chromium issue page, this bookmarklet copies the short URL to clipboard. Also offers a markup version, a snippets version, and the pure ID.
Example: https://crbug.com/445359 instead of https://bugs.chromium.org/p/chromium/issues/detail?id=445359&can=1&q=owner%3Ame%20OR%20reporter%3Ame%20OR%20cc%3Ame%20OR%20commentby%3Ame&sort=-modified&colspec=ID%20Pri%20M%20Status%20Owner%20Summary%20OS%20Modified
*/
// https://github.com/lgarron/clipboard.js
var clipboard = {};
clipboard.copy = (function() {
View checkout-chromium-preload-list.sh
#!/usr/bin/env bash
# Setup script for a checkout of the Chromium HSTS preload list.
# Source -> medium.com/p/8c8896f5cef3 and gist.github.com/hemanth/7611535
echo "---- Creating folder and initializing a git repository. ----"
mkdir chromium-hsts && cd chromium-hsts
git init
echo "---- Adding chromium remote and initializing sparse checkout of /net/http. ----"
git remote add origin https://chromium.googlesource.com/chromium/src
View ѕрооғ.badssl.com.csr
-----BEGIN CERTIFICATE REQUEST-----
MIIC9DCCAdwCAQAwbjELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWEx
FjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xDzANBgNVBAoMBkJhZFNTTDEhMB8GA1UE
AwwYeG4tLW4xYWFlN2Y3by5iYWRzc2wuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOC
AQ8AMIIBCgKCAQEAwgTs+IzuBMKz2FDVcFjMkxjrXKhoSbAitfmVnrErLHY+bMBL
YExM6rK0wA+AtrD5csmGAvlcQV0TK39xxEu86ZQuUDemZxxhjPZBQsVG0xaHJ590
6wqdEVImIXNshEx5VeTRa+gGPUgVUq2zKNuq/27/YJVKd2s58STRMbbdTcDE/FO5
bUKttXz+rvUV0jNI5yJxx8IUemwo6jdK3+pstXK0flqiFtxpsVdE2woSq97DD0d0
XEEi4Zr5G5PmrSIGKS6xukkcDCeeo/uL90ByAKySCNmMV4RTgQXL5v5rVJhAJ4XH
ELtzcO9pGEEHRVV8+WQ/PSzDqXzrkxpMhtHKhQIDAQABoEEwPwYJKoZIhvcNAQkO
View Braille ASCII loading animation
⠁⠃⠂⠆⠄⠤⠠⠰⠐⠘⠈⠉
Inspired by https://github.com/typings/typings
@lgarron
lgarron / replace.fish
Last active Apr 5, 2017
Replace using `ag` and `sed` in fish
View replace.fish
# brew install gsed
for file in (ag -i -l "PageInfoPopupView" .)
echo $file
gsed --in-place="" "s/PageInfoPopupView/PageInfoBubbleView/g" $file
end
You can’t perform that action at this time.