Skip to content

Instantly share code, notes, and snippets.

View theohogberg's full-sized avatar
🛠️

Theo theohogberg

🛠️
View GitHub Profile
@theohogberg
theohogberg / random32x.tsx
Created March 25, 2024 21:26
TS: random32 * x hex generator
export const getRandom32x = (x: number = 1): string => {
if (x > 8) x = 8;
const uint32Array = new Uint32Array(x);
crypto.getRandomValues(uint32Array);
return uint32Array.reduce((a: string, v: number) => {
return a + v.toString(16).padStart(8, '0');
}, "");
};
import angular = require('angular');
function OnScrollToEndDirective($window, $document) {
'use strict';
return {
restrict: 'A',
link: link,
};
@theohogberg
theohogberg / get node terminal dimensions
Last active August 29, 2015 14:23
get node terminal width and height
function termRect () {
var tty = require('tty');
var width;
var height;
if(tty.isatty(1) && tty.isatty(2)) {
if(process.stdout.getWindowSize) {
width = process.stdout.getWindowSize(1)[0];
height = process.stdout.getWindowSize(1)[1];