Skip to content

Instantly share code, notes, and snippets.

View FormData Object
->Setting processData to false lets you prevent jQuery from automatically transforming the data into a query string.
And Setting the contentType to false is imperative.
Refference link: https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects
//01// File Upload using FormData Object in Javascript
Syntax:
var formData = new FormData(); // Currently empty
formData.append(name, value); // custom text field where key/value pair
formData.append(name, value, filename); // Custom file uploading
@weisk
weisk / script.sh
Created Apr 9, 2021 — forked from xphere/script.sh
Bash script skeleton
View script.sh
#!/bin/bash
settings() {
SCRIPT_DIR="$(dirname "$0")"
}
main() {
request $@
settings
run
@weisk
weisk / email_parse_url.py
Created Apr 1, 2021 — forked from aptgetupgrade/email_parse_url.py
code to poll emails from an IMAP email server and post these to wallabag
View email_parse_url.py
# Read email in inbox, look for any URLs and update them to wallabag, delete email if URLs found in it.
# Built from various internet sources. Final code donated under GPL v3 by Github user aptgetupgrade
# Tested using python 2. Could be run as part of a crontab, e.g. every 5 mins.
#
import sys
import imaplib
import getpass
import email
import email.header
import datetime
@weisk
weisk / multiple_ssh_setting.md
Created Mar 29, 2021
Multiple SSH keys for different github accounts
View multiple_ssh_setting.md

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@weisk
weisk / get_test.sh
Created Mar 29, 2021
Continuously make requests to a server with curl and measure the request frequency with pv
View get_test.sh
#!/usr/sbin/env bash
while true; do
curl $1 -s > /dev/null
echo .
done | pv -l > /dev/null
@weisk
weisk / levenshtein.js
Created Mar 29, 2021
Levenshtein distance between two given strings implemented in JavaScript and usable as a Node.js module
View levenshtein.js
/*
Copyright (c) 2011 Andrei Mackenzie
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
@weisk
weisk / README.md
Created Mar 24, 2021 — forked from mdp/README.md
Clone/Sync all gists
View README.md

Clone all your gists

Stolen from mbostok and improved upon

node cloneAllGists.js username token [outputDir]

@weisk
weisk / notes.md
Created Mar 24, 2021 — forked from routeback/notes.md
SEC487 Notes
View notes.md
View web server log analysis cheat sheet
# get total requests by status code
awk '{print $9}' /var/log/nginx/access.log | sort | uniq -c | sort -rn
# get top requesters by IP
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head | awk -v OFS='\t' '{"host " $2 | getline ip; print $0, ip}'
# get top requesters by user agent
awk -F'"' '{print $6}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head
# get top requests by URL
@weisk
weisk / delete_git_submodule.md
Created Mar 15, 2021 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.
View delete_git_submodule.md

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule