Skip to content

Instantly share code, notes, and snippets.

View yujinqiu's full-sized avatar
💭
🚀

yujinqiu

💭
🚀
View GitHub Profile
@yujinqiu
yujinqiu / gist:6047242
Created July 21, 2013 02:24
html:detect ie
(function () {
if (!Worker) //Detect IE
document.location = "http://www.whatbrowser.org/ru/browser/";
})();
def indent(elem, level=0):
i = "\n" + level*" "
if len(elem):
if not elem.text or not elem.text.strip():
elem.text = i + " "
if not elem.tail or not elem.tail.strip():
elem.tail = i
for elem in elem:
indent(elem, level+1)
if not elem.tail or not elem.tail.strip():
#!/bin/bash
NGINX_VERSION="1.4.7"
NGINX_TARBALL="nginx-${NGINX_VERSION}.tar.gz"
PCRE_VERSION="8.34"
PCRE_TARBALL="pcre-${PCRE_VERSION}.tar.gz"
OPENSSL_VERSION="1.0.1g"
OPENSSL_TARBALL="openssl-${OPENSSL_VERSION}.tar.gz"
OPENSSL_PATCH_URL="https://bugs.archlinux.org/task/35868?getfile=10648"
if [[ "${1}" == "clean" ]]; then
#!/usr/bin/env bash
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.osx` has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
@yujinqiu
yujinqiu / gist:9699345ec52c8ac57e77
Created September 17, 2014 12:10
ubuntu 14.04 LTS source
deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
@yujinqiu
yujinqiu / rsa
Created December 10, 2014 07:57
golang rsa
package main
import (
"io"
"os"
"fmt"
"crypto/rand"
"crypto/rsa"
"crypto/md5"
"crypto"
func readLine(path string) {
inFile, _ := os.Open(path)
defer inFile.Close()
scanner := bufio.NewScanner(inFile)
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
fmt.Println(scanner.Text())
}
}
@yujinqiu
yujinqiu / golang file exist
Created December 12, 2014 09:49
golang file exitst
// equivalent to Python's `if not os.path.exists(filename)`
if _, err := os.Stat(filename); os.IsNotExist(err) {
fmt.Printf("no such file or directory: %s", filename)
return
}
In the above example we are not checking if err != nil because os.IsNotExist(nil) == false anyway.
To check if a file exists,
(defn tc [wndtime numwnds threshold & children]
(fixed-event-window wndtime
(combine folds/mean
(moving-event-window numwnds
(combine folds/minimum
(where (> metric threshold)
;;create a threshold crossing event
(with {:host nil :state "threshold crossed" :description (str "service crossed the value of " threshold " over " numwnds " windows of " wndtime " seconds")}
(apply sdo children)))))))
)
@yujinqiu
yujinqiu / config.go
Last active August 29, 2015 14:19 — forked from bodokaiser/config.go
package main
import (
"log"
"fmt"
"encoding/json"
)
var conf1 = `
{