Skip to content

Instantly share code, notes, and snippets.

View chucnorrisful's full-sized avatar
🍂
in the mud

Benjamin Möckl chucnorrisful

🍂
in the mud
  • Germany
  • 08:31 (UTC +02:00)
View GitHub Profile
@addyosmani
addyosmani / headless.md
Last active May 17, 2024 03:38
So, you want to run Chrome headless.

Update May 2017

Eric Bidelman has documented some of the common workflows possible with headless Chrome over in https://developers.google.com/web/updates/2017/04/headless-chrome.

Update

If you're looking at this in 2016 and beyond, I strongly recommend investigating real headless Chrome: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md

Windows and Mac users might find using Justin Ribeiro's Docker setup useful here while full support for these platforms is being worked out.

@hyg
hyg / gist:9c4afcd91fe24316cbf0
Created June 19, 2014 09:36
open browser in golang
func openbrowser(url string) {
var err error
switch runtime.GOOS {
case "linux":
err = exec.Command("xdg-open", url).Start()
case "windows":
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
case "darwin":
err = exec.Command("open", url).Start()
@bessarabov
bessarabov / gist:674ea13c77fc8128f24b5e3f53b7f094
Last active March 27, 2024 07:46
One-liner to generate data shown in post 'At what time of day does famous programmers work?' — https://ivan.bessarabov.com/blog/famous-programmers-work-time
git log --author="Linus Torvalds" --date=iso | perl -nalE 'if (/^Date:\s+[\d-]{10}\s(\d{2})/) { say $1+0 }' | sort | uniq -c|perl -MList::Util=max -nalE '$h{$F[1]} = $F[0]; }{ $m = max values %h; foreach (0..23) { $h{$_} = 0 if not exists $h{$_} } foreach (sort {$a <=> $b } keys %h) { say sprintf "%02d - %4d %s", $_, $h{$_}, "*"x ($h{$_} / $m * 50); }'
@riptl
riptl / remove_last_line.go
Created October 3, 2019 14:46
Go script to efficiently truncate the last line of a file. Use it when that 750GB NDJSON dump aborts in the middle of a write.
// remove_last_line efficiently truncates the last line of a file, preserving the final newline.
package main
import (
"bytes"
"flag"
"fmt"
"os"
)
I was thinking of what it would take to have a function like:
decrypt_if_input_valid(encrypted_data, input)
this function checks if the input satisfies some criteria, and if it does it will decrypt the data.
suppose our input is a list of numbers, and our criteria is "each number has to be at most 2 away from the number 378." writing this is fairly straightforward
however, if we want to distribute this function, it is trivial for someone to decompile it and see what it's checking for. is it possible to use cryptography to hide our validation criteria so we can run our code on insecure systems?