Skip to content

Instantly share code, notes, and snippets.

Avatar
Brewing coffee

Abe Estrada AbeEstrada

Brewing coffee
View GitHub Profile
@AbeEstrada
AbeEstrada / index.mjs
Last active January 5, 2023 00:05
Privnote + AWS Lambda
View index.mjs
import { S3Client, PutObjectCommand, GetObjectCommand, DeleteObjectCommand } from "@aws-sdk/client-s3";
const s3Client = new S3Client({ region: "us-east-1" });
const Bucket = "BUCKET_NAME_GOES_HERE";
export const handler = async (event) => {
let statusCode = 200;
let body = ``;
if (event.requestContext.http.method === "POST") {
@AbeEstrada
AbeEstrada / gist:382d2fdd9ae41e75a81c9d2416745485
Last active April 17, 2022 02:01
macOS: Disable Chrome CORS
View gist:382d2fdd9ae41e75a81c9d2416745485
open -a "Google Chrome" --args --user-data-dir="/tmp/chrome_dev_test" --disable-web-security
View oneLiners.js
console.log(JSON.stringify(data ?? null, null, 2))
[...Array(10).keys()]
const sleep = ms => new Promise(res => setTimeout(res, ms));
const sum = arr => arr.reduce((sum, n) => sum + n, 0)
const avg = arr => sum(arr) / arr.length
@AbeEstrada
AbeEstrada / axiosDownloadImage.js
Created April 12, 2022 21:33
Node axios download image
View axiosDownloadImage.js
import { writeFile } from "fs/promises";
import axios from "axios";
const main = async () => {
try {
const response = await axios.get(`${FILE_URL}`, { responseType: "arraybuffer" });
try {
await writeFile(`./${FILE_NAME}.jpg`, response.data);
} catch(err) {
console.log(err);
View formatDate.js
const formatDate = (date) => {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
const seconds = String(date.getSeconds()).padStart(2, "0");
return `${[year, month, day].join("/")} ${[hours, minutes, seconds].join(":")}`;
};
@AbeEstrada
AbeEstrada / last.sh
Created January 22, 2022 03:25
ffmpeg: get last frame from video
View last.sh
ffmpeg -sseof -3 -i input.mp4 -update 1 -q:v 1 last.jpg
@AbeEstrada
AbeEstrada / first.sh
Created January 22, 2022 03:11
ffmpeg: get first frame from video
View first.sh
ffmpeg -i input.mp4 -ss 00:00:00 -frames:v 1 first.jpg
@AbeEstrada
AbeEstrada / details.html
Created January 5, 2022 00:29
Hugo Shortcode: Details
View details.html
{{ if .Inner }}<details {{ if eq (.Get "open") "true" }}open{{ end }}>
{{ with .Get "title" }}<summary>{{.}}</summary>{{ end }}
{{ .Inner | markdownify }}
</details>{{ end }}
@AbeEstrada
AbeEstrada / Monokai.sublime-color-scheme
Last active April 9, 2022 01:48
Sublime Text Monokai Color Scheme
View Monokai.sublime-color-scheme
// Documentation at https://www.sublimetext.com/docs/color_schemes.html
{
"variables": {},
"globals": {
"background": "#19171a",
"selection": "#333",
"selection_border": "#333",
"stack_guide": "var(grey)",
"active_guide": "var(purple)",
"line_highlight": "var(black3)",
View .zshrc
export PATH=$HOME/.bin:/usr/local/bin:/usr/local/sbin:$PATH
export ZSH=$HOME/.oh-my-zsh
# ZSH_THEME="simple"
ZSH_THEME=""
NVM_LAZY_LOAD=true
ZSH_AUTOSUGGEST_USE_ASYNC=true
ZSH_AUTOSUGGEST_STRATEGY=(completion history)