This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; It's been a long time that Typed Clojure couldn't annotate `hash-map` using | |
; first class type. Because these functions require even number of arguments, | |
; and also have some special type constrain on its arguments. | |
; So we used to check these functions using special handler in checker. | |
; One of my GSOC goal is to make it possible to type check these kind of | |
; function without special handler. | |
; And now I made it. Thanks Sam Tobin-Hochstadt and Asumu Takikawa who inspired | |
; us. | |
; You can try it at my fork of Typed Clojure | |
; https://github.com/xudifsd/core.typed/tree/repeat-support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro defasync [name args & body] | |
(if config/in-test? | |
`(defn ~name ~args ~@body) | |
(let [name-str (str name)] | |
`(defn ~name ~args | |
(future | |
(try | |
~@body | |
(catch Exception e# | |
(log/error (str ~name-str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn self-is-active? | |
[{{:keys [uid]} :params :as req}] | |
(when-not (nil? uid) | |
(let [user-id (u/->int uid) | |
user (users/get-user-by-id user-id)] | |
(when-not (nil? user) | |
(not (:inactive user)))))) | |
(defn self-belongs-to-team? | |
[{{:keys [uid subdomain]} :params :as req}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn self-is-active? | |
[{{:keys [uid]} :params :as req}] | |
(when-not (nil? uid) | |
(let [user-id (u/->int uid) | |
user (*get-user-by-id* user-id)] | |
(when-not (nil? user) | |
(not (:inactive user)))))) | |
(defn self-belongs-to-team? | |
[{{:keys [uid subdomain]} :params :as req}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class ListNode[+T](data: T, next: Option[ListNode[T]]) object List { | |
def newList[T](data: T) = newListFromNode(new ListNode(data, None)) | |
def newListFromNode[T](node: ListNode[T]) = new List(node) | |
private def travse_iter[A](head:Option[ListNode[A]], fn: (ListNode[A]) => Unit): Unit = { | |
head match { | |
case Some(node) => { | |
fn(node) | |
List.travse_iter(node.next, fn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <time.h> | |
#include <sys/types.h> | |
#include <sys/time.h> | |
#include <unistd.h> | |
#define SIZE (40 * 1024 * 1024 * 1024L) | |
static inline double get_time_diff_double(struct timeval end, struct timeval start) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while : | |
do | |
git add . | |
sleep 1 | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn qsort [l] | |
(if (empty? l) '() | |
(let [f (first l) | |
smaller (filter #(<= % f) (rest l)) | |
bigger (filter #(> % f) (rest l))] | |
(concat (qsort smaller) [f] (qsort bigger))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
时间限制:10000ms | |
单点时限:1000ms | |
内存限制:256MB | |
描述 | |
Given a sequence {an}, how many non-empty sub-sequence of it is a prefix of fibonacci sequence. | |
A sub-sequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. | |
The fibonacci sequence is defined as below: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
class TreeNode: | |
def __init__(self, val): | |
self.val = val | |
self.left = None | |
self.right = None | |
def printTreeWithDistance(root, k): | |
def impl(root, path): |
OlderNewer