Skip to content

Instantly share code, notes, and snippets.

View number23's full-sized avatar
🎯
Focusing

number23 number23

🎯
Focusing
View GitHub Profile
(defmacro assert-all
[& pairs]
`(do (when-not ~(first pairs)
(throw (IllegalArgumentException.
(str (first ~'&form) " requires " ~(second pairs) " in " ~'*ns* ":" (:line (meta ~'&form))))))
~(let [more (nnext pairs)]
(when more
(list* `assert-all more)))))
(defmacro when-let*
@number23
number23 / README.md
Last active June 28, 2016 04:21 — forked from chuangbo/README.md
Python dynamic DNSPod DNS Script

替换上你的login_token,域名ID,记录ID等参数,就可以运行了。 会在后台一直运行,每隔30秒检查一遍IP,如果修改了就更新IP。

获得domain_id可以用curl curl -k https://dnsapi.cn/Domain.List -d "login_token=xxxxx,xxxxxxxx&format=json" | python -m json.tool

获得record_id类似 curl -k https://dnsapi.cn/Record.List -d "login_token=xxxxx,xxxxxxxx&domain_id=xxx&format=json" | python -m json.tool

@number23
number23 / gist:fcc08a7bb05f77d6720c
Created September 4, 2014 09:21
vars since 1.4 in core
;; vars since 1.4 in core
(for [[n v] (ns-publics 'clojure.core) :let [since (:added (meta v))] :when (= since "1.4")] n)
@ptaoussanis
ptaoussanis / transducers.clj
Last active December 17, 2021 13:54
Quick recap/commentary: Clojure transducers
(comment ; Fun with transducers, v2
;; Still haven't found a brief + approachable overview of Clojure 1.7's new
;; transducers in the particular way I would have preferred myself - so here goes:
;;;; Definitions
;; Looking at the `reduce` docstring, we can define a 'reducing-fn' as:
(fn reducing-fn ([]) ([accumulation next-input])) -> new-accumulation
;; (The `[]` arity is actually optional; it's only used when calling
;; `reduce` w/o an init-accumulator).
(require '[clojure.core.async :as a])
(def xform (comp (map inc)
(filter even?)
(dedupe)
(flatmap range)
(partition-all 3)
(partition-by #(< (apply + %) 7))
(flatmap flatten)
(random-sample 1.0)
package eval
import scala.reflect.runtime.currentMirror
import scala.tools.reflect.ToolBox
import java.io.File
object Eval {
def apply[A](string: String): A = {
val toolbox = currentMirror.mkToolBox()
@dimitrisli
dimitrisli / Mail.scala
Last active March 22, 2017 08:51 — forked from mariussoutier/Mail.scala
Makes sense to wrap in Some instead of Option since the case is exhaustive
package object mail {
implicit def stringToSeq(single: String): Seq[String] = Seq(single)
implicit def liftToOption[T](t: T): Option[T] = Some(t)
sealed abstract class MailType
case object Plain extends MailType
case object Rich extends MailType
case object MultiPart extends MailType
@dysinger
dysinger / easy-ubuntu-openvpn.sh
Created August 28, 2013 18:22
Create a VPN on EC2 in 30 seconds
#!/bin/sh
# linux firewall/forwarding
modprobe iptable_nat
echo 1 | tee /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 10.10.10.1/2 -o eth0 -j MASQUERADE
# install openvpn
apt-get update && apt-get install -y openvpn
cd /etc/openvpn/
INSTANCE=$(curl http://169.254.169.254/latest/meta-data/public-hostname)
openvpn --genkey --secret ${INSTANCE}.key
@ray1729
ray1729 / tweet.clj
Created June 29, 2013 22:18
Sending tweets from Clojure
(require '[clojure.java.io :as io])
(require '[oauth.twitter :refer [oauth-client]])
(defn read-properties
"Parse a properties file, convert the property keys to Clojure
keywords and return as a Clojure map."
[resource-name]
(when-let [resource (io/resource resource-name)]
(let [properties (java.util.Properties.)]
(with-open [stream (io/input-stream resource)]

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style