Skip to content

Instantly share code, notes, and snippets.

View WebFreak001's full-sized avatar
💾
Saving the world

Jan Jurzitza WebFreak001

💾
Saving the world
View GitHub Profile
size_t bytesToUTF16Count(size_t bytes)
{
if (bytes > text.length)
bytes = text.length;
size_t offset;
size_t index;
while (index < bytes)
{
switch (text.ptr[index] & 0b1111_0000)
@WebFreak001
WebFreak001 / vibed.system
Created November 20, 2019 17:57
SystemD service for simple web servers
[Unit]
Description=new.webfreak.org
After=network-online.target mongodb.service
[Service]
ExecStart=/srv/http/org.webfreak.new/webfreak.org-v3/webfreak-org-3 --vvv
Restart=always
WorkingDirectory=/srv/http/org.webfreak.new/webfreak.org-v3
User=http
Group=http
/**
* @fires Event#change when checked is changed
* @fires Event#change-mod when mod is changed
* @fires Event#next when the mod was left-clicked or selected with enter
* @fires Event#prev when the mod was right-clicked
*/
export class OsuModCheckbox extends HTMLElement {
protected wrapper: HTMLLabelElement;
protected cb: HTMLInputElement;
protected span: HTMLElement;
module diet2spasm;
import diet.defs;
import diet.dom;
import diet.internal.string;
import diet.input;
import diet.parser;
import diet.traits;
/// Compiles diet code to spasm compatible createElement/textContent/setAttribute D code usable for mixin.
@WebFreak001
WebFreak001 / plurals.d
Last active July 20, 2019 14:40
Implements Mozilla's localization and plurals site in D for i18n
/// Implements mozilla's plural forms.
/// See_Also: https://developer.mozilla.org/en-US/docs/Mozilla/Localization/Localization_and_Plurals
/// Returns: the index which plural word to use. For each rule from top to bottom.
int resolvePlural(int form, int n)
{
import std.algorithm : among;
switch (form)
{
// Asian, Persian, Turkic/Altaic, Thai, Lao
@WebFreak001
WebFreak001 / zopflipng_folder.fish
Created June 25, 2019 13:33
Optimizes a whole folder using zopflipng as fish script (just copy paste into the fish shell)
for file in *.png
echo -n "Optimizing $file..."
if zopflipng -y -m $file (basename $file .png)".min.png" | grep "Result is smaller"
mv (basename $file .png)".min.png" $file
echo " optimized."
else
rm (basename $file .png)".min.png"
echo
end
end
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
<ws2:longPathAware>true</ws2:longPathAware>
</windowsSettings>
</application>
@WebFreak001
WebFreak001 / output.d
Last active January 24, 2018 10:53
traits doc generator
[
ConstantCompletion("allMembers", "$(P Takes a single argument, which must evaluate to either
a type or an expression of type.
A tuple of string literals is returned, each of which
is the name of a member of that type combined with all
of the members of the base classes (if the type is a class).
No name is repeated.
Builtin properties are not included.
)
@WebFreak001
WebFreak001 / d_to_html.d
Last active October 9, 2017 22:17
Create websites using D, with a cool syntax
module d_to_html;
import std.conv;
import std.stdio;
import std.traits;
import std.range;
struct Element
{
string _name;
@WebFreak001
WebFreak001 / backup.sh
Created March 16, 2017 12:38
Backup website & mysql database
#!/bin/sh
id=`date +%Y-%m-%d_%H-%M`
# Creates a backup of a website + database in a .tar.gz file
# Archive structure:
# db.sql
# website_folder/
# Name of backup
appname="mywebsite"