Skip to content

Instantly share code, notes, and snippets.

View luoyetx's full-sized avatar

Jie Zhang luoyetx

View GitHub Profile
@luoyetx
luoyetx / sleep.c
Created March 25, 2016 02:32
cross platform sleep function
#ifdef WIN32
#include <windows.h>
#define JDA_SLEEP(ms) Sleep(ms)
#else
#include <unistd.h>
#define JDA_SLEEP(ms) usleep(ms)
#endif
#include <unistd.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/epoll.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
typedef struct {
#!/usr/bin/env python
import pdfkit
chapters = [
'intro',
'linear_algebra',
'prob',
'numerical',
# add c++11 flags for gcc
if (CMAKE_COMPILER_IS_GNUCXX)
set(ENABLE_CXX11 "-std=c++11")
if (GCC_VERSION VERSION_LESS 4.7)
set(ENABLE_CXX11 "-std=c++0x")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ENABLE_CXX11}")
endif()
@luoyetx
luoyetx / mxnet.build.bat
Last active August 29, 2017 14:57
build mxnet on windows
call "C:/Program Files (x86)/IntelSWTools/compilers_and_libraries/windows/mkl/bin/mklvars.bat" intel64
cmake .. -DBLAS=MKL -DCUDA_TOOLKIT_ROOT_DIR="%CUDA_PATH%" -G "Visual Studio 14 2015 Win64"
@luoyetx
luoyetx / timer.h
Last active February 28, 2023 10:37
macros for time evaluation
#include <chrono>
/*! \brief Timer */
class Timer {
using Clock = std::chrono::high_resolution_clock;
public:
/*! \brief start or restart timer */
inline void Tic() {
start_ = Clock::now();
}
@luoyetx
luoyetx / LOG.c
Created August 2, 2016 02:47
logging
#include <time.h>
#include <stdio.h>
#include <stdarg.h>
void LOG(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
char msg[256];
vsprintf(msg, fmt, args);
va_end(args);
#ifdef DEBUG
#define cudaCheckError(ans) { cudaAssert((ans), __FILE__, __LINE__); }
inline void cudaAssert(cudaError_t code, const char *file, int line, bool abort=true)
{
if (code != cudaSuccess)
{
fprintf(stderr, "CUDA Error: %s at %s:%d\n",
cudaGetErrorString(code), file, line);
if (abort) exit(code);
}
{
"color_scheme": "Packages/Theme - Afterglow/Afterglow.tmTheme",
"default_line_ending": "system",
"font_size": 14,
"ignored_packages":
[
"Vintage"
],
"tab_size": 2,
"tabs_medium": true,
@luoyetx
luoyetx / a.py
Created September 5, 2016 07:18
solve an email address
import math
ps = [
0.0000008110673199286165000000000000000000,
0.0000162907226016170940000000000000000000,
0.0024177576053697383000000000000000000000,
0.0000000054649286143693143000000000000000,
0.0003272079103201879800000000000000000000,
0.0000000148552161462659780000000000000000,