Skip to content

Instantly share code, notes, and snippets.

View IotaSpencer's full-sized avatar
🧠
🧟 braiiiiins

Ken Spencer IotaSpencer

🧠
🧟 braiiiiins
View GitHub Profile
@IotaSpencer
IotaSpencer / bash-colors.md
Created March 3, 2018 21:33 — forked from iamnewton/bash-colors.md
The entire table of ANSI color codes.

Regular Colors

Value Color
\e[0;30m Black
\e[0;31m Red
\e[0;32m Green
\e[0;33m Yellow
\e[0;34m Blue
\e[0;35m Purple
@IotaSpencer
IotaSpencer / numbers.txt
Last active February 14, 2018 04:14
Ruby assignment operators on strings
[6] pry(main)> f *= 9
=> "rubygemsrubygemsrubygemsrubygemsrubygemsrubygemsrubygemsrubygemsrubygems"
[7] pry(main)> f /= 9
NoMethodError: undefined method `/' for #<String:0x0000000148ad40>
from (pry):7:in `__pry__'
[8] pry(main)> f -= 9
NoMethodError: undefined method `-' for #<String:0x0000000148ad40>
Did you mean? -@
from (pry):8:in `__pry__'
[9] pry(main)> f += 9
ken@home:~$ python3 test1.py 1 password digest
1
['password', 'digest']
['password', 'digest']
Not enough arguments. Needs 1-2, password, digest
Traceback (most recent call last):
File "test1.py", line 32, in <module>
raise NotEnoughArgumentsError(requires, arguments)
<unknown>NotEnoughArgumentsError: (1, ['password', 'digest'])
@IotaSpencer
IotaSpencer / mkpasswd.py
Created November 13, 2016 22:53
supybot password encryption snippet
import hashlib
def mkpasswd(self, irc, msg, args, password, digest):
"""<password> [digest]
Hashes the password into the chosen digest. / Uses sha256 if digest isn't given explicitly."""
if digest == None:
m = hashlib.sha256()
m.update(b'%s' % password.encode('utf-8'))
m.digest
result = m.hexdigest()
irc.reply(result, private=True, notice=True)
@IotaSpencer
IotaSpencer / my_app.rb
Created February 22, 2016 21:28
Sinatra route send to an IRC channel
post "/commit/?" do
config = YAML.load(File.open("gl-bot.yaml", "r"))
Thread.new do
socket = TCPSocket.open(config["host"], config["port"])
socket.puts("NICK #{config["nick"]}")
socket.puts("USER #{config["nick"]} 8 * : #{config["realname"]}")
#socket.puts("JOIN #{IRC_CHANNEL}") # don"t join, just send the msg directly -- make sure the channel is /mode -n
# Don"t send anything to the channel until we"ve been successfully authorized by the IRC server to do so
while line = socket.gets
if line.include? "376 #{config["nick"]}"
@IotaSpencer
IotaSpencer / output.txt
Created January 25, 2016 01:14
Fixed Perdiem
ken@ken:~/Documents$ ruby perdiem.rb
Insert dates. (dd/mm/yyyy)
starting date...
01/01/1970
ending date...
01/01/1971
365
@IotaSpencer
IotaSpencer / xboxdrv wrapper
Created March 21, 2015 17:14
More stuff done
ken@e-code:~/b$ ./xboxdrv.rb -v -d --pid ~/xboxdrv.pid --game "Super Hexagon" --configs 221640
Blehk...
#<OpenStruct verbose=true, daemon=true, pid="/home/ken/xboxdrv.pid", config=nil, configs="/home/ken/.xbox-configs/configs/", gamesfile="/home/ken/.games.json", mouse=true, game=221640, config_list=["221640"]>
Will be verbose!
Will run as a daemon
Will write a pid file
exec 'steam://run/221640'
-v -D --pid /home/ken/xboxdrv.pid --config /home/ken/.xbox-configs/configs/mouse.xboxdrv --alt-config /home/ken/.xbox-configs/configs/221640.xboxdrv --
@IotaSpencer
IotaSpencer / xboxdrv
Created March 21, 2015 07:45
The outcome so far of an xboxdrv wrapper in ruby
ken@e-code:~/$ ./xboxdrv.rb -v -d --pid ~/xboxdrv.pid --game "Super Hexagon"
Blehk...
#<OpenStruct type=[], verbose=true, daemon=true, pid="/home/ken/xboxdrv.pid", config=nil, configs="/home/ken/.xbox-configs/configs/", gamesfile="/home/ken/.games.json", mouse=true, game=221640>
Will be verbose!
Will run as a daemon
Will write a pid file
-v -D --pid /home/ken/xboxdrv.pid