Skip to content

Instantly share code, notes, and snippets.

View sydneyitguy's full-sized avatar

seb's sydneyitguy

  • Seoul, Korea
View GitHub Profile
@sydneyitguy
sydneyitguy / refresh_and_screenshot.sh
Created April 19, 2020 15:24
Refresh Chrome every 120 seconds and take screenshot
#!/bin/sh
exec <"$0" || exit; read v; read v; exec /usr/bin/osascript - "$@"; exit
# The line above allows the rest of the file to be written in plain AppleScript.
repeat 99999999 times
tell application "Google Chrome"
activate
tell application "System Events"
tell process "Google Chrome"
keystroke "r" using {command down, shift down}
@sydneyitguy
sydneyitguy / steem-witness.sh
Created March 17, 2020 15:56
Steem Witness Stackscript
# MARK: - System updates
sudo update-locale LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=en_US.UTF-8
sudo locale-gen en_US.UTF-8
sudo apt-get update && sudo apt-get -y upgrade && sudo apt-get -y dist-upgrade && sudo apt-get -y autoremove
git clone https://github.com/someguy123/steem-docker.git
cd ~/steem-docker
./run.sh dlblocks
./run.sh install_docker
@sydneyitguy
sydneyitguy / rails_new.sh
Created March 11, 2020 03:15
New Rails 6 Project
rails new AppName -T -d=postgresql --skip-action-cable --skip-coffee --skip-spring --skip-turbolinks
@sydneyitguy
sydneyitguy / instagram.js
Created January 22, 2020 09:45
Get Instagram Followers
const random_wait_time = (waitTime = 300) => new Promise((resolve, reject) => {
setTimeout(() => {
return resolve();
}, Math.random() * waitTime);
});
const get_followers = async(userId, userFollowerCount) => {
let userFollowers = [],
batchCount = 20,
actuallyFetched = 20,
@sydneyitguy
sydneyitguy / eth.rb
Created January 8, 2020 16:42
Ethereum address validation and normalization in Ruby
# Extracted from https://github.com/se3000/ruby-eth
#
# Dependencies:
# - gem 'digest-sha3'
# - gem 'rlp'
#
# Usage:
# - Eth::Utils.valid_address?('0x4Db7569F90bd836294B11c8b08B853d2de499Ced')
# => true
# - Eth::Utils.format_address('0x4db7569f90bd836294b11c8b08b853d2de499ced')
@sydneyitguy
sydneyitguy / postgres_upgrade.sh
Last active August 19, 2019 07:47
PostgreSQL upgrade from 10 to 11
sudo apt install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
psql --version
sudo apt update
sudo apt install postgresql-11
pg_lsclusters
sudo pg_dropcluster 11 main --stop
@sydneyitguy
sydneyitguy / countries+languages.md
Last active June 11, 2019 07:00
Country & Language Codes

Countries

  • AW: Aruba
  • AF: Afghanistan
  • AO: Angola
  • AI: Anguilla
  • AX: Åland Islands
  • AL: Albania
  • AD: Andorra
  • AE: United Arab Emirates
  • AR: Argentina
@sydneyitguy
sydneyitguy / detectExtension.js
Last active November 23, 2018 07:05
Detect whether a chrome extension is installed or not
export const isChrome = function() {
return /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
}
export const detectExtension = function(extensionId, callback) {
const xobj = new XMLHttpRequest();
xobj.overrideMimeType("application/json");
xobj.open('GET', 'chrome-extension://' + extensionId + '/manifest.json', true);
xobj.onreadystatechange = function () {
if (xobj.readyState === 4) {
@sydneyitguy
sydneyitguy / pg_index.md
Last active November 17, 2018 19:42
Postgresql Index Maintenance

Index size/usage statistics

Table & index sizes along which indexes are being scanned and how many tuples are fetched. See Disk Usage for another view that includes both table and index sizes.

Works with PostgreSQL >=8.1

SELECT
    t.tablename,
    indexname,
    c.reltuples AS num_rows,
@sydneyitguy
sydneyitguy / eth-key.rb
Last active August 10, 2018 05:30
Generate a Ethereum key pair / Get public key from a given private key (if a parameter passed)
#!/usr/bin/env ruby
# gem install digest-sha3
require 'openssl'
require 'digest/sha3'
require 'open-uri'
require 'json'
def decode(s, base)
syms = '0123456789abcdef'.freeze