Skip to content

Instantly share code, notes, and snippets.

View j-em's full-sized avatar
🏠
Working from home

Jeremy j-em

🏠
Working from home
  • Canada, Montreal
View GitHub Profile

Keybase proof

I hereby claim:

  • I am j-em on github.
  • I am jem_xyz (https://keybase.io/jem_xyz) on keybase.
  • I have a public key ASBgKmLCK8W-kifO8GkKfJeQTOfkLaZ0J2bJyZcx8fLusAo

To claim this, I am signing this object:

@j-em
j-em / DynamicDOM.cs
Created November 11, 2017 21:42 — forked from TryJSIL/DynamicDOM.cs
Dynamic DOM
using System;
using JSIL;
using JSIL.Meta;
public static class Program {
public static int x = 10;
public static int y = 20;
public static void Main () {
dynamic document = Builtins.Global["document"];
object Collections extends App {
implicit class Collections[E](iterable: Traversable[E]) {
def mapIt[A](f: (E) => A): List[A] = {
iterable match {
case head :: body => f(head) :: body.mapIt(f)
case _ => List()
}
}
}
}
@j-em
j-em / gist:37a2f0e56c0039073b9a
Created January 13, 2016 21:22
ClojureScript exceptions length
Compiling "resources/public/js/main-100.js" failed.
clojure.lang.ExceptionInfo: failed compiling file:src-cljs-om/tack/job.cljs {:file #object[java.io.File 0x1d8ab0dc "src-cljs-om/tack/job.cljs"]}
at clojure.core$ex_info.invoke(core.clj:4593)
at cljs.compiler$compile_file$fn__3198.invoke(compiler.cljc:1254)
at cljs.compiler$compile_file.invoke(compiler.cljc:1216)
at cljs.compiler$compile_root.invoke(compiler.cljc:1291)
at cljs.closure$compile_dir.invoke(closure.clj:438)
at cljs.closure$eval3581$fn__3582.invoke(closure.clj:478)
at cljs.closure$eval3533$fn__3534$G__3524__3541.invoke(closure.clj:383)
at cljs.closure$eval3594$fn__3595.invoke(closure.clj:492)
@j-em
j-em / monads.clj
Created October 1, 2015 11:06
Monads (or close to it) experimentations
(defn m-bind [mv mf]
(if (nil? mv)
nil
(mf mv)))
(defn m-log [[step n] mf]
(println (str step (inc n)))
(m-bind [step (inc n)] mf))
(defn operations []
@j-em
j-em / gist:6ecb895b0727ca709493
Created February 27, 2015 08:11
Diff between two strings
def diff_str(str1, str2):
differ = difflib.Differ()
string_buffer = io.StringIO()
for char in differ.compare(str1, str2):
if char[0] == "+" or char[0] == " ":
string_buffer.write(char[2])
return string_buffer.getvalue().encode()
@j-em
j-em / ruby-challenge.rb
Last active August 29, 2015 14:11
Ruby Challenge
require 'benchmark'
test_string = "apples, pears # and bananas\ngrapes\nbananas !apples"
args = ["#", "!"]
# first try =>
def r_remove_comments(str, markers)
formatted_string = ""
str.each_line do |line|
markers.each do |marker|
class Teetime < ActiveRecord::Base
validates :user, format: { with: /\w/, message: "can only contains letters or numbers"}, uniqueness: true
validates :date, presence: true
validates :time, presence: true
validates :club_id, inclusion: {in: Club.all.map { |club| club.id }, message: "%{value} is not a valid club"}
belongs_to :club
def self.available_on(date, club)
# date comes in the format mm/dd/yyy
# club comes in the format "clubname"
RSpec.describe Teetime do
it "return a list of Time object for a given date and for a club" do
av = Teetime.available_on("01/01/2014", "club1")
expect(av).to be_a(Array)
unless av.empty?
expect(av[0]).to be_a(Time)
end
end
end