Skip to content

Instantly share code, notes, and snippets.

@uhziel
uhziel / size.cpp
Created May 19, 2014 02:57
The size of scalars
#include <iostream>
int main()
{
std::cout << "The size of scalars:" << std::endl;
std::cout << "int\t" << sizeof(int) << std::endl;
std::cout << "long\t" << sizeof(long) << std::endl;
std::cout << "short\t" << sizeof(short) << std::endl;
return 0;
@uhziel
uhziel / appendfile.c
Last active August 29, 2015 14:01
c append text to file
#include <cstdio>
int main(int argc, char *argv[])
{
FILE* f = fopen("assert.log", "a");
fputs("hello", f);
fclose(f);
return 0;
}
@uhziel
uhziel / WLost.ahk
Last active August 29, 2015 14:00
WLost(The lost function of Windows)
; ^ ctrl ! alt # win
; super paste
SetKeyDelay 30
#v::Send {raw}%clipboard%
; hide window
#PgDn::
^!v::SendInput from SendInput: %clipboard%
^!a::WinHide A
^!b::WinShow
@uhziel
uhziel / double_to_float.c
Created January 26, 2014 02:14
double 转 float 精度的丢失
/*
* (gdb) print d
* $1 = 10.1
* (gdb) print f
* $2 = 10.1000004
*/
#include <stdlib.h>
int main() {
@uhziel
uhziel / touchme.cs
Created December 2, 2013 13:23
把这个绑定到一个盒子上,每点击一次,盒子生命减1。生命结束时,盒子死亡。
using UnityEngine;
using System.Collections;
public class touch : MonoBehaviour {
public int life = 3;
// Use this for initialization
void Start () {
}
@uhziel
uhziel / touchit.cs
Created December 2, 2013 10:31
显示有多少个手指头按上屏幕
using UnityEngine;
using System.Collections;
public class touchit : MonoBehaviour {
private string result = "none";
// Use this for initialization
void Start () {
@uhziel
uhziel / bmi.lua
Created September 25, 2013 23:36
function bmi(w, h)
-- BMI 身体质量指数 用来衡量胖瘦和是否健康的一个标准
-- 体重过低 <18.5
-- 体重正常 18.5~23.9
-- 超重 24.0~27.9
-- 肥胖 ≥28
-- http://zh.wikipedia.org/wiki/%E8%BA%AB%E9%AB%98%E9%AB%94%E9%87%8D%E6%8C%87%E6%95%B8
-- w:体重 kg
-- h:身高 m
return w / (h * h)
[palsenberg-repo]
name=palsenberg-repo for CentOS 5
baseurl=http://www.palsenberg.com/rpmrepo/
gpgcheck=0
@uhziel
uhziel / test_constructor.cpp
Created July 23, 2013 05:53
测试“形参为对象时的默认参数”
#include <iostream>
class Foo {
public:
Foo() : a(0) {}
public:
int a;
};
void myprint(const Foo& foo = Foo()) {