Skip to content

Instantly share code, notes, and snippets.

@snyh
snyh / distance_random.py
Created December 12, 2012 14:02
generate random element from an list with gurantee at least "n" element is not same. (n is default the length of the list)
import random
class DistanceRandom:
def __init__(self, v_range, v_distance=None):
if v_distance == None:
v_distance = len(v_range)
assert(len(v_range) >= v_distance >= 1)
self.freshed = v_range
self.dist = v_distance
self.used = []
@snyh
snyh / dui.go
Last active December 23, 2015 22:09
package main
import "dui"
import "fmt"
import "io/ioutil"
func main() {
dui.Init()
f := dui.NewFrame(300, 300)
@snyh
snyh / twoway.qml
Created December 6, 2013 08:05
qml property twoway sync.
import QtQuick 2.0
import QtQuick.Controls 1.0
Column {
CheckBox {
id:a1
text:"A1"
Binding { target :a2; property: "checked"; value:a1.checked }
}
import socket
s = socket.socket(socket.AF_UNIX)
addr = "\0org.snyh.test"
s.bind(addr)
while(True):
pass
# use netstat -anp | grep snyh
# to verify it
@snyh
snyh / no_proc_self_exe.c
Created December 17, 2013 02:34
it's show that /proc/`pid`/exe is not always valid.
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#define NUM_THREADS 5
void func(void *a)
{
printf("/proc/%ld/exe\n", getpid());
@snyh
snyh / ReadXSettings.go
Last active September 18, 2018 13:21
//this simple file show you how to read the XSettings properties (http://standards.freedesktop.org/xsettings-spec/xsettings-spec-0.5.html)
package main
import "fmt"
import "github.com/BurntSushi/xgb/xproto"
import "github.com/BurntSushi/xgb"
import "encoding/binary"
import "io"
import "bytes"
@snyh
snyh / gist:7bfab3f65b2642505915
Created July 2, 2014 00:57
associate touchscreen and output under deepin2014
Normal you don't need this unless you work with multi-head and touchscreen. Below steps will associate your devices when things changed.
First, find the *touchscreen device* name. run "xinput | grep -i touchscreen"
and results will be similar to this:
"⎜ ↳ ELAN Touchscreen id=11 [slave pointer (2)]"
the "ELAN Tochscreen" or "11" can be used as device name.
diff --git a/datetime/timezone/timestamp.c b/datetime/timezone/timestamp.c
index 6ddb230..53a8857 100644
--- a/datetime/timezone/timestamp.c
+++ b/datetime/timezone/timestamp.c
@@ -31,7 +31,7 @@
static int isdst_timestamp(time_t t);
-DSTTime*
+DSTTime
1 Why we don't use server side choosing mirror?
═══════════════════════════════════════════════
The IP address family can't reflect the connection status between
mirror server and the user, especially in China.
We belive Only the user side can make the best choose.
2 How deepin solve the problem?
@snyh
snyh / repo_guard.go
Last active September 18, 2018 13:21
package main
import (
"flag"
"fmt"
"io/ioutil"
"os"
"path"
"strings"
"time"