Skip to content

Instantly share code, notes, and snippets.

@yongzhy
yongzhy / git-serve.md
Last active September 19, 2017 08:56 — forked from datagrok/git-serve.md
How to easily launch a temporary one-off git server from any local repository, to enable a peer-to-peer git workflow.

Launch a one-off git server from any local repository.

I [tweeted this already][1] but I thought it could use some expansion:

Enable decentralized git workflow: git config alias.serve "daemon --verbose --export-all --base-path=.git --reuseaddr --strict-paths .git/"

Say you use a git workflow that involves working with a core "official" repository that you pull and push your changes from and into. I'm sure many companies do this, as do many users of git hosting services like Github.

Say that server, or Github, goes down for a bit.

@yongzhy
yongzhy / FloatDebug.java
Created March 2, 2017 01:55
Simple code to debug JDK9 float point issue
// javac whetstc.java
// java whetstc
import java.util.*;
import java.io.*;
public class FloatDebug
{
@yongzhy
yongzhy / gist:20993e3e579f30c17d49dcd469700043
Created February 2, 2017 02:52 — forked from mems/gist:5301297
How to convert a (simple) SWF to PDF

Convert (simple) SWF to PDF

In SWFTools a programs called gfx2gfx is available to do this task, but it's not officially available precompiled.

It can convert SWF, PDF or image to SWF, PDF, ebook or image.

For discard downscaling for rasterized image (default: 72dpi) we use the provided by @m-p-y: add -r attribute to increase maxdpi

Requirements

@yongzhy
yongzhy / gist:ca6ec2396ea20e5aabefab9d4e568d72
Created April 26, 2016 02:32
build YCM in msys2 environment
$ pacman -S mingw-w64-x86_64-clang mingw-w64-x86_64-cmake mingw-w64-x86_64-gcc mingw-w64-x86_64-gdb winpty
$ cmake -G "Unix Makefiles" -DUSE_SYSTEM_LIBCLANG=ON -DPYTHON_INCLUDE_DIR=/mingw64/include/python2.7 -DPYTHON_LIBRARY=/mingw64/lib/libpython2.7.dll.a . ../third_party/ycmd/cpp
$ cmake --build . --target ycm_core --config Release
@yongzhy
yongzhy / complete.cc
Last active August 29, 2015 14:13 — forked from xavierd/complete.cc
#include <clang-c/Index.h>
#include <cstdlib>
#include <iostream>
/*
* Compile with:
* g++ complete.cc -o complete -lclang -L/usr/lib/llvm
* Run with:
* LIBCLANG_TIMING=1 ./complete file.cc line column [clang args...]
*/
@yongzhy
yongzhy / benchmark utility in c
Created February 27, 2014 02:28
Utility function for benchmark in C code
#ifdef WIN32
#include <windows.h>
double get_time()
{
LARGE_INTEGER t, f;
QueryPerformanceCounter(&t);
QueryPerformanceFrequency(&f);
return (double)t.QuadPart/(double)f.QuadPart;
}
@yongzhy
yongzhy / gist:9045121
Created February 17, 2014 05:16
golang logging with different level and output to different file
// from http://www.goinggo.net/2013/11/using-log-package-in-go.html
import (
"io"
"log"
)
var (
_TRACE *log.Logger
_INFO *log.Logger
@yongzhy
yongzhy / gist:5450698
Last active December 22, 2016 09:26
Build the silver searcher on Windows using MingW

Build the silver searcher on Windows using MingW

Install Dependency Packages

$mingw-get install pthread
$mingw-get install autotools

Compile and Install Zlib

@yongzhy
yongzhy / Call functions from Windows DLL file.
Created December 3, 2012 05:39
Call functions from Windows DLL file.
//+build windows
package colorterm
import (
"syscall"
"unsafe"
)
type (