Skip to content

Instantly share code, notes, and snippets.

View flori's full-sized avatar

Florian Frank flori

View GitHub Profile
@flori
flori / downloadPGN.js
Last active August 18, 2022 15:48
Download all imported PGNs from lichess
var downloadTime = 3 * 1000
function getIds() {
var ids = []
jQuery('.game-row__overlay').each(
function () {
var h = jQuery(this).attr('href')
var id = h.match(/[a-z0-9]+/i)[0]
ids.push(id)
#!/usr/bin/env ruby
require 'set'
$places = Set[]
$distance = Hash.new(Float::INFINITY)
for distance in DATA
/^(?<from>\w+) to (?<to>\w+) = (?<distance>\d+)/ =~ distance
$places << from << to
@flori
flori / fib.rb
Created March 22, 2016 15:24
Fibonacci Generator in Ruby
$fib = Enumerator.new do |e|
a, b = 0, 1
loop do
e.yield a
b, a = a + b, b
end
end
def $fib.[](n)
each_with_index.find { |x, i| i == n }.first
module FloatRange
def each
if Float === self.begin
current = self.begin
if exclude_end?
while current < self.end
yield current
current = current.next_float
end
else
(ffr@ffr:mysql [master] ❷ ->0)$ cat /usr/local/opt/mysql/my.cnf
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,ALLOW_INVALID_DATES
>> token = Tins::Token.new(bits: 128)
# => "ilTeQJ8zNHGo71cGnZiIfe"
>> token.length
# => 22
>> token.bits
# => 130
>> token = Tins::Token.new(length: 32)
# => "iEqo9h0wIoXJrMrkYZkplrwBjrfTyUma"
>> token.length
# => 32
#!/usr/bin/env ruby
require 'json'
r = ''
for line in DATA
line.gsub!(/^(\s*"[^=]+":\s*")(.*?)(",\s*)$/) {
b, m, a = $~.captures
"#{b}#{m.gsub('"', '\\"')}#{a}"
}
>> natural = (1..Float::INFINITY).lazy
# => #<Enumerator::Lazy: 1..Infinity>
>> even = natural.select { |x| x % 2 == 0 }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: 1..Infinity>:select>
>> even.take(10).to_a
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
>>
diff --git a/Library/Formula/vim.rb b/Library/Formula/vim.rb
index d3f5ff2..ccc8cdc 100644
--- a/Library/Formula/vim.rb
+++ b/Library/Formula/vim.rb
@@ -5,6 +5,7 @@ class Vim < Formula
# This package tracks debian-unstable: http://packages.debian.org/unstable/vim
url 'http://ftp.de.debian.org/debian/pool/main/v/vim/vim_7.3.923.orig.tar.gz'
sha1 'f308d219dd9c6b56e84109ace4e7487a101088f5'
+ depends_on 'gtk+'
head 'https://vim.googlecode.com/hg/'
class ::JSON::GenericObject
def self.load(source, proc = nil, opts = {})
result = ::JSON.load(source, proc, opts.merge(:object_class => ::JSON::GenericObject))
result.nil? ? ::JSON::GenericObject[] : result
end
def self.dump(obj, *args)
::JSON.dump(obj, *args)
end
end