Skip to content

Instantly share code, notes, and snippets.

Avatar
Brewing coffee

Abe Estrada AbeEstrada

Brewing coffee
View GitHub Profile
@AbeEstrada
AbeEstrada / users.php
Created Mar 6, 2012
Snippet: PHP Codeigniter Model
View users.php
<?php
class Users extends CI_Model {
function add($options=array()) {
// required values
if (!$this->_required(array('email'), $options)) return false;
// default values
$options = $this->_default(array('status'=>'active'), $options);
// qualification (make sure that we're not allowing the site to insert data that it shouldn't)
@AbeEstrada
AbeEstrada / gist:11e4511f9915b00f9714
Last active May 21, 2022
Cloudflare Email Protection Decoder in Go
View gist:11e4511f9915b00f9714
package main
import (
"bytes"
"strconv"
)
func cf(a string) (s string) {
var e bytes.Buffer
r, _ := strconv.ParseInt(a[0:2], 16, 0)
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 Apr 12, 2022
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 / Monokai.sublime-color-scheme
Last active Apr 9, 2022
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)",
@AbeEstrada
AbeEstrada / Adaptive.sublime-theme
Last active Apr 9, 2022
Sublime Text 4 Adaptive Theme
View Adaptive.sublime-theme
// Documentation at https://www.sublimetext.com/docs/themes.html
{
"variables": {},
"rules": [
// Hide sidebar heading
{
"class": "sidebar_heading",
"opacity": 0.0,
"font.size": 0,
"fg": "#101010",
@AbeEstrada
AbeEstrada / last.sh
Created Jan 22, 2022
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 Jan 22, 2022
ffmpeg: get first frame from video
View first.sh
ffmpeg -i input.mp4 -ss 00:00:00 -frames:v 1 first.jpg