CoffeeScript 1.7 is shaping up to be a pretty kick-ass release with significant improvements. Here are the ones I'm most excited about, in order of my own excitement.
Years of being wished for, finally granted!
ctrl_table = { | |
sends_escape = true, | |
last_mods = {} | |
} | |
control_key_timer = hs.timer.delayed.new(0.15, function() | |
ctrl_table["send_escape"] = false | |
-- log.i("timer fired") | |
-- control_key_timer:stop() | |
end |
# If your test settings file doesn't import any other settings file | |
# then you can use the function directly: | |
def prevent_tests_migrate(db): | |
import django | |
from django.db import connections | |
from django.db.migrations.executor import MigrationExecutor | |
django.setup() | |
ma = MigrationExecutor(connections[db]).loader.migrated_apps | |
return dict(zip(ma, ['{a}.notmigrations'.format(a=a) for a in ma])) |
CoffeeScript 1.7 is shaping up to be a pretty kick-ass release with significant improvements. Here are the ones I'm most excited about, in order of my own excitement.
Years of being wished for, finally granted!
def fibonacci(n): | |
result = [] | |
x, y = 0, 1 | |
while x < n: | |
result.append(x) | |
x, y = y, y + x |
(defmacro makexml [code] | |
(import [hy.models.expression [HyExpression]] | |
[hy.models.dict [HyDict]]) | |
(defn dict-to-attrs [d] | |
(setv keys (slice d 0 (len d) 2)) | |
(setv vals (slice d 1 (len d) 2)) | |
(.join " " (list-comp | |
(kwapply | |
(.format "{name}=\"{value}\"") | |
{"name" i "value" (get vals (.index keys i))}) |
(ns cljs-uuidv4 | |
"Generator for a v4/random UUID that works with cljs.core/UUID" | |
(:require [goog.string.StringBuffer])) | |
(defn UUIDv4 | |
"Returns a new randomly generated (version 4) cljs.core/UUID, | |
like: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx | |
as per http://www.ietf.org/rfc/rfc4122.txt. | |
Usage: |
; Inspired by https://twitter.com/gigasquid/status/530699466891067392 ... | |
; An implementation of the Fizz Buzz Kata with no conditionals. | |
(defn fb-gen | |
[step value] | |
(into (sorted-map) (zipmap (range step 101 step) (repeat value)))) | |
(def nums (into (sorted-map) (zipmap (range 1 101) (range 1 101)))) | |
(def threes (fb-gen 3 "fizz")) | |
(def fives (fb-gen 5 "buzz")) | |
(def fifteens (fb-gen 15 "fizzbuzz")) |
Everything is pip 1.4+ all downloads starting 2014-01-02 and ending with 2014-04-13.
SELECT python_type, array_to_string(python_release[0:2], '.') AS python_release, COUNT(*)
FROM (
SELECT
python_type,
string_to_array(
(
CASE WHEN (python_release IS NULL OR python_release = '')
/ | |
(?:(\w+)\:?\/\/)? # Protocol | |
([^\/?]+) # Optional subdomains, domain and TLD | |
\/? # Traling slash | |
([^\?]*) # Path | |
([^\#]*) # Query | |
(\#?.*) # Fragment | |
/xu | |
# http://regex101.com/r/oV5tN9 |
(defn pivot-and-rest [coll] | |
(let [splitted (split-at (quot (count coll) 2) coll) | |
second-part (second splitted)] | |
[(first second-part) (concat (first splitted) (rest second-part))])) | |
(defn quicksort [coll] | |
(cond | |
(empty? coll) [] | |
(= (count coll) 1) coll | |
:else (let [[p xs] (pivot-and-rest coll) |