Skip to content

Instantly share code, notes, and snippets.

View holmesconan's full-sized avatar

Holmes Conan holmesconan

  • Hebei, China
View GitHub Profile
@holmesconan
holmesconan / capture.cpp
Created August 28, 2015 12:44
Capture screen by GDI on Windows
HDC hdc = GetDC(NULL); // get the desktop device context
HDC hDest = CreateCompatibleDC(hdc); // create a device context to use yourself
// get the height and width of the screen
int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
int width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
// create a bitmap
HBITMAP hbDesktop = CreateCompatibleBitmap( hdc, width, height);
#!/bin/bash
action=$1; uri=$2; shift; shift;
case "$action" in
GET)
curl -XGET "localhost:9200/$uri?pretty=1" "$@"
;;
PUT)
curl -XPUT "localhost:9200/$uri?pretty=1" "$@"
;;
@holmesconan
holmesconan / nginx.conf
Last active May 26, 2016 14:20
Set prefer domain
server {
listen 80;
server_name example.org;
return 301 http://www.example.org$request_uri;
}
@holmesconan
holmesconan / wordpress.conf
Created December 12, 2016 06:58
Nginx Wordpress Rewrite rules.
server {
server_name example.com ;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log debug;
root /var/www/example.com/htdocs ;
index index.php;
if (!-e $request_filename) {
@holmesconan
holmesconan / index.html
Created June 23, 2017 14:02
HTML5 Boilerplate With IE Conditional Tag.
<!DOCTYPE html>
<!--[if lt IE 9]>
<html class="lt-ie9" lang="zh-CN">
<![endif]-->
<!--[if gte IE 9]> -->
<html lang="zh-CN">
<!--<![endif]-->
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
@holmesconan
holmesconan / flushdns.sh
Created October 30, 2017 02:26
Flush macOS 10.12+ DNS cache
#!/bin/sh
killall -HUP mDNSResponder
killall mDNSResponderHelper
dscacheutil -flushcache
@holmesconan
holmesconan / ss-local-select-auto.sh
Created November 4, 2017 06:32
Bash script to choose shadowsocks servers.
#!/bin/bash
{"sig":"cccea3c025698294837b8e2442b2868b8f1fe1b033a202e93aac77f8a36befcbcda8c9113229c5d82649527f7052aa02a60abe86afab8e46f0d2f5b293651b7b0","msghash":"22dfc290a00344129a64c53aa83b63095283d55f7390ccdcd06f11db0e7154bc"}
@holmesconan
holmesconan / tf-docker-env.sh
Last active June 18, 2018 13:58
Tensorflow GPU deploy script
#!/bin/sh
# This script is used to config tensorflow docker runtime environment on aliyun.
# System should be Ubuntu 16.04
# echo Install NVIDIA driver
# sudo add-apt-repository ppa:graphics-drivers
# sudo apt-get update
# sudo ubuntu-drivers devices
# https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-using-the-repository
@holmesconan
holmesconan / vgg.py
Created July 1, 2018 09:23
Memory Optimization With Swap-out in DNN.
# coding: utf-8
# Low Memory VGG model.
import os
import numpy as np
import pandas as pd
import tensorflow as tf
from tensorflow.python.client import timeline
tf.logging.set_verbosity(tf.logging.DEBUG)