This file contains hidden or 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
#!/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, |
This file contains hidden or 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
source :rubygems | |
gem "eventmachine" |
This file contains hidden or 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
#!/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. |
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'eventmachine' | |
class Server | |
attr_accessor :connections | |
def initialize | |
@connections = [] |
This file contains hidden or 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
::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 |
This file contains hidden or 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
/** | |
* MerkleTree Implementation | |
* @version 1.0.0 | |
* @author Ronny Amarante <[email protected]> | |
*/ | |
var SHA256 = require("crypto-js/sha256"); | |
function MerkleTree(transactions) { | |
this.transactions = transactions; |
This file contains hidden or 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 'cgi' | |
require 'fileutils' | |
desc 'Generate a code review.' | |
# Uses rake code_review[master,qa] by default | |
task :code_review, :left_branch, :right_branch do |cmd, args| | |
left_branch = ( args[:left_branch] || "master" ) | |
right_branch = ( args[:right_branch] || "qa" ) | |
gp = GitParser.new(left_branch, right_branch) | |
gp.fancy_full_diff |
This file contains hidden or 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
#!/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 |
This file contains hidden or 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
#!/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): |
This file contains hidden or 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
# | |
# 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' |