Skip to content

Instantly share code, notes, and snippets.

View hlgsdx's full-sized avatar

hlgsdx

View GitHub Profile
@hlgsdx
hlgsdx / main.cpp
Created May 27, 2018 14:22
SDL2:↑↓←→按键控制图片切换
#include <SDL.h>
#include <cstdio>
#include <iostream>
using namespace std;
//窗口宽
const int SCREEN_WIDTH = 640;
//窗口高
const int SCREEN_HEIGHT = 480;
@hlgsdx
hlgsdx / main.cpp
Created May 28, 2018 03:25
SDL2:加载JPG图片
#include <SDL.h>
#include <SDL_image.h>
#include <cstdio>
#include <iostream>
using namespace std;
//窗口宽
const int SCREEN_WIDTH = 1024;
//窗口高
@hlgsdx
hlgsdx / main.cpp
Created May 31, 2018 02:13
二维数组中的查找
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
//https://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e
class Solution {
public:
bool Find(int target, vector<vector<int> > array) {
vector<int>::iterator iterSmall;
vector<vector<int> >::iterator iterBig;
@hlgsdx
hlgsdx / main.c
Created June 2, 2018 01:52
Linux exec族 函数
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
/*用fork创建子进程后执行的是和父进程相同的程序(但有可能执行不同的代码分支),
* 子进程往往要调用一种exec函数以执行另一个程序。
* 当进程调用一种exec函数时,该进程的用户空间代码和数据完全被新程序替换,
* 从新程序的启动例程开始执行。调用exec并不创建新进程,所以调用exec前后该进程的id并未改变。
* 其实有六种以exec开头的函数,统称exec函数:
@hlgsdx
hlgsdx / main.c
Created June 2, 2018 03:07
execl 练习:通过文件描述符重定向 将文件内容变大写输出
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define BUF_SIZE 0x1000
@hlgsdx
hlgsdx / main.c
Created June 2, 2018 06:19
Linux waitpid
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <sys/types.h>
int main() {
pid_t pid, wpid;
int status, i;
@hlgsdx
hlgsdx / main.c
Created June 2, 2018 12:48
Linux 多进程文件复制
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
void CreateProcess(char *src, char *des, unsigned long int blocksize, int proc_num);
@hlgsdx
hlgsdx / bdcc.sh
Last active October 30, 2018 05:14
Bilibili Bangumi Downloaded Content Converter Script
#!/bin/bash
echo '---My Bili Bangumi Downloaded Content Converter---'
for folder in `find . -maxdepth 1 -type d`
do
if [[ "$folder" == '.' ]]; then
continue
else
pushd $folder
if [ -e 'entry.json' ]; then
fd="`jq -r '.type_tag' < 'entry.json'`"
@hlgsdx
hlgsdx / DWM.reg
Created February 17, 2019 09:20
Windows 7 DWM default values
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM]
"Composition"=dword:00000001
"ColorizationOpaqueBlend"=dword:00000001
"EnableAeroPeek"=dword:00000001
"CompositionPolicy"=dword:00000002
"AlwaysHibernateThumbnails"=dword:00000000
"LastDisqualifiedCompositionSignature"=dword:000c0000
@hlgsdx
hlgsdx / sound_playback.c
Last active February 23, 2019 13:33 — forked from ghedo/sound_playback.c
Simple sound playback using ALSA API and libasound
/*
* Simple sound playback using ALSA API and libasound.
*
* Compile:
* $ cc -o play sound_playback.c -lasound
*
* Usage:
* $ ./play <sample_rate> <channels> <seconds> < <file>
*
* Examples: