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
require 'net/http' | |
require 'openssl' | |
# https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#general-api-information | |
# example curl request: | |
# `curl -H "X-MBX-APIKEY: #{api_key}" -X GET "https://api.binance.com/api/v3/account?recvWindow=100000×tamp=#{current_time}&signature=#{signature}"` | |
api_key = '<replace this with your api_key generated on binance>' | |
secret_key = '<replace this with your secret_key generated on binance>' |
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
# Active Nothing - Null Object Pattern | |
class Bot | |
FAUX_DATABASE = [{ id: 1, name: 'KITT' }, { id: 3, name: 'GERTY' }].freeze | |
attr_reader :name | |
def self.find(id) | |
row = FAUX_DATABASE.find{ |r| r[:id] == id } | |
return nil if row.nil? | |
new(row) |
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
--------r u b y | |
require 'csv' | |
require 'faker' | |
CSV.open("./users.csv", 'a+', write_headers: false) do |csv| | |
50_000.times do |n| | |
csv << [n, Faker::FunnyName.two_word_name, Faker::Internet.email, Faker::Address.city] | |
end |
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
SELECT relname, last_vacuum, last_autovacuum, last_analyze, last_autoanalyze | |
FROM pg_stat_all_tables | |
WHERE schemaname = 'public'; |
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
#!/bin/bash | |
# | |
# example usage | |
# | |
# > random_password 10 | |
if [ $# -lt 1 ]; then | |
echo "This command requires an integer for the password length" | |
else | |
echo -n "password: "; base64 /dev/urandom | head -c $1 |
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
#!/bin/bash | |
rand=$RANDOM | |
const=$((1 + rand % 100)) | |
yellow="\033[33;40m" | |
none="\033[0m" | |
function game { | |
echo -e $yellow"Welcome to the guessing game!"$none | |
echo |
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
#!/bin/bash | |
for i in $(ls) | |
do | |
without=$(cat $i | wc -c) | |
with=$(cat -vet $i | wc -c) | |
echo -n "chars including special chars in: $i " | |
echo "$with - $without" | |
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
SELECT count(*) | |
FROM pg_stat_activity | |
WHERE pid != pg_backend_pid() | |
AND usename = current_user; |
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
SELECT table_name | |
FROM INFORMATION_SCHEMA.views | |
WHERE table_schema = ANY (current_schemas(false)); |
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
#!/bin/bash | |
# | |
# example usage | |
# | |
# > mem 0.1 100 | |
for i in `seq 1 $2` | |
do | |
free -m | |
cat /proc/meminfo | grep MemFree |