Skip to content

Instantly share code, notes, and snippets.

@zyguan
zyguan / ntpdate.yml
Created September 6, 2015 02:15
A simple ansible playbook for controlling ntpdate job
---
- hosts: nodes
vars:
server: ntp.ubuntu.com
m: "0"
h: "*/6"
dow: "*"
dom: "*"
mon: "*"
state: present
@zyguan
zyguan / st_example.go
Created October 22, 2015 08:50
A clumsy segment tree implementation in golang
package main
import (
"errors"
"fmt"
"math"
)
func divide(l, r int) (int, error) {
m := (l + r) / 2
Windows Registry Editor Version 5.00
; Here are some of common key codes
; 3a (CapsLock)
; e0 5d (Menu)
; e0 5b (LeftWindow)
; e0 5c (RightWindow)
; e0 1d (RCtrl) 1d (LCtrl)
; e0 38 (RAlt) 38 (LAlt)
; see http://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html for details
@zyguan
zyguan / grub.cfg
Last active November 19, 2015 09:40
Examples of booting linux iso images
# This configuration may be outdated, please see:
# https://wiki.archlinux.org/index.php/Multiboot_USB_drive
# https://wiki.archlinux.org/index.php/Talk:Multiboot_USB_drive
set timeout=10
insmod search_fs_uuid
# you must replace E85C-CED5 with the actual uuid
search --no-floppy --set=isopart --fs-uuid E85C-CED5
@zyguan
zyguan / pom.xml
Last active November 30, 2015 02:06 — forked from codahale/pom.xml
Take this and save it as pom.xml in your project directory.
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>sample-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
-- Firefox saves your browsing history data in places.sqlite. So it's
-- possible to know about your behavior by a sql select statement.
-- Here is an example.
--
-- (https://support.mozilla.org/en-US/kb/recovering-important-data-from-an-old-profile)
--
SELECT host, count(*) FROM moz_historyvisits h LEFT JOIN
(SELECT id, substr(substr(url, instr(url,'://')+3),
0,instr(substr(url, instr(url,'://')+3),'/')) AS host
@zyguan
zyguan / mvn-get
Last active March 1, 2016 00:50
从 Android 创建的 Gist
#! /bin/sh
repos="http://maven.oschina.net/content/groups/public/"
mvn dependency:get -DremoteRepositories="$repos" -Dartifact="$1"
@zyguan
zyguan / CV.css
Created March 1, 2016 13:32 — forked from Sth0nian/CV.css
body {
background-color: gray;
}
article {
width:720px;
margin:auto;
margin-top: -10px;
font-family:helvetica,
verdana, sans-serif;
padding-bottom:3em;
@zyguan
zyguan / calc.y
Created April 14, 2016 08:27
An example of go yacc
// Copyright 2011 Bobby Powers. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
// based off of Appendix A from http://dinosaur.compilertools.net/yacc/
// original work: https://github.com/golang-samples/yacc
%{
from inspect import isgenerator
def fact(n):
if n <= 1:
return n
else:
f = yield fact(n-1)
return f * n
def fib(n):