Skip to content

Instantly share code, notes, and snippets.

View paomian's full-sized avatar
🤕
I don't know.

localhost paomian

🤕
I don't know.
View GitHub Profile
@paomian
paomian / steam.clj
Last active June 22, 2021 02:51
stream
;;不得不说,这思想很牛,但是理解起来也很绕,不知道这种代码到底是好还是不好。。。
;;想想不用这种方法怎么来实现这个功能,应该是用一个额外的表记录下所有前面的素数,然后用 (map (fn [x] (some (fn [y] (not-zero?(mod x y))) [primes list])) strems)
(defmacro my-delay [body]
`(fn [] ~body))
(defn my-force [f]
(f))
(def the-empty-stream [])
@paomian
paomian / deref.rs
Created November 1, 2019 06:52
rust deref
struct X { val: i32 }
impl std::ops::Deref for X {
type Target = i32;
fn deref(&self) -> &i32 { &self.val }
}
trait M { fn m(self); }
impl M for i32 { fn m(self) { println!("i32::m()"); } }
impl M for X { fn m(self) { println!("X::m()"); } }
@paomian
paomian / sync.clj
Created October 15, 2018 03:30
sync
(ns benchmark.sync
(:refer-clojure :exclude [sync])
(:import [com.mongodb.client MongoClients]
[com.mongodb.client MongoClient]
[com.mongodb.client MongoCollection]
[com.mongodb.client MongoDatabase]
[org.bson Document]
[com.mongodb Block ConnectionString MongoClientSettings ServerAddress]
[com.mongodb.connection ClusterSettings ConnectionPoolSettings]
[java.util.concurrent CyclicBarrier CountDownLatch]))
@paomian
paomian / async.clj
Last active October 15, 2018 03:26
asyc
(ns benchmark.async
(:import [clojure.lang IPersistentMap Named Keyword Ratio]
[java.util List Map Date Set]
[com.mongodb ConnectionString
ServerAddress
Block ReadPreference]
[com.mongodb.async.client MongoClient
MongoClients MongoClientSettings Observables
MongoCollection MongoDatabase]
[com.mongodb.connection ClusterSettings ConnectionPoolSettings]
#[macro_use] extern crate hyper;
extern crate rand;
use std::io::{BufReader};
use std::io::prelude::*;
use std::fs::OpenOptions;
use std::collections::BTreeMap;
use std::iter::Iterator;
use hyper::client::Client;
use hyper::header::Basic;

Keybase proof

I hereby claim:

  • I am paomian on github.
  • I am paomian (https://keybase.io/paomian) on keybase.
  • I have a public key ASDuZCUs9SSAMks7aMaMlkHbQ2MyuXz9Xd71M_LIEybJ3wo

To claim this, I am signing this object:

(defrecord Merror [wrap])
(defmonad error-m
[m-bind (fn m-bind-error
[x f]
(if (contains? (:wrap x) :error)
x
(f x)))
m-result (fn m-result-error
[x]
use std::io::BufReader;
use std::io::BufRead;
use std::fs::File;
use std::path::Path;
use std::error::Error;
use std::env;
use std::collections::BTreeMap;
fn get_data(s:&str,separator:char,n:usize) -> Option<usize> {
let mut g = 0;
@paomian
paomian / pv.java
Created August 31, 2015 16:27
pv java
import java.lang.Exception;
import java.lang.Object;
import java.lang.Runnable;
import java.lang.System;
import java.lang.Thread;
import java.util.LinkedList;
import java.util.concurrent.Semaphore;
class MyQueue {
(require 'prelude-programming)
;;; Code:
(prelude-require-packages '(rust-mode
racer))
(require 'rust-mode)
(setq racer-rust-src-path "/Users/ipaomian/work/rust/rustc-1.1.0/src")
(setq racer-cmd "/Users/ipaomian/work/rust/racer/target/release/racer")