Skip to content

Instantly share code, notes, and snippets.

View fallengiants's full-sized avatar
💭
in Domine sola fidi, et mala omnis acqui vincit.

fall fallengiants

💭
in Domine sola fidi, et mala omnis acqui vincit.
View GitHub Profile
# Cheaty idea
class Conway
def initialize(height, width)
@height = height
@width = width
@cells = [0] * width
end
def set_cell(x,y,v) # v is a boolean value
if v
class Integer # so that 3.to_roman() will return a result
Roman = 'IVXLCDM' # cardinally ordered roman numerals
def to_roman
raise "Number too large" if self > 4999 # string does not contain characters for > 4999
n, nsize = self, Math.log10(self).to_i # n = this number, nsize = number of digits in this number
nsize.downto(0).map do |pow| # pow = each digit from the left (i.e. 4,3,2,1 for 1000) - 1 (zero is the first index)
mid = pow << 1 # mid = pow * 2 (so that for every multiple of 10, there are two roman characters)
current = n / (10 ** pow) # current = T where Txxx is the current number and pow is digits from right; i.e. 1234 and pow is 3 -> T == 1
n = n % (10 ** pow)
@fallengiants
fallengiants / index.html
Last active January 15, 2018 16:19
Movement on a skewed field by coordinate https://jsbin.com/xeguqoq
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
.container-field {
width: 500px;
height: 200px;
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Hello World</title>
<script src="https://unpkg.com/react@latest/dist/react.js"></script>
<script src="https://unpkg.com/react-dom@latest/dist/react-dom.js"></script>
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
</head>
#content {margin: 0 auto !important;width: 1000px !important;}#filter {background-color: #eee !important;border: none !important;border-radius: 0 !important;padding: 10px 20px !important;}#filter .thread_tags {margin: 0 !important;margin-top: 20px !important;padding: 0 !important;}#filter .toggle_tags {padding: 0 !important;}#nav_purchase, #navigation {border: 0 !important;}#navigation {border-bottom: 5px solid #eee !important;padding-bottom: 20px !important;}* {background: none !important;background-image: none !important;box-shadow: none !important;font-family: "Helvetica Neue" !important;text-shadow: none !important;}*, *:before, *:after {box-sizing: border-box !important;}.bbc-block {border: 1px solid #d0d0d0 !important;border-radius: 0 !important;box-shadow: none !important;margin: 0 !important;}.bbc-spoiler {background-color: #888 !important;color: #888 !important;}.bbc-spoiler:hover {background-color: #ddd !important;color: #000 !important;}.forumbar, .threadbar {background-color: #eee !important;borde
<html>
<body>
<div class="title">
<h2>I AM AN ANIMU</h2>
</div>
<div class="collector">
<div class="porn">
</div>
<div class="wordstuff">
there were dirty thoughts in her head because somebody put paper in it.
@fallengiants
fallengiants / sphinx.rb
Last active December 21, 2015 21:10
sphinx 0.9.9
require 'formula'
class Libstemmer < Formula
# upstream is constantly changing the tarball,
# so doing checksum verification here would require
# constant, rapid updates to this formula.
head 'http://snowball.tartarus.org/dist/libstemmer_c.tgz'
homepage 'http://snowball.tartarus.org/'
end
class Symbol
def ~@
_bound = binding
return ->(arg) {_bound.send(self, arg)}
end
end
#f '123456789',100
def f(d,t)
a=[]
0.upto(3**(d.size-1)).map do |n|
l,n=[d,n.to_s(3)].map {|t| t.chars.map(&:to_i)}
k,m,z=[l.shift],1,1
l.map {|i| o=n.pop||0;z=(1-(o&1)*2); o&2>0 ? k<<k.pop*10+i*m : k<<i*m=z }
a<<k.join(?+).gsub('+-',?-) if k.reduce(&:+)==t
end
1.upto(3**8).each do |i|
flags = i.to_s(3).rjust(8, ?0).split(//)
math = ''
1.upto(9).map do |c|
math += c.to_s
math += case flags.shift
when ?1 then ?+
when ?2 then ?-
else ''
end