This file contains 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
""" | |
Some solution to the 2 eggs problem. Given N floors, you find the first | |
floor and find how many steps you have to go up. | |
""" | |
import math | |
def find_roots_of_quadratic_equation(a, b, c): | |
""" | |
(-b +_ sqrt(b2 - 4ac))/2a |
This file contains 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
// Assume you have to read something like: | |
// 3 - number of test cases that follow | |
// 3 - limit in this test case. | |
// 1 2 3 - test case data | |
// 4 | |
// 1 2 3 4 | |
const readline = require('readline') | |
const rl = readline.createInterface({ | |
input: process.stdin, |
This file contains 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
#!/usr/bin/env bash | |
# Script stores the current IP in a tmp file and later checks if it changed when run. POSTS to a Telegram bot. | |
# Check how you can create a bot at https://core.telegram.org/bots | |
old_ip=`cat /tmp/currentip` | |
current_ip=`wget -qO- https://ipecho.net/plain` | |
if [ $current_ip != $old_ip ]; then | |
curl -s -X POST https://api.telegram.org/bot<TELEGRAM_BOT_TOKEN>/sendMessage -d chat_id=<CHAT_ID> -d text="Machine changed IP from: ${old_ip} to ${current_ip}" |
This file contains 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
#!/usr/bin/env bash | |
# This will update all git repos in your present working directory to target: branch | |
# Inspired from: https://stackoverflow.com/a/31994428 | |
read -p 'Branch to switch to: ' branch | |
for d in */; do cd $d; git stash; git checkout $branch; (git pull origin $branch); cd ..; done |
This file contains 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
# shortform git commands | |
alias g='git' | |
# push changes to an empty git repository for the first time | |
git push --set-upstream origin master | |
# Remove + and - from start of diff lines | |
git diff --color | sed "s/^\([^-+ ]*\)[-+ ]/\\1/" | less -r | |
# clear out git hooks |
This file contains 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 openstack import connection | |
conn = connection.Connection( | |
auth_url=configs['auth']['OS_AUTH_URL'], | |
project_name=configs['auth']['OS_PROJECT_NAME'], | |
username=configs['auth']['OS_USERNAME'], | |
password=configs['auth']['OS_PASSWORD'], | |
project_domain_name=configs['auth']['OS_PROJECT_DOMAIN_NAME'], | |
user_domain_name=configs['auth']['OS_USER_DOMAIN_NAME'] | |
) |
This file contains 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
[ | |
{ | |
"username":"test", | |
"pass":"testpass" | |
}, | |
{ | |
"username":"admin", | |
"pass": "adminpass" | |
}, | |
] |