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.

Visual Studio for

omnibus-gitlab与系统默认nginx的强行融合

只需从/var/opt/gitlab/nginx/conf/nginx.conf中提取关键配置,插入到系统nginx.conf之中。

/etc/gitlab/gitlab.rb中的nginx['enable']禁用,unicorn['enable']启用。

sudo gitlab-ctl reconfigure

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

【170504】服务器管理记录(CentOS 7 2)

  • Some port may be blocked by the firewall, thus cannot be visit.

iptables -L -n

Check /etc/sysconfig/iptables and edit the rules, then restart the iptable service to make it work.

service iptables restart

  • tomcat default port

See /usr/local/apache-tomcat/conf/server.xml

  • nginx default port

ps aux | grep nginx

/usr/local/nginx/conf/nginx.conf

listen 8080 default_server;
listen [::]:8080 default_server ipv6only=on;

error adding listener addr=/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket

chown git gitlab.socket

adding listener failed addr=127.0.0.1:8080 (in use)

gitlab-ctl tail unicorn

  • firewalld

systemctl unmask firewalld

systemctl start firewalld

systemctl status firewalld

sudo firewall-cmd –permanent –add-service=http

  • nginx configure compatible with gitlab
# gitlab socket 文件地址
upstream gitlab {
  server unix://var/opt/gitlab/gitlab-rails/sockets/gitlab.socket;
}

server {
  listen *:8080;

  server_name gitlab.semprathlon.net;   # 

  server_tokens off;     # don't show the version number, a security best practice
  root /opt/gitlab/embedded/service/gitlab-rails/public;

  # Increase this if you want to upload large attachments
  # Or if you want to accept large git objects over http
  client_max_body_size 250m;

  # individual nginx logs for this gitlab vhost
  access_log  /var/log/gitlab/nginx/gitlab_access.log;
  error_log   /var/log/gitlab/nginx/gitlab_error.log;

  location / {
    # serve static files from defined root folder;.
    # @gitlab is a named location for the upstream fallback, see below
    try_files $uri $uri/index.html $uri.html @gitlab;
  }

  # if a file, which is not found in the root folder is requested,
  # then the proxy pass the request to the upsteam (gitlab unicorn)
  location @gitlab {
    # If you use https make sure you disable gzip compression 
    # to be safe against BREACH attack

    proxy_read_timeout 300; # Some requests take more than 30 seconds.
    proxy_connect_timeout 300; # Some requests take more than 30 seconds.
    proxy_redirect     off;

    proxy_set_header   X-Forwarded-Proto $scheme;
    proxy_set_header   Host              $http_host;
    proxy_set_header   X-Real-IP         $remote_addr;
    proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header   X-Frame-Options   SAMEORIGIN;

    proxy_pass http://gitlab;
  }

  # Enable gzip compression as per rails guide: http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression
  # WARNING: If you are using relative urls do remove the block below
  # See config/application.rb under "Relative url support" for the list of
  # other files that need to be changed for relative url support
  location ~ ^/(assets)/  {
    root /opt/gitlab/embedded/service/gitlab-rails/public;
    # gzip_static on; # to serve pre-gzipped version
    expires max;
    add_header Cache-Control public;
  }

  error_page 502 /502.html;
}
  • gitlab 502 error debug

gitlab-ctl tail

gitlab.socket permission denied

sudo usermod -aG gitlab-www git

http://www.doocr.com/articles/58b1599ee21ae505cb93a717

chgrp -R gitlab-www /var/opt/gitlab/gitlab-rails

chown -R www /var/opt/gitlab/gitlab-rails

  • ./configure, cannot find htmlcxx. Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-stand …

https://askubuntu.com/questions/210210/pkg-config-path-environment-variable

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

  • error while loading shared libraries: libhtmlcxx.so.3: cannot open shared object file: No such file

http://stackoverflow.com/questions/480764/linux-error-while-loading-shared-libraries-cannot-open-shared-object-file-no-s

sudo ldconfig

黑苹果折腾第六迭代已在路上

第五迭代中凭借积累的经验与clover存档、kext存档,顺利安装了OSX10.11.6,成功仿冒了rMbP。睡眠问题是极难迈过去的坎,通过App Store的某些应用可禁用睡眠,保持稳定。

意外发现是虽然HDMI输出与VGA输出互斥,在引导阶段连上VGA接口就有机会启用VGA视频输出。

现阶段,仿冒iMac(21inch)硬件已到位,NVIDIA及时发布了适用于Pascal架构的显卡驱动。升级系统至macOS Sierra 10.12.4并安装最新NVIDIA web driver即可成功驱动GTX1060,拉开了第六迭代的序幕。

观察新版Clover(版本号>4000),Boot without caches选项不复存在,因为macOS 10.12.4启动时始终加载prelinked cache

macOS不支持Intel VT-d特性,该特性与虚拟机相关。若BIOS启用了相关特性则需要Clover选项dart=0禁用之,否则System panic in nanosecondsVT-x特性仍受支持。

鼠标DPI键的隐藏功能

按住DPI键5秒以上,鼠标滚轮功能会切换为音量调节,鼠标中键变为播放/暂停。

Airbnb再曝种族歧视问题:房东拒接亚洲客

<div><img src="http://n.sinaimg.cn/tech/transform/20170407/0upN-fyecrxv4438545.jpg" data-link="" alt="Airbnb再曝种族歧视问题:房东拒接亚洲客"/><span></span></div> <p>  新浪科技讯&nbsp;北京时间4月7日晚间消息,旅行房屋租赁平台Airbnb日前表示,一位房东在得知租客的“亚洲人”身份之后单方面取消了住宿预约,现已永久停止与该涉事房东合作。</p> <p>  Airbnb在接受《赫芬顿邮报》采访时称,该事件发生在今年2月份,位于加州大熊湖(Big&nbsp;Bear)附近。日前,网上出现了一段涉事女租客在雪夜里哭诉委屈的视频,使得该事件得以曝光,并引发了人们的关注。Airbnb以公司隐私政策为由,拒绝透露涉事房东和租客的身份。</p> <p>  这位女租客在视频中描述了事件原委。她说:“大约一个月前,我们在Airbnb上进行了预订。我当时问女房东,是否可以再加两个人,女房东说可以,只要我们肯加钱。”</p> <p>  女住客接着说:“我们计划去大熊湖滑雪。住宿问题解决后,我们认为一切就绪,于是准备驱车去大熊湖。随后,我再次向女房东确认,我带了两位朋友一起住宿,是用现金支付吗?”</p> <p>  没想到对方突然改变态度说:“不行,我们算了吧。”然后挂了电话,并单方面取消了订单。于是,女租客用短信告知房东,将向Airbnb举报她的行为。而女房东则回复称:“去吧,就算地球上只剩你一个人,我也不会租给你。”然后说出拒客原因:“一句话,因为你是亚洲人。”</p> <p>  此外,女房东在短信中还称:“我不允许这个国家让外国人去告诉我们怎样做。这就是为什么我们选了特朗普。”</p> <p>  但女租客却称,她是美国公民。显然,女房东只根据女租客的资料照片做出了错误的判断,以为她是外国人。女租客在视频中哭泣着说:“她们看到我是亚洲人,她们看到的只是我的种族。这就是我们所遭受的待遇,让人痛心。”</p> <p>  对此,Airbnb发言人克里斯托弗·纳尔蒂(Christopher&nbsp;Nulty)在一份声明中称:“房东的行为令人憎恶和无法容忍。”纳尔蒂还称,在得知该事件后,Airbnb立即与女租客取得联系,希望能帮助她们重新预订房间,但女租客已另有安排。</p> <p>  纳尔蒂还称:“根据我们的非歧视政策,涉事房东已被永久性地从Airbnb平台移除。”</p> <p>  早在2015年12月,Airbnb就曾曝出种族歧视问题。当时,哈佛大学进行的一项研究表明,如果租客的名字听起来像黑人,在Airbnb上租到房子的概率就会降低。</p> <p>  去年9月,Airbnb引入新规,旨在反对种族歧视问题。这些新规包括:预订过程中将用户照片最小化,要求用户同意反歧视协议和扩大极速预订范围等。极速预订可以让顾客直接预订,不必经过房东审核批准。(李明)</p>