Skip to content

Instantly share code, notes, and snippets.

View avin's full-sized avatar
🚀

Avin Lambrero avin

🚀
View GitHub Profile
@avin
avin / setup.md
Created March 30, 2024 10:03
Setup OpenWRT router with wireguard client

Preconfigure two interfaces wan and lan (if not already configured)

vi /etc/config/network

config interface 'wan'
        option device 'eth0'
        option proto 'dhcp'

config interface 'lan'
@avin
avin / App.tsx
Last active September 14, 2023 19:35
Slim form control
import React, {memo, useCallback, useEffect, useRef} from 'react';
import {useControl, useForm, useValidation} from './utils/useFormState';
// function useTraceUpdate(props: any) {
// const prev = useRef(props);
// useEffect(() => {
// const changedProps = Object.entries(props).reduce((ps: any, [k, v]) => {
// if (prev.current[k] !== v) {
// ps[k] = [prev.current[k], v];
// }
@avin
avin / template.ftl
Created May 19, 2023 07:50
Freemarker dump all data
<#-- JSON stringify -->
<#function stringify obj>
<#if !obj??>
<#return 'undefined'>
</#if>
<#if obj?is_date>
<#return '"' + obj?string("yyyy-MM-dd HH:mm:ss") + '"'>
</#if>
<#if obj?is_boolean || obj?is_number>
<#return obj?string>
@avin
avin / obs-auto-record.cmd
Created April 6, 2023 13:04
Periodical record in OBS
:: This script automates video recording using OBS
:: Disable command echoing and clear the screen
echo off
cls
:: Set the log file path
set logfile="C:\utils\autorecord\logs\automate.log"
echo log file will be %logfile%
// ==UserScript==
// @name SuperAjax for AppLinks
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Allow to do cross-domain AJAX requests
// @author You
// @run-at document-start
// @connect *
// @match https://localhost:5173/*
// @match https://web.rbsdev.com/front-utils/app-links/*
@avin
avin / needful-languages.js
Last active March 4, 2023 12:14
[TAMPERMONKEY] Only needful languages for AIPRM for ChatGPT
// ==UserScript==
// @name Only needful languages for AIPRM for ChatGPT
// @namespace http://tampermonkey.net/
// @version 0.1
// @author You
// @description try to take over the world!
// @match https://chat.openai.com/chat
// @icon https://www.google.com/s2/favicons?sz=64&domain=openai.com
// @grant none
// ==/UserScript==
@avin
avin / react-to-vue.md
Last active April 23, 2024 03:41
Migrate from React to Vue | Migrate from Vue to React
@avin
avin / coursehunter.tampermonkey.js
Created December 30, 2022 13:33
Coursehunter Separate Video Player
// ==UserScript==
// @name Coursehunter Separate Video Player
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://coursehunter.net/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
@avin
avin / Front End Security Basics.md
Last active March 10, 2023 09:39
codebashing courses summary

Reverse Tabnabbing

If tag with target="_blank" or uses window.open the hacker can replace original tab with opener.location="https://www.evilsite.com"; by opened page. It can be used in a phishing attack To fix it add rel="noopener" to and 'noopener' as third argument for window.open(: window.open('https://www.your.url','_blank','noopener')

HTTP Strict-Transport-Security (HSTS)

Add header Strict-Transport-Security: max-age=31536000; includeSubdomains; preload to make sure that the user once accessed the HTTPS version of the page will always be automatically redirected to it bypassing requests for HTTP.

@avin
avin / man.txt
Last active October 9, 2022 12:15
solve-algorithm-guide
Original text from: https://seanprashad.com/leetcode-patterns/
----
If input array is sorted then
- Binary search
- Two pointers
If asked for all permutations/subsets then
- Backtracking