Skip to content

Instantly share code, notes, and snippets.

View htr3n's full-sized avatar

Alex T. htr3n

View GitHub Profile
@htr3n
htr3n / macos-ramdisk.md
Last active May 1, 2024 10:16
Creating RAM disk in macOS

Built-in

diskutil erasevolume HFS+ 'RAM Disk' `hdiutil attach -nobrowse -nomount ram://XXXXX`

where XXXXX is the size of the RAM disk in terms of memory blocks.

Notes:

System

ssh-keygen -t rsa -b 4096 -C "hoang.huy.tran@gmail.com"
  • Windows PowerShell was built upon .NET and only worked on Windows
  • PowerShell Core is open sourced and built on .NET Core 2.x, work on Windows, Linux, macOS, ARM
@htr3n
htr3n / ubuntu-installation.md
Last active January 18, 2023 01:30
Installing and setting a working Ubuntu box

Software Management

Ubuntu/Linux Tools

APT (Ubuntu's Advanced Packaging Tool)

# installing a package
sudo apt install zsh
html,
body {
font-family: "Helvetica Neue", arial, sans-serif;
font-size: 16px;
line-height: 1.66em;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px;
}
@htr3n
htr3n / nodejs_base64.js
Created November 4, 2021 21:58
Create an object from a base64 encoded input JSON string in Node.js
const inputStr = ... ; // a base64 encoded string
if (inputStr) {
const decodedStr = Buffer.from(inputStr, 'base64').toString('utf8');
const result = JSON.parse(decodedStr);
if (result) {
// ...
}
}
@htr3n
htr3n / gulpfile.js
Last active October 31, 2021 23:36
Gulp 4 configuration SASS, PostCSS, autoprefixer, cssnano, sourcemaps
const gulp = require('gulp');
const sass = require('gulp-sass');
const postcss = require('gulp-postcss');
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');
const sourcemaps = require('gulp-sourcemaps');
const log = require('fancy-log');
const sassSourceFile = 'assets/scss/hyde-hyde.scss';
const outputFolder = 'static/css';
@htr3n
htr3n / Dockerfile
Last active October 19, 2021 05:49
node-canvas-lambda-container
FROM public.ecr.aws/lambda/nodejs:14
##
# Install necessary package for building Node.js Canvas
##
RUN yum -y update \
&& yum -y groupinstall "Development Tools" \
&& yum install -y nodejs gcc-c++ cairo-devel libjpeg-turbo-devel pango-devel giflib-devel zlib-devel librsvg2-devel
COPY *.js package* ./
{
"name": "node-canvas-lambda-container",
"version": "1.0.0",
"dependencies": {
"canvas": "^2.8.0"
},
"license": "MIT"
}
'use strict';
exports.handler = async (event, context, callback) => {
const result = {
body: null,
isBase64Encoded: false,
statusCode: 200
};
console.log('Received a render request event');
try {
@htr3n
htr3n / firefox-optimization.md
Last active July 24, 2021 13:55
Firefox Quantum optimization

about:config

  • Set browser.download.animateNotifications to False
  • Set security.dialog_enable_delay to 0
  • Set network.prefetch-next to False (Only on slow internet connections)
  • Set browser.newtabpage.activity-stream.feeds.telemetry to false
  • Set browser.newtabpage.activity-stream.telemetry to false
  • Set browser.ping-centre.telemetry to false
  • Set toolkit.telemetry.archive.enabled to false
  • Set toolkit.telemetry.bhrPing.enabled to false