This file contains 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 "open-uri" | |
require "json" | |
require "htmlentities" | |
module URLTitle | |
class Twitter | |
class << self | |
def fetch_tweet(id, token) |
This file contains 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 "socket" | |
require "openssl" | |
unless ARGV.size == 3 | |
puts "Usage: #$0 <serverhost> <serverport> <listensocketpath>" | |
exit | |
end | |
class NanoBouncer |
This file contains 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 "socket" | |
require "openssl" | |
sock = TCPSocket.new(ARGV[0], ARGV[1].to_i) | |
ctx = OpenSSL::SSL::SSLContext.new | |
ctx.set_params(verify_mode: OpenSSL::SSL::VERIFY_PEER) | |
io = OpenSSL::SSL::SSLSocket.new(sock, ctx).tap do |socket| | |
socket.sync_close = true |
This file contains 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
#!/bin/sh | |
exec tail -n +3 $0 | |
# This file provides an easy way to add custom menu entries. Simply type the | |
# menu entries you want to add after this comment. Be careful not to change | |
# the 'exec tail' line above. | |
menuentry "Ubuntu 20.04 ISO" { | |
set root=(hd0,gpt2) | |
set isofile="/ubuntu-20.04.3-desktop-amd64.iso" | |
loopback loop $isofile | |
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile persistent persistent-path=/ub2004-1/ fsck.mode=skip quiet splash -- |
This file contains 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
class ProcCaller | |
def add(&block) | |
(@procs ||= []) << block | |
end | |
def callem! | |
@procs.map do |p| | |
Thread.new { p.call } | |
end.each &:join |
This file contains 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/ruby -w | |
require "warning" | |
def foo(regexp) | |
end | |
Warning.ignore(:ambiguous_slash) | |
foo /why you do dis/ | |
# still prints: |
This file contains 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
def luhn_calc(num) | |
sum = 0 | |
num.to_s.gsub(/\s/, "").each_char.to_a.reverse.each_with_index do |d,i| | |
multiplier = 2 - (i&1) | |
sum += (multiplier * d.to_i).divmod(10).reduce(:+) | |
end | |
sum * 9 % 10 | |
end |
This file contains 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
# encoding: UTF-8 | |
# ----- Settings: ----- | |
# what machine's MPC is monitored, and on which port | |
MPC_HOST = "localhost:13579" | |
LOGFILE = "log.txt" | |
PRINTLOG = false # also print to console? | |
ENDTOLERANCE = 0.95 # seen 95% = seen all of it | |
INTERVAL = 5 # seconds to wait after each status update | |
OUTPUT_CHARSET = "CP850" # this is a fix for windows's cmd.exe |
This file contains 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 "nokogiri" | |
require "open-uri" | |
filename = "4k_monitors.txt" | |
old_names = File.readlines(filename).map(&:strip) rescue [] | |
page = Nokogiri::HTML(open("https://www.jimms.fi/fi/Product/List/000-1HJ/oheislaitteet--naytot--g-sync?ob=6&fq=4k")) |
This file contains 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
# frozen-string-literal: true | |
class Roda | |
module RodaPlugins | |
# Treats any string matchers with a trailing slash ("/") almost like | |
# the slash wasn't there, but GET requests to that path without the | |
# slash are redirected to the path with a trailing slash. | |
# | |
# Example: | |
# |
NewerOlder