Skip to content

Instantly share code, notes, and snippets.

View roy4801's full-sized avatar
🎯
Focusing

roy4801

🎯
Focusing
View GitHub Profile
@roy4801
roy4801 / jobobject.cpp
Last active September 8, 2023 07:33
Limit CPU usage >= Windows 8 (JOBOBJECT_CPU_RATE_CONTROL_INFORMATION)
HANDLE hJob = CreateJobObject( NULL, NULL );
JOBOBJECT_CPU_RATE_CONTROL_INFORMATION cpuRateControlInformation;
ZeroMemory( &cpuRateControlInformation, sizeof( cpuRateControlInformation ) );
int cpuUsagePercent = 30;
cpuRateControlInformation.CpuRate = cpuUsagePercent * 100;
cpuRateControlInformation.ControlFlags = JOB_OBJECT_CPU_RATE_CONTROL_ENABLE | JOB_OBJECT_CPU_RATE_CONTROL_HARD_CAP;
if ( !SetInformationJobObject( hJob, JobObjectCpuRateControlInformation, &cpuRateControlInformation, sizeof( cpuRateControlInformation ) ) )
#!/bin/bash
# Do not add the trailing slash
INPUT_HOST=127.0.0.1
INPUT_PORT=1859
INPUT_URL=$INPUT_HOST:$INPUT_PORT
OUTPUT_HOST=
OUTPUT_PORT=1859
OUTPUT_URL=$OUTPUT_HOST:$OUTPUT_PORT
@roy4801
roy4801 / msys2-visual-studio-code.md
Created April 2, 2020 13:03 — forked from dhkatz/msys2-visual-studio-code.md
Using MSYS2 with Visual Studio Code

Using MSYS2 with Visual Studio Code is extremely easy now thanks to the Shell Launcher extension by Tyriar.

First, install the extension and reload Visual Studio Code.

Then, open the settings.json to edit your settings.

Add the field shellLauncher.shells.windows. I recommend using autocompletion here so that all the default shells are added.

You should having something like this now:

@roy4801
roy4801 / ffmpeg.md
Created January 16, 2020 13:36 — forked from protrolium/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

@roy4801
roy4801 / server.cpp
Last active November 28, 2019 17:30
#include <iostream>
#include <cstring>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
char buffer[1024];
const char *hello = "Hello from server";
@roy4801
roy4801 / 167.cpp
Created November 24, 2019 17:54
Uva 167
#include <bits/stdc++.h>
using namespace std;
int kase;
int ch[8][8];
int queen[100][8]; // [which][i] = j
int cnt;
vector<int> now;
int row[10], L[20], R[20];
void build(int j)
{
#include <bits/stdc++.h>
using namespace std;
#define PROB "D"
#define TESTC ""
#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long int LL;
typedef unsigned long long ULL;
/*
* VJUDGE D - Aquarium
* author: roy4801
* (C++)
*/
#include <bits/stdc++.h>
using namespace std;
#define PROB "D"
/*
* HOJ 464 - 菇菇園
* author: roy4801
* (C++)
*/
#include <bits/stdc++.h>
using namespace std;
#define PROB "464"
/*
* VJUDGE C - GCD on Blackboard
* author: roy4801
* (C++)
*/
#include <bits/stdc++.h>
using namespace std;
#define PROB "C"