This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def findfrac(val=math.sqrt(2)): | |
ratio={} | |
for i in range(1,100): | |
for j in range(1,100): | |
ratio[i*100+j]=math.fabs(i/j-val) | |
mk,mv=None,10000 | |
for k,v in ratio.items(): | |
if v<mv: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
param ( | |
[Parameter(Position = 0)]$Range, | |
[Parameter()][switch]$Long | |
) | |
function GetWeekOfYear() { | |
param($d) | |
$cal = [cultureinfo]::InvariantCulture.Calendar | |
return $cal.GetWeekOfYear($d, [System.Globalization.CalendarWeekRule]::FirstFullWeek, [System.DayOfWeek]::Monday) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Derived from the Earendel colorscheme by Georg Dahn: | |
" http://vim.sourceforge.net/scripts/script.php?script_id=2188 | |
hi clear | |
if exists("syntax_on") | |
syntax reset | |
endif | |
let colors_name = "paperwork" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
avail=$(sed -ne 's/^MemAvailable:\s*\([0-9]\+\) .*/\1/p' /proc/meminfo) | |
high=$(expr $avail \* 70 / 100) | |
max=$(expr $avail \* 85 / 100) | |
systemd-run --user --slice limake.slice --scope --same-dir --collect -p MemoryHigh=${high}K -p MemoryMax=${max}K /usr/bin/make "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <errno.h> | |
#include <uchar.h> | |
#include <iconv.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <unistd.h> | |
#include <fcntl.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::string format_percentage(uintmax_t a, uintmax_t b, unsigned int precision = 0) { | |
if (b == 0) | |
return "??%"s; | |
else if (a == 0) | |
return "0%"s; | |
else if (a == b) | |
return "100%"s; | |
else if (a > b) | |
return ">100%"s; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <unistd.h> | |
#include <sys/eventfd.h> | |
int main(int argc, char *argv[]) { | |
int ret; | |
bool nonblock = false; | |
if (argc == 2 && std::string("--nonblock") == argv[1]) { | |
std::cout << "enabling nonblock\n"; | |
nonblock = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Windows.h> | |
int main() { | |
PROCESS_POWER_THROTTLING_STATE pi = { | |
PROCESS_POWER_THROTTLING_CURRENT_VERSION, | |
PROCESS_POWER_THROTTLING_EXECUTION_SPEED, | |
PROCESS_POWER_THROTTLING_EXECUTION_SPEED | |
}; | |
SetProcessInformation(GetCurrentProcess(), ProcessPowerThrottling, &pi, sizeof(pi)); | |
SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> | |
<Product | |
Id="*" | |
Name="NanaZip" | |
Language="!(bind.fileLanguage.NanaZip.exe)" | |
Version="!(bind.fileVersion.NanaZip.exe)" | |
Manufacturer="Kenji Mouri" | |
UpgradeCode="951cc21a-fbaa-44b1-82e2-c4f8eb57af02"> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CPPFLAGS+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -MMD -MP | |
CFLAGS+=-Wall -Wextra -Wformat=2 -std=c11 | |
CXXFLAGS+=-Wall -Wextra -Wformat=2 -std=c++20 | |
# optional, add dependencies if needed | |
CPPFLAGS+=-pthread | |
LDLIBS+=-pthread | |
ifeq ($(HARDENING), 1) | |
CPPFLAGS+=-D_FORTIFY_SOURCE=2 |
NewerOlder