Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
echo '-----> update <-----'
apt update
echo '-----> upgrade <-----'
apt --yes upgrade
echo '-----> dist-upgrade <-----'
apt --yes dist-upgrade
#!/usr/bin/env ruby
password_length = (ARGV[0] || 16).to_i
symbol_count = (ARGV[1] || 2).to_i
alphanumerics = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
symbols = "~`!@##$%^&-=_+()[]{};:,.".chars
50.times do
password = password_length.times.collect { alphanumerics[Random.rand(0...alphanumerics.length)] }.join
symbol_count.times { password[Random.rand(0...password.length)] = symbols[Random.rand(0...symbols.length)] }
@bitaxis
bitaxis / µstamp.py
Last active December 14, 2018 19:23
import datetime
import time
class µstamp(datetime.datetime):
def __init__(self, year, month, day, hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold=0):
super().__init__()
def __add__(self, other):
if type(other) is int: other = datetime.timedelta(days=other)
@bitaxis
bitaxis / cpd.sh
Last active October 31, 2018 13:04
For OS X, copy path of directory or file to clipboard
function cpd {
if [ "$1" == "" ]; then printf `pwd` | pbcopy; return 0; fi
if [ -f "$1" ]; then printf `pwd`/$1 | pbcopy; return 0; fi
if [ ! -d "$1" ]; then echo "$1: No such directory"; return 1; fi
printf `pwd` | pbcopy
popd > /dev/null
}
@bitaxis
bitaxis / uuids.rb
Last active September 16, 2018 14:40
#!/usr/bin/env ruby
require "optparse"
require "uuidtools"
DEFAULT_COUNT = 20
RANDOM_FUNC = -> { $options[:count].times { puts UUIDTools::UUID.random_create } }
$options = {
count: DEFAULT_COUNT,
@bitaxis
bitaxis / test.uml
Last active October 26, 2017 05:44
@startuml
autonumber
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
@enduml
@bitaxis
bitaxis / gist:c6e849fb031154590551dacdf4b04e38
Created January 25, 2017 05:54
Hack to allow rvm install to work again on Yosemite 10.10.5
$ cd /opt/local/share/curl
$ sudo wget https://curl.haxx.se/ca/cacert.pem
$ sudo mv curl-ca-bundle.crt curl-ca-bundle.crt-original
$ sudo mv cacert.pem curl-ca-bundle.crt
$ rvm remove 2.4.0
$ rvm install 2.4.0 # some time later...
$ rvm use 2.4.0
$ ruby --version
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin14]
$ rvm gemset list
$ rvm install 2.4.0
Searching for binary rubies, this might take some time.
Found remote file https://rubies.travis-ci.org/osx/10.10/x86_64/ruby-2.4.0.tar.bz2
Checking requirements for osx_port.
Certificates in '/opt/local/etc/openssl/cert.pem' are already up to date.
Requirements installation successful.
ruby-2.4.0 - #configure
ruby-2.4.0 - #download
ruby-2.4.0 - #validate archive
ruby-2.4.0 - #extract
@bitaxis
bitaxis / gist:1406229
Created November 29, 2011 20:06
Update vim/bundles (per github.com/tpope/vim-pathogen)
#!/usr/bin/env python
import os
import os.path
for item in os.listdir('.'):
if not os.path.isdir(item): continue
os.chdir(item)
try:
print 'Updating "%s"...' % item
@bitaxis
bitaxis / gist:1377616
Created November 18, 2011 20:13
Rfactory
# Enhance rails.vim to work with test/factories/*_factory.rb
mkdir ~/.vim/macros && cat > ~/.vim/macros/rails.vim
:Rnavcommand factory test/factories spec/factories -glob=**/* -suffix=_factory.rb