Skip to content

Instantly share code, notes, and snippets.

View iamqiz's full-sized avatar
🍊
On vacation

iamqiz

🍊
On vacation
  • China
View GitHub Profile
@tobek
tobek / get-image-urls.js
Last active November 19, 2024 10:25
Save images from chrome inspector/dev tools network tab
/* open up chrome dev tools (Menu > More tools > Developer tools)
* go to network tab, refresh the page, wait for images to load (on some sites you may have to scroll down to the images for them to start loading)
* right click/ctrl click on any entry in the network log, select Copy > Copy All as HAR
* open up JS console and enter: var har = [paste]
* (pasting could take a while if there's a lot of requests)
* paste the following JS code into the console
* copy the output, paste into a text file
* open up a terminal in same directory as text file, then: wget -i [that file]
*/
#!/usr/bin/env python
# Linux usage: ./extract_tampermonkey_script.py "/home/<USER>/.config/<BROWSER>/Default/Local Extension Settings/<EXTENSION_ID>"
# i.e.: ./extract_tampermonkey_script.py "/home/foo/.config/google-chrome-beta/Default/Local Extension Settings/gcalenpjmijncebpfijmoaglllgpjagf"
# Mac usage: ./extract_tampermonkey_script.py "/Users/<USER>/Library/Application Support/Google/Chrome/Default/Local Extension Settings/<EXTENSION_ID>/"
# i.e.: ./extract_tampermonkey_script.py "/Users/foo/Library/Application Support/Google/Chrome/Default/Local Extension Settings/dhdgffkkebhmkfjojejmpbldmpobfkfo/"
import leveldb
import sys
import re
@EdisonLeeeee
EdisonLeeeee / pytorch_l2_normalize.py
Last active August 22, 2022 10:53
PyTorch equivalence for tf.nn.l2_normalize
import torch
import tensorflow as tf
########## PyTorch Version 1 ################
x = torch.randn(5, 6)
norm_th = x/torch.norm(x, p=2, dim=1, keepdim=True)
norm_th[torch.isnan(norm_th)] = 0 # to avoid nan
########## PyTorch Version 2 ################
norm_th = torch.nn.functional.normalize(x, p=2, dim=1)