Skip to content

Instantly share code, notes, and snippets.

@hwdsl2
hwdsl2 / .MOVED.md
Last active April 10, 2025 04:32
IPsec VPN Server Auto Setup Script for Ubuntu and Debian
@clojens
clojens / re.clj
Created December 12, 2013 17:58
A few clojure java regex samples
(def ptrn
{
:a {:pattern #"a(?!b)"
:purpose "Only allow a if it is not preceded by a 'b' (negative lookahead)"
:samples ["acdefg" ; ok
"abcdef" ; nil
]}
:b {:pattern #"(?i)(<title.*?>)(.+?)(</title>)"
@dmitshur
dmitshur / gist:6927554
Last active December 29, 2024 12:06
[Legacy GOPATH mode] How to `go get` private repos using SSH key auth instead of password auth.
@onlytiancai
onlytiancai / import_zone.py
Created June 21, 2013 07:56
从zonefile文件把域名记录导入到DNSPod
# -*- coding: utf-8 -*-
'''
功能:
从zonefile文件导入域名到Dnspod
requirements:
dnspython==1.10.0
requests==1.0.4
'''
@teropa
teropa / resources.md
Last active December 4, 2020 05:42
Clojure Resources

Tutorials

@hdemers
hdemers / pydata-science.sh
Last active June 1, 2020 07:17
Installation instructions for doing data science in a Python environment on Ubuntu. We'll install base packages like numpy, scipy, scikit-learn and pandas. We also install the IPython Notebook interactive environment. This is a best practice recommendation for doing research-type work. We make use of virtualenvwrapper, but don't show how to inst…
mkvirtualenv datascience
sudo apt-get install python-scipy libblas-dev liblapack-dev gfortran
sudo apt-get install libffi-dev # for cryptography from scrapy
sudo apt-get install libxslt-dev # for libxml from scrapy
export BLAS=/usr/lib/libblas.so
export LAPACK=/usr/lib/liblapack.so
pip install numpy
pip install scipy
pip install scikit-learn
pip install pandas
(defn- debounce-future
"Returns future that invokes f once wait-until derefs to a timestamp in the past."
[f wait wait-until]
(future
(loop [wait wait]
(Thread/sleep wait)
(let [new-wait (- @wait-until (System/currentTimeMillis))]
(if (pos? new-wait)
(recur new-wait)
(f))))))
@n1k0
n1k0 / 404checker.js
Created January 11, 2013 10:55
A CasperJS script to check for 404 & 500 internal links on a given website
/**
* This casper scipt checks for 404 internal links for a given root url.
*
* Usage:
*
* $ casperjs 404checker.js http://mysite.tld/
* $ casperjs 404checker.js http://mysite.tld/ --max-depth=42
*/
/*global URI*/
anonymous
anonymous / clean-mode-line.el
Created January 2, 2013 13:15
Emacs tweek of the modeline for Clojure development - the various modes appear as symbols on the mode line to conserve space and make Emacs look even more intriguing.
(defvar mode-line-cleaner-alist
`((auto-complete-mode . " α")
(yas-minor-mode . " γ")
(paredit-mode . " Φ")
(eldoc-mode . "")
(abbrev-mode . "")
(undo-tree-mode . " τ")
(volatile-highlights-mode . " υ")
(elisp-slime-nav-mode . " δ")
(nrepl-mode . " ηζ")
@ptaoussanis
ptaoussanis / free-port.clj
Created December 14, 2012 06:28
A little utility to allow simple redeployment of Clojure web servers with zero downtime, and without the need for a proxy or load balancer. Just wrap any port-binding calls, and the utility will auto kill pre-existing servers as necessary. *nix only. Based on the blog post by Feng Shen, http://shenfeng.me/fast-restart-clojure-webapp.html
;; (require '[clojure.string :as str] '[clojure.java.shell :as shell] '[taoensso.timbre :as timbre])
(defn with-free-port!
"Attempts to kill any current port-binding process, then repeatedly executes
nullary `bind-port!-fn` (which must return logical true on successful
binding). Returns the function's result when successful, else throws an
exception. *nix only.
This idea courtesy of Feng Shen, Ref. http://goo.gl/kEolu."
[port bind-port!-fn & {:keys [max-attempts sleep-ms]