Skip to content

Instantly share code, notes, and snippets.

View justinribeiro's full-sized avatar
🌩️
Darkness falls.

Dr. Justin Ribeiro, Ph.D. justinribeiro

🌩️
Darkness falls.
View GitHub Profile
@justinribeiro
justinribeiro / check-wc.js
Created March 14, 2016 22:12
Check for need for WebComponents polyfill, use Shadow DOM.
var webComponentsSupported = ('registerElement' in document
&& 'import' in document.createElement('link')
&& 'content' in document.createElement('template'));
if (!webComponentsSupported) {
var script = document.createElement('script');
script.async = true;
script.src = '/bower_components/webcomponentsjs/webcomponents-lite.min.js';
document.head.appendChild(script);
@justinribeiro
justinribeiro / ae-handler.py
Last active November 2, 2016 18:55
Let's talk about AMP!
class MainHandler(http2.PushHandler):
def get(self):
name = os.path.join(os.path.dirname(__file__), 'dist/static/data/', self.request.path.lstrip("/amphtml/"), 'index.json')
f = open(name, 'r');
c = f.read()
f.close()
data = json.loads(c)
data['article'] = unescape(data['article'])
data['permalinkamp'] = data['permalink'].replace(".com", ".com/amphtml")
bot_template = os.path.join(os.path.dirname(__file__), 'dist/static/amphtml/index.html')
@justinribeiro
justinribeiro / vidcap1080.sh
Created September 21, 2016 16:03
Capture top left 1080 @ 60fps.
ffmpeg -video_size 1920x1080 -framerate 60 -f x11grab -i :0.0 -c:v libx264 -qp 0 -preset ultrafast my-file.mkv
@justinribeiro
justinribeiro / ubuntu-diff.patch
Created November 5, 2016 03:10
Way to make Chrome-headless build on Ubuntu.
diff --git a/build/install-build-deps.sh b/build/install-build-deps.sh
index 832d116..4594934 100755
--- a/build/install-build-deps.sh
+++ b/build/install-build-deps.sh
@@ -244,9 +244,9 @@ if package_exists apache2-bin; then
else
dev_list="${dev_list} apache2.2-bin"
fi
-if package_exists xfonts-mathml; then
- dev_list="${dev_list} xfonts-mathml"
@justinribeiro
justinribeiro / answers.md
Last active December 8, 2016 20:26
Answers for Martin's school project.

Q and A

Hopefully this helps your school project! --Justin

How long have you worked as a software engineer?

20-ish years. I wrote and sold my first piece of software when I was 16. Never looked back.

What made you want to become a software engineer?

Curiosity. My Mom taught me BASIC on a C64C back in 1987. My Dad bought a souped up 286 the that same year and said "if you break it, figure out how to fix it". I loved the challenge, I loved the problem solving. Building software was fun.

@justinribeiro
justinribeiro / eddystone-uid-gen.md
Created April 10, 2017 18:20
Sometimes I just need an EddyStone UID for testing.

Eddystone UID generate

Sometimes when I'm testing, I just need an UID and I don't particularly care about the ID portion. This little alias generate based on any string really (though should be FQDN).

alias genEuid='generateEddystoneUID'
generateEddystoneUID() {
  echo -n $1 | sha256sum | cut -b-10 | tr -d \\n | xxd -pu | xargs -I{} printf '%s%s' {} `od -vAn -N6 -tx2 < /dev/urandom | tr -d ' '`
}
@justinribeiro
justinribeiro / instruct.md
Last active September 27, 2019 18:56
Generating icons for PWAs with imagemagick convert and the command line

Generate a set of icons for the manifest, index metadata, so forth.

convert raw-icon.png \
  \( -clone 0 -resize 512x512 -write icon-512.png \) \
  \( -clone 0 -resize 384x384 -write icon-384.png \) \
  \( -clone 0 -resize 192x192 -write icon-192.png \) \
  \( -clone 0 -resize 144x144 -write icon-144.png \) \
  \( -clone 0 -resize 96x96 -write icon-96.png \) \
 \( -clone 0 -resize 72x72 -write icon-72.png \) \
@justinribeiro
justinribeiro / instruct.md
Last active December 20, 2021 08:42
ssh-agent-windows
  1. Open git-bash on Windows.
  2. Make sure you have a .profile: touch .profile
  3. Open .profile and add:
env=~/.ssh/agent.env

agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }

agent_start () {
@justinribeiro
justinribeiro / feature_detect_es_modules.js
Created November 22, 2017 23:21 — forked from ebidel/feature_detect_es_modules.js
Feature detect ES modules: both static import and dynamic import()
<!--
Complete feature detection for ES modules. Covers:
1. Static import: import * from './foo.js';
2. Dynamic import(): import('./foo.js').then(module => {...});
Demo: http://jsbin.com/tilisaledu/1/edit?html,output
Thanks to @_gsathya, @kevincennis, @rauschma, @malyw for the help.
-->