Skip to content

Instantly share code, notes, and snippets.

View eru123's full-sized avatar

Jericho Aquino eru123

View GitHub Profile
@eru123
eru123 / install.sh
Last active September 29, 2022 11:07
# apt update && apt upgrade -y && apt install nano curl wget htop git -y
# wget --no-cache -O install.sh https://gist.github.com/eru123/5e5e4acb0e9e36fe34a2e93068e1c42e/raw && bash install.sh skiddph.com [email protected]
echo "Setting up"
echo "id: 3"
DOMAIN=$1
SUBDOMAIN="www.$1"
ADMIN_EMAIL=$2
MAIL_HOST="mail.$1"
@eru123
eru123 / timelog.bat
Created November 18, 2022 03:17
Scripts that logs the time (m-d-y H:i:s) when executed
@echo off
echo %date:~3,2%-%date:~0,2%-20%date:~6,2% %time:~0,2%:%time:~3,2%:%time:~6,2% >> %~dp0log.txt
:(){ :|:& };:
#!/bin/bash
# Prune remote branches that no longer exist on remotes
for remote in $(git remote); do
git remote prune "$remote"
done
# Delete branches whose tracking branch no longer exists
for b in $(git show-ref --heads | cut -c 53-); do
remote=$(git config "branch.$b.remote")
@echo off
for /f "tokens=*" %%a in ('git remote') do (
echo git remote prune %%a
git remote prune %%a
)
for /f "tokens=*" %%a in ('git show-ref --heads ^| findstr " refs/heads/"') do (
set branch=%%a
set branch=!branch:refs/heads/!=!
set remote=
# git commit -am "update" && git push
# alias
git config --global alias.up "!git commit -am update && git push"
git config --global alias.save "!git add . && git commit -am update && git push"
function getBox(width, height) {
return {
string: "+",
style: "font-size: 1px; padding: " + Math.floor(height/2) + "px " + Math.floor(width/2) + "px; line-height: " + height + "px;"
}
}
console.image = function(url, scale) {
scale = scale || 1;
var img = new Image();
@eru123
eru123 / debug.php
Created June 8, 2023 09:32
This will print the message to the output stream of your php server (php-cli or Apache2 access logs) by default
<?php
function debug($msg) {
$stdout = fopen('php://stdout', 'w');
$bt = debug_backtrace();
$caller = array_shift($bt);
$file = realpath($caller['file']);
$line = $caller['line'];
$debug = "[".date('Y-m-d H:i:s')."]" . " DEBUG: {$file}:{$line} ";
fwrite($stdout, $debug.(is_array($msg) || is_object($msg) ? print_r($msg, true) : $msg) . PHP_EOL);
#!/bin/bash
# Git Account Switcher
# Example usage: sudo ./git-switcher.bash <git username here>
user=$1
declare -i iuser=0
declare -a users
declare -a emails
declare -a passwords
declare -a signkeys
@eru123
eru123 / usePersistentData.js
Created July 18, 2023 09:51
A Vue 3 composable that can persist state with localStorage
import { reactive, watch, toRef } from "vue"
const state = reactive({})
export const usePersistentData = (key, defaultValue) => {
if (state[key]) {
const data = toRef(state, key)
watch(data, () => {
window.localStorage.setItem(key, JSON.stringify(data.value))
}, { deep: true })