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
#!/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
# 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/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
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
const os = require('os') | |
const crypto = require('crypto') | |
const path = require('path') | |
const fs = require('fs') | |
const util = require('util') | |
const puppeteer = require('puppeteer') | |
const libxml = require('libxmljs') | |
const dayjs = require('dayjs') | |
// generates static html files for server side rendering |
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
# check if user doesn't exist | |
function user_doesnt_exist { | |
if id -u "$1" >/dev/null 2>&1; then | |
return 1 | |
else | |
return 0 | |
fi | |
} | |
# usage. do something if the user abc doesn't exist. |
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
mongodb://$user:$password@localhost:27027/?authMechanism=DEFAULT&authSource=$dbname | |
mongodb://$user:$password@$host1:27017,$host2:27017/?replicaSet=rs0&authMechanism=DEFAULT&authSource=$dbname |