Skip to content

Instantly share code, notes, and snippets.

^!v::SendInput from SendInput: %clipboard%
^!a::WinHide A
^!b::WinShow
@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::
@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 / 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 / demo_urllib.py
Created November 7, 2010 13:56
use a urllib library
import urllib
webpage = urllib.urlopen('http://www.baidu.com')
pagefile = open('baidu.html', 'w')
for lines in webpage.readlines():
pagefile.write(lines)
pagefile.close()
webpage.close()
@uhziel
uhziel / apue.2e.fig1.3.c
Created September 25, 2011 16:23
apue.2e.fig1.3.c
#include "apue.h"
#include <dirent.h>
int main(int argc, char *argv[])
{
DIR *dp;
struct dirent *dirp;
if (argc != 2)
{
@uhziel
uhziel / apue.2e.fig1.4.c
Created September 25, 2011 16:27
apue.2e.fig1.4.c
#include "apue.h"
#define BUFFSIZE 4096
int main()
{
int n;
char buf[BUFFSIZE];
while ((n = read(STDIN_FILENO, buf, BUFFSIZE)) > 0)
@uhziel
uhziel / apue.2e.fig1.5.c
Created September 25, 2011 16:34
apue.2e.fig1.5.c
#include "apue.h"
int main()
{
int c;
while ((c = getc(stdin)) != EOF)
{
if (putc(c, stdout) == EOF)
{
@uhziel
uhziel / apue.2e.fig1.6.c
Created September 26, 2011 16:28
apue.2e.fig1.6.c
#include "apue.h"
int main()
{
printf("hello world from process ID %d\n", getpid());
return 0;
}
@uhziel
uhziel / apue.2e.fig1.7.c
Created September 26, 2011 17:46
apue.2e.fig1.7.c
#include "apue.h"
#include <sys/wait.h>
int main()
{
char buf[MAXLINE];
pid_t pid;
int status;
printf("%% ");