Skip to content

Instantly share code, notes, and snippets.

@e7
e7 / get-active-window.c
Last active January 18, 2019 07:06
xwininfo也可以获取窗口id号
// -*- coding:utf-8-unix; mode:c; -*-
/*
get the active window on X window system
http://k-ui.jp/blog/2012/05/07/get-active-window-on-x-window-system/
*/
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
/**
* 二进制数据与Set互转
*/
@MappedJdbcTypes({JdbcType.VARBINARY})
public abstract class AbstractSetBinaryConverter<T> implements TypeHandler<Set<T>> {
/**
* 暂用json序列化
*/
private static final ObjectMapper OM = new ObjectMapper();
/*
* Copyright 2011 Jesper de Jong
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NGX_OK 0
#define NGX_ERROR -1
#define NGX_SETPROCTITLE_PAD '\0'
typedef int ngx_int_t;
import ctypes
import time
SendInput = ctypes.windll.user32.SendInput
# C struct redefinitions
PUL = ctypes.POINTER(ctypes.c_ulong)
class KeyBdInput(ctypes.Structure):
_fields_ = [("wVk", ctypes.c_ushort),
("wScan", ctypes.c_ushort),
func NilInterface(i interface{}) bool {
iVal := reflect.ValueOf(i)
switch iVal.Kind() {
case reflect.Invalid:
return i == nil
case reflect.Chan, reflect.Map, reflect.Slice, reflect.Interface, reflect.Func:
fallthrough
case reflect.Ptr, reflect.UnsafePointer:
return iVal.IsNil()
package main
import (
"fmt"
"reflect"
)
type row struct { i, j int }
func main() {
@e7
e7 / strbytes
Last active October 19, 2021 11:01
// gin
func StringToBytes(s string) []byte {
return *(*[]byte)(unsafe.Pointer(
&struct {
string
Cap int
}{s, len(s)},
))
}
@e7
e7 / gpg
Created October 17, 2022 07:28
fingerprint:
A3D4 3A29 8737 27DF 0332 4F3F CE04 2F08 D030 B175
public key:
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQGNBGNM+40BDADQc9srvea/E/XzwsybseuSSEQIn2Xl3GTuKPlFio80MuLt8nsc
CuJVgzyem13qQHGowu14pG0mZdh1cSC8dwhuCTF3YSgWD7pPkoaeU8/s6dbDUSH8
8Ku/anB5e3iOrhMKIExxKzTU7edt44rzeBv/hydrZUkZ1JM/IxfnKAUrG1zhGfDH
k31Mhgwd34zDj/qXku/J1cB6Ry9x4iR8E5ybpL6DohSKB7VHVfnLukT8ZB6qKK6O