Skip to content

Instantly share code, notes, and snippets.

dminuoso

Block or report user

Report or block dminuoso

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View foo.rb
module M
X = 1
end
Object.include M
A = String
puts A::X
X = 23
View foo.js
const idIfEq = (a, b) => a === b ? a : null
moves.find((row) => row.reduce(idIfEq))
View foo.js
const composeP2 = (f, g) => (val) => g(val).then((next) => f(next));
const composeP = (...funcs) => funcs.reverse().reduce(composeP2);
View van_laarhoven_lens.rb
Identity = Struct.new(:value) do
def fmap(*args)
-> (func) {
Identity.new(func.call(self.value))
}.curry[*args]
end
end
Const = Struct.new(:value) do
def fmap(*args)
View van_laarhoven_lens.rb
# Identity functor that does not give any additional structure
Identity = Struct.new(:value) do
def fmap(func = nil, &blk)
f = func || blk;
Identity.new(f.call(self.value))
end
end
# Const Functor that preserves its content
Const = Struct.new(:value) do
View foo.rb
class Hash
def self.setter(*args)
-> (paths, val, obj) {
obj.deep_dup.tap do |o|
*dir, final = paths
if dir.empty?
o.store(final, val)
else
o.dig(*dir).store(final, val)
end
View foo.rb
def self.writer_path(*args)
-> (paths,val, obj) {
obj.deep_dup.tap { |o| o.dig(*paths) = val }
}.curry[*args]
end
View bar.rb
usages = lines
.map(&:split)
.group_by(&loginL)
.map(&toUsage)
.sort_by(&:trafficOut)
.reverse
View foo.js
const toggleClass = (id, toggle) => id === toggle ? 'toggle active' : 'toggle inactive';
const Style = ({ activeFontColor, activeBackgroundColor, fontColor }) => (
<style jsx>
{`
.toggle {
width: 50%;
height: 50px;
border-radius: 100px;
line-height: 50px;
View functional.rb
module ArityRange
def arity_range
args = parameters.map(&:first)
req = args.count :req
keyreq = args.count :keyreq
opt = args.include?(:rest) ? Float::INFINITY : args.count(:opt)
keyopt = args.include?(:keyrest) ? Float::INFINITY : args.count(:key)
You can’t perform that action at this time.