Prepare for deep learning based on GPU with Python

  • OS: Ubuntu 16.04

  • Building prerequisities: make build-essential python3-dev

  • Parallel computing prerequisities: cuda8.0 cudnn6.0

export CUDA_HOME=/usr/local/cuda
export PATH=$PATH:/usr/include:/usr/local/cuda/include
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/usr/lib/x86_64-linux-gpu/:usr/local/cuda/lib64

  • Python 3.5 packages: chainer tensorflow-gpu cupy

nvidia-cuda-dev is only required when building cupy locally.

If python package installation fails, try with sudo pip install --force-reinstall --ignore-installed --no-cache-dir -vvvv to debug.

淘宝IP地址库接口

$.get('http://ip.taobao.com/service/getIpInfo.php?ip=','json',function(res){
    p=JSON.parse(res);
    p=p.data;
    for(var key in p){
            console.log(key + " -> " + p[key]);
    }
})

How to compile OpenGL applications with GLUT

Compile manually with mingw

Set environment variables $CPATH$ and LIBRARY_PATH to locate glut.h and glut32.lib.
If they are not set, use option -I'[include_path]' and -L'[library_path]'.

g++ [source_file] -o [target_file] -lfreeglut -lopengl32 -Wl,–subsystem,windows

Build with Sublime Text

Create a new build system.

{
“cmd”: [“g++”, “${file}”, “-o”,”${file_path}/${file_base_name}”,”-lfreeglut”,”-lopengl32”,”-lglu32”,”-Wl,–subsystem,windows”],
“working_dir”: “${file_path}”,
“variants”:
[
{
“name”: “Run”,
“cmd”: [“cmd”,”/C”,”${file_path}/${file_base_name}.exe &pause”]
}
]
}

Build with CMake

Help about configurations
CMakeLists

## OpenGL
FIND_PACKAGE(OpenGL REQUIRED)
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
## OpenGL
FIND_PACKAGE(GLUT REQUIRED)
INCLUDE_DIRECTORIES(${GLUT_INCLUDE_DIR})

TARGET_LINK_LIBRARIES([project_name] ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})

Error when starting GLUT app when compiled for 64 bit

The application was unable to start correctly (0xc000007b). Click OK to close the application.

Make sure to link with the correct (64-bit) version of the library, and there is the correct (64-bit) dll available on the path.

js ajax发起跨域请求

常见的错误:

No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://xxx.com' is therefore not allowed access.

禁止跨域请求是浏览器的安全机制的一部分,不能随便绕开。

即便采用axios,本质上仍是XMLHttpRequest,会遇到同样的问题。

在不能触及被请求端的后端的前提下,需要使用代理来启用Access-Control-Allow-Origin

现在有了一种便捷手段:https://bird.ioliu.cn/

https://segmentfault.com/q/1010000007665348

Visual Studio for Mac offline installation

Note that the recent release is no longer a preview version.

When trying out the Visual Studio Mac downloader from Microsoft, you will find it with “network error” and not pushing forward anymore.

However, disconnect the network and it will give in, providing with offline downloading links.

It was not possible to complete an automatic installation. This might be due to a problem with your network, proxy servers or an unsolvable installation conflict. At this point, you can continue the installation by manually downloading and installing the independent pieces. The list below shows each component that you need to install.

Mono Framework

Download the Mono Framework v5.0.0 archive to any directory on your disk, double-click it and follow the instructions on screen. Please accept all the defaults during the installation, including the target drive.

Android SDK

Download the Android SDK for Mac OS X version 24.4.1, open the downloaded archive and copy the contents of the folder found at its root directory (most probably named android-sdk-macosx) to the /Users/semprathlon/Library/Developer/Xamarin/android-sdk-macosx directory.

Click here in order to start the Android SDK Manager application. In the GUI make sure the following components are installed or selected for installation:

  • Android SDK Tools
  • Android SDK Platform-tools
  • Android SDK Build-tools
  • Android API 15
  • Android API 19
  • Android API 21

Once all the required components are selected (you can select others as well, if you wish) start the installation.
If you cannot see /Users/semprathlon/Library/Developer/Xamarin/android-sdk-macosx in Finder please click here to reveal the directory in Finder.

Download the Android NDK for Mac OS X version r10e, open the downloaded archive and copy the contents of its root directory (most probably named android-ndk-r10e) to the /Users/semprathlon/Library/Developer/Xamarin/android-ndk directory.

When the Android SDK installation is finished you might want to start the Android Emulator Manager and create as many emulator images as you might need for your development. This step can be performed at any time, on an as-needed basis.

Visual Studio

Download the Visual Studio v7.0.0 archive to any directory on your disk, double-click it and then drag and drop the Visual Studio icon to the Applications folder.

Xamarin.Android

Download the Xamarin.Android v7.3.0 archive to any directory on your disk, double-click it and follow the instructions on screen. Please accept all the defaults during the installation, including the target drive.

Xamarin.iOS

Download the Xamarin.iOS v10.10.0 archive to any directory on your disk, double-click it and follow the instructions on screen. Please accept all the defaults during the installation, including the target drive.

Xamarin.Mac

Download the Xamarin.Mac v3.4.0 archive to any directory on your disk, double-click it and follow the instructions on screen. Please accept all the defaults during the installation, including the target drive.

Github Repo管理重要“灭火救急”技能

  • 放弃本地所有未提交的更改

https://www.v2ex.com/t/66718

git fetch [origin branch-name]
git reset –hard [origin/branch-name]
git clean -df

  • sync forked reposities

https://segmentfault.com/q/1010000002590371

git remote -v

git remote add upstream URL

git fetch upstream
git merge upstream/master

  • revoke commit

https://segmentfault.com/q/1010000000115900

git reset –hard HEAD~1
git push –force

Visual Studio - NET开发杂项

Visual Studio shortcut keys

  • error C2011: ‘’ : ‘class’ type redefinition

    #pragma once

  • C#语言编写风格

    将C++中的->,::,.合并为一种运算符应当是很有意义的。
    在编写托管程序时相当具有优势,不必再纠结于*^newgcnew
    using语句块可体现其独特性。

  • StreamReader类

    StreamReader不仅采用流的方式,而且对于操作系统中文件的处理更具功能性,能修正字符集错误。

    using (StreamReader sr1 = new StreamReader(FILE_INFO_NAME,UnicodeEncoding.GetEncoding(“GB2312”)));
    StreamReader reader=new StreamReader(fileName,System.Text.Encoding.Default)

  • One-Click Publish

    对于使用C#开发的项目,Visual Studio提供了Click-once App打包方式。
    打包时为了让资源文件也能被包含在生成文件中,需将相关文件build action改为Content

  • 发布独立可执行文件的注意事项

    不要随便拿个Debug生成的可执行文件扔给老哥。
    Debug 和 Release 的真正秘密,在于一组编译选项。
    注意工具集和平台运行库的选择。
    MFC的使用方式。