Skip to content

Instantly share code, notes, and snippets.

@daehee
daehee / .gitignore
Created Jan 8, 2021
nim .gitignore
View .gitignore
# ignore files with no extention:
*
!*/
!*.*
# normal ignores:
*.exe
nimcache
*.pdb
*.ilk
View gist:5cbbe44737b08b077782426307e24ec4
func PrintMemUsage() {
var m runtime.MemStats
runtime.ReadMemStats(&m)
// For info on each, see: https://golang.org/pkg/runtime/#MemStats
fmt.Printf("Alloc = %v MiB", bToMb(m.Alloc))
fmt.Printf("\tTotalAlloc = %v MiB", bToMb(m.TotalAlloc))
fmt.Printf("\tSys = %v MiB", bToMb(m.Sys))
fmt.Printf("\tNumGC = %v\n", m.NumGC)
}
View gist:45fbeb9df39552b6f561b48dd8cd0eab
if path == "~" {
// In case of "~", which won't be caught by the "else if"
path = dir
} else if strings.HasPrefix(path, "~/") {
// Use strings.HasPrefix so we don't match paths like
// "/something/~/something/"
path = filepath.Join(dir, path[2:])
}
View gist:859c6a3d9f14b0263665a5ab58f0692e
func orDone(done, c <-chan interface{}) <-chan interface{} {
valStream := make(chan interface{})
go func() {
defer close(valStream)
for {
select {
case <-done:
return
case v, ok := <-c:
if ok == false {
@daehee
daehee / unfollow.js
Created Oct 21, 2020 — forked from migftw/unfollow.js
LinkedIn Unfollow Script
View unfollow.js
function isHidden(el) {
if(el) return (el.offsetParent === null);
else return false;
}
TotalUnfollowed = 0;
var LoadingAnimation = document.getElementsByClassName("initial-load-animation")[0];
var CatchLoadingAnimation = setInterval(function(){
if(isHidden(LoadingAnimation) == true) {
@daehee
daehee / main.go
Created Sep 28, 2020
chromedp - get response headers
View main.go
// https://stackoverflow.com/a/56602780
package main
import (
"context"
"io/ioutil"
"log"
"os"
"time"
@daehee
daehee / go-sqlite3_database_is_locked.go
Created Sep 14, 2020 — forked from mrnugget/go-sqlite3_database_is_locked.go
Program that tests the concurrency issues with go-sqlite3. This will create two tables: `products` and `users`. One goroutine will repeatedly read from the `products` table in N fresh goroutines. At the same time ONE goroutine writes to the other table.
View go-sqlite3_database_is_locked.go
package main
import (
"database/sql"
"fmt"
"log"
"math/rand"
"sync"
"time"
@daehee
daehee / converter.sh
Created Feb 20, 2020 — forked from xdavidhu/converter.sh
Converter.sh, a bash script to convert domain lists to resolved IP lists without duplicates
View converter.sh
#!/bin/bash
# Converter.sh by @xdavidhu
# This is a script inspired by the Bug Hunter's Methodology 3 by @Jhaddix
# With this script, you can convert domain lists to resolved IP lists without duplicates.
# Usage: ./converter.sh [domain-list-file] [output-file]
echo -e "[+] Converter.sh by @xdavidhu\n"
if [ -z "$1" ] || [ -z "$2" ]; then
echo "[!] Usage: ./converter.sh [domain-list-file] [output-file]"
exit 1
@daehee
daehee / domainstoips.sh
Created Feb 20, 2020
Convert list of domains to IPs using dig
View domainstoips.sh
#!/bin/sh
# call with domaintoips.sh <domain> <list of subdomains.txt>
ulimit -n 800000
while read -r domain; do dig +short $domain | grep -v '[[:alpha:]]' | sort -u >> $1-ipf.txt; done < $2
cat $1-ipf.txt | anew $1-ipz.txt
@daehee
daehee / cleanips.sh
Created Feb 20, 2020
strip out CDNs from list of IPs (cloudflare, akamai, incapsula, sucuri)
View cleanips.sh
#!/bin/bash
# Call with domain name <e.g. tesla.com> as arg $1
scanned () {
cat $1 | sort -u | wc -l
}
## segregating cloudflare IP from non-cloudflare IP
iprange="173.245.48.0/20 103.21.244.0/22 103.22.200.0/22 103.31.4.0/22 141.101.64.0/18 108.162.192.0/18 190.93.240.0/20 188.114.96.0/20 197.234.240.0/22 198.41.128.0/17 162.158.0.0/15 104.16.0.0/12 172.64.0.0/13 131.0.72.0/22"
for ip in `cat $1-ipz.txt`; do