Skip to content

Instantly share code, notes, and snippets.

;; in the code below, 'f' function is exactly the same as 'g' function,
;; and every line starting with '(time ...)' measures exactly the same
;; calculation. Which is for some reason fast for 'f', for as long as
;; 'g' is not defined, and after that it soon becomes slow both for 'f'
;; and for 'g'. The effect is quite reproducible.
user=> (set! *warn-on-reflection* true)
true
user=> (def xs (int-array 1 0))
#'user/xs
@jsn
jsn / global-deps.edn
Last active December 26, 2019 02:01
my clojure repl setup
{
:aliases {
:deps {:extra-deps
{org.clojure/tools.deps.alpha {:mvn/version "0.6.474"}}}
:dev {:extra-paths ["/home/jason/.clojure/my-dev"]
:extra-deps
{com.bhauman/rebel-readline {:mvn/version "0.1.4"}
nrepl/nrepl {:mvn/version "0.6.0"}
cider/cider-nrepl {:mvn/version "0.21.1"}}
:main-opts ["-m" "myrepl"]}

Simpler-than-Pilaf Baked Rice

  • MAKES: 4 servings
  • TIME: 30 minutes

This basic, valuable technique is a combination of pilaf and paella but simpler than either, especially if you omit the spices and go with just salt and pepper. See "15 Ingredients to Stir Into Rice Pilaf or Simpler-than-Pilaf Baked Rice" (page 461) for ideas too.

Tomato and Cheese Frittata

MAKES: 4 servings

TIME: 30 minutes

All sorts of vegetables can be used here. See the variations and the list that follows.

  1. 2 tablespoons extra virgin olive oil
  2. 1/2 onion, sliced
jason@jsn cr $ head -n1000 z.cr z2.cr
==> z.cr <==
def q
puts "in q"
1
end
Q = q()
class Z
jason@jsn cr $ crystal z2.cr
in class method for x
2018-02-09 03:17:03 +03:00
before
in class method for y
in class
out of class
after
jason@jsn cr $ head -n 1000 z.cr z2.cr
==> z.cr <==
jason@jsn cr $ head -n 1000 z.cr z2.cr
==> z.cr <==
class Z
def self.f
puts "in class method"
return Time.now
end
@@x : Time = f()
@jsn
jsn / a.cr
Created October 30, 2017 18:37
def check(l)
abba = false
l.scan(/([a-z])([a-z])\2\1/) do |rm|
next if $1 == $2
return false if rm.pre_match =~ /\[[^\]]*$/
abba = true
end
!!abba
end
@jsn
jsn / ws.cr
Created October 22, 2017 12:47
require "http/server"
handler = HTTP::WebSocketHandler.new do |session|
session.on_message do |message|
puts "Received #{message}"
pp [email protected] message
end
end
HTTP::Server.new(8081, [handler, HTTP::LogHandler.new]).listen
@jsn
jsn / s.cr
Created October 19, 2017 18:20
crystal lang *Server bug
# compile with --release, connect with netcat: nc localhost 12300, try multiple times
require "socket"
TCPServer.new(12300, reuse_port: true).accept.puts "hi"