Skip to content

Instantly share code, notes, and snippets.

View yerffejytnac's full-sized avatar

Jeffrey yerffejytnac

View GitHub Profile
//Converting colors to proper format
function normalizeColor(hexCode) {
return [
((hexCode >> 16) & 255) / 255,
((hexCode >> 8) & 255) / 255,
(255 & hexCode) / 255,
];
}
["SCREEN", "LINEAR_LIGHT"].reduce(
(hexCode, t, n) =>
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE OR REPLACE FUNCTION nanoid(size int DEFAULT 12)
RETURNS text AS $$
DECLARE
id text := '';
idx int := 0;
alphabet char(62) := '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
bytes bytea := gen_random_bytes(size);
byte int;
#!/bin/bash
set -u
# First check if the OS is Linux.
if [[ "$(uname)" = "Linux" ]]; then
HOMEBREW_ON_LINUX=1
fi
# On macOS, this script installs to /usr/local only.
# On Linux, it installs to /home/linuxbrew/.linuxbrew if you have sudo access
@yerffejytnac
yerffejytnac / throttle.applescript
Created October 6, 2020 22:43
Use Network Link Conditioner from command line
-- https://stackoverflow.com/questions/34876073/switch-network-link-conditioner-profiles-from-console-script/38991769
set mode to system attribute "mode"
tell application "System Preferences"
activate
set current pane to pane "com.apple.Network-Link-Conditioner"
delay 1
end tell
tell application "System Events"
@yerffejytnac
yerffejytnac / machine.js
Last active January 27, 2020 21:21
Generated by XState Viz: https://xstate.js.org/viz
const getCurrentPosition = (context, event) =>
new Promise((resolve, reject) => {
let position;
let options = null;
if (!context.position) {
return navigator.geolocation.getCurrentPosition(
p => {
const { coords, timestamp } = p;
position = { coords, timestamp };
resolve(position);
@yerffejytnac
yerffejytnac / ISSUE.md
Last active December 27, 2019 00:36
Hasura + custom postgres/postgis function

Hasura Postgres Custom Function Issue

I am experimenting with Hasura for the first time and wanted to toy around with a location-based app where a user could see a grid of locations from their current location.

Naturally, I referenced the blog posts https://blog.hasura.io/graphql-and-geo-location-on-postgres-using-hasura-562e7bd47a2f/ and https://blog.hasura.io/native-support-for-postgis-topology-operators-now-in-graphql-engine/ to get me started, and have kept things relatively the same as what the blog post outlined.

Original Function

-- SETOF table
CREATE TABLE user_venues (
let scroll = 0;
function scrollToEnd() {
setTimeout(function() {
if (scroll !== document.body.scrollHeight) {
scroll = document.body.scrollHeight;
window.scrollTo(0, document.body.scrollHeight);
scrollToEnd();
}
}, 3000);
}
@yerffejytnac
yerffejytnac / m3u8-to-mp4.md
Created December 8, 2017 19:59 — forked from tzmartin/m3u8-to-mp4.md
m3u8 stream to mp4 using ffmpeg

1. Copy m3u8 link

Alt text

2. Run command

echo "Enter m3u8 link:";read link;echo "Enter output filename:";read filename;ffmpeg -i "$link" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 $filename.mp4
@yerffejytnac
yerffejytnac / userChrome.css
Last active November 28, 2017 00:21
Firefox Dev Tools (v57+) Font Overrides/Styles
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document regexp("chrome://browser/content/devtools/**/.*"){
.devtools-monospace #root [role="treeitem"] {
font-family: 'Operator Mono SSm Lig', serif !important;
font-size: 11px !important;
line-height: 16px !important;
-moz-osx-font-smoothing: grayscale !important;
letter-spacing: initial !important;
}
}
@yerffejytnac
yerffejytnac / geolocation.js
Created July 1, 2015 14:56
Geolocation Service
import Ember from 'ember';
var geolocation;
if ('geolocation' in navigator) {
geolocation = navigator.geolocation;
}
export default Ember.Service.extend({
maximumAge: 30000,