Skip to content

Instantly share code, notes, and snippets.

View emdeeeks's full-sized avatar

Gareth Griffiths emdeeeks

View GitHub Profile
@emdeeeks
emdeeeks / dns.rb
Created February 5, 2019 16:29 — forked from honnix/dns.rb
play dns with ruby
#!/usr/bin/env ruby
# Copyright (c) 2009 Samuel Williams. Released under the GNU GPLv3.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@emdeeeks
emdeeeks / Gemfile
Created December 25, 2018 22:36 — forked from yaplik/Gemfile
Project for PV249 - Example SMTP Server with forwarding via smtp
source :rubygems
gem "eventmachine"
@emdeeeks
emdeeeks / emchat.rb
Created December 25, 2018 22:27 — forked from evilbetty/emchat.rb
Simple chat server with eventmachine
#!/usr/bin/env ruby
#
# Chat server attempt with Ruby and EventMachine.
#
# TODO:
#
# - Prevent chat from acting on \n (pressing enters in chat)
# - Handle (unexpected) disconnects properly (with unbind event).
# - Implement proper leaving with /quit.
@emdeeeks
emdeeeks / chat.rb
Created December 25, 2018 20:56 — forked from PurwadiPw/chat.rb
Simple chat ruby using eventmachine
#!/usr/bin/env ruby
require 'rubygems'
require 'eventmachine'
class Server
attr_accessor :connections
def initialize
@connections = []
@emdeeeks
emdeeeks / BlueBot.rb
Created October 23, 2018 21:29 — forked from waff1es/BlueBot.rb
the bot connects to discord and connects to whatever voice channel im in but it doesnt play any music ;_; |music_test works though
::RBNACL_LIBSODIUM_GEM_LIB_PATH = "C:/ruby22/libsodium.dll"
require 'discordrb'
require 'youtube-dl'
bot = Discordrb::Commands::CommandBot.new token: '<token here>', client_id: <client id here>, prefix: '|'
no_channel_warning = "You're not in a voice channel!"
bot.command :play do |event, songlink|
channel = event.user.voice_channel
@emdeeeks
emdeeeks / MerkleTree.js
Created October 12, 2018 16:50 — forked from amaranter/MerkleTree.js
Merkle Tree Implementation with Javascript and CryptoJS (SHA-256)
/**
* MerkleTree Implementation
* @version 1.0.0
* @author Ronny Amarante <[email protected]>
*/
var SHA256 = require("crypto-js/sha256");
function MerkleTree(transactions) {
this.transactions = transactions;
@emdeeeks
emdeeeks / merkle.rb
Created October 12, 2018 13:55 — forked from earlonrails/merkle.rb
Merkle tree in ruby
#!/usr/bin/env ruby
class Merkle
attr_accessor :key, :parent, :left, :right
def initialize(array, parent = nil)
@parent = parent
@key = array.join
load(array)
end
@emdeeeks
emdeeeks / PoW.py
Created October 1, 2018 14:49 — forked from daedalus/PoW.py
bitcoin PoW
#!/usr/bin/env python
# example of proof-of-work algorithm
import hashlib
import time
max_nonce = 2 ** 32 # 4 billion
def proof_of_work(header, difficulty_bits):
@emdeeeks
emdeeeks / block_chain.rb
Created September 30, 2018 15:39 — forked from altamic/block_chain.rb
Blockchain consisting of proof of work as from lian
#
# Ruby Example of the 'proof of work' explanation
# from https://en.bitcoin.it/wiki/Proof_of_work
#
# note: block data passed to do_work is simplified.
# bitcoin blockchain is more complex too.
#
require 'digest/sha2'