lsof -i :[PORT]
kill -9 [PID]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import floor, fabs | |
from PIL import Image, ImageSequence | |
def transform_image(original_img, crop_w, crop_h): | |
""" | |
Resizes and crops the image to the specified crop_w and crop_h if necessary. | |
Works with multi frame gif and webp images also. | |
args: | |
original_img is the image instance created by pillow ( Image.open(filepath) ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
apt update | |
apt install python3-pip -y | |
apt install libjpeg8-dev zlib1g-dev libtiff-dev libfreetype6 libfreetype6-dev libwebp-dev libopenjp2-7-dev libopenjp2-7-dev -y | |
pip3 install pillow --global-option="build_ext" --global-option="--enable-zlib" --global-option="--enable-jpeg" --global-option="--enable-tiff" --global-option="--enable-freetype" --global-option="--enable-webp" --global-option="--enable-webpmux" --global-option="--enable-jpeg2000" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Option: From the Terminal | |
# Get internal ip addresses | |
hostname -I | |
# Get the ip address which is starting with 10.XXX.XXX.XXX from the output. | |
# And place it in the command below. | |
wget --bind-address=10.XXX.XXX.XXX https://example.com | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig) | |
sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');") | |
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ] | |
then | |
>&2 echo 'ERROR: Invalid installer signature' | |
sudo rm composer-setup.php |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Don't forget to run "sudo chmod a+x filename" to give this script neccessary permissions in order to work properly. | |
osascript <<EOD | |
tell application "Google Chrome" | |
set windowList to every window | |
repeat with aWindow in windowList | |
set tabList to every tab of aWindow | |
repeat with atab in tabList |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig) | |
sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');") | |
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ] | |
then | |
>&2 echo 'ERROR: Invalid installer signature' | |
sudo rm composer-setup.php |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertMinsToHours(input) { | |
if (typeof input != 'number') { | |
return '' | |
} | |
const m = input < 0 ? -1 : 1 | |
const k = Math.floor(input*m % 60) | |
const b = Math.floor(input*m / 60) | |
return (m==-1 ? '-' : '+') + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Creates a new javascript object from bigger javascript object by taking certain properties from it. | |
* | |
* @param {object} input - Main javascript object | |
* @param {array} keys - Keys that will be used to create a new object. | |
*/ | |
Object.prototype.extract = function extract(input, keys) { | |
return Object.prototype.toString.call(input) === '[object Object]' | |
? Object.keys(input) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove -nodes if you want to protect the cert with a password. | |
openssl req -x509 -newkey rsa:4096 -keyout sample-key.pem -out sample-cert.pem -days 365 -subj '/CN=sample.com/O=Sample Corp./C=US' -nodes |