Skip to content

Instantly share code, notes, and snippets.

View ALiwoto's full-sized avatar
🚩
Trying to experience new things

ALi.w ALiwoto

🚩
Trying to experience new things
  • Earth. under the blue sky
  • 17:12 (UTC +03:30)
View GitHub Profile
@Justasic
Justasic / message.md
Last active December 22, 2022 22:10
.run() is bad for libraries

.run() is bad for libraries

As a developer I have noticed a trend in libraries where the library developer will write this amazing library that does everything you need it to except that it has a .run() or .start() method. The intent is for the user of said library to do the initialization code in the application entry point and then do something like return app.run();. Whether it's in Python, Java, C++, or Rust they all abstratct away the application's main event loop.

What is an event loop?

@NepNet
NepNet / GlxBindingsContext.cs
Last active December 26, 2024 04:19
Bindings contexts for OpenTK 4. If you need to load the bindings for windows use the wgl one, for linux glx and if you use it in a cross platform app like a gtk one use the native bindings context, it will check the platform and use either wgl or glx depending on the platform. For Mac ¯\_(ツ)_/¯ idk, I don't have a mac to test
using System;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using OpenTK;
public class GlxBindingsContext : IBindingsContext
{
[DllImport("libGL", CharSet = CharSet.Ansi)]
private static extern IntPtr glXGetProcAddress(string procName);
public IntPtr GetProcAddress(string procName)

How to setup a practically free CDN using Backblaze B2 and Cloudflare

⚠️ Note 2023-01-21
Some things have changed since I originally wrote this in 2016. I have updated a few minor details, and the advice is still broadly the same, but there are some new Cloudflare features you can (and should) take advantage of. In particular, pay attention to Trevor Stevens' comment here from 22 January 2022, and Matt Stenson's useful caching advice. In addition, Backblaze, with whom Cloudflare are a Bandwidth Alliance partner, have published their own guide detailing how to use Cloudflare's Web Workers to cache content from B2 private buckets. That is worth reading,

@lisawolderiksen
lisawolderiksen / git-commit-template.md
Last active May 13, 2025 14:13
Use a Git commit message template to write better commit messages

Using Git Commit Message Templates to Write Better Commit Messages

The always enthusiastic and knowledgeable mr. @jasaltvik shared with our team an article on writing (good) Git commit messages: How to Write a Git Commit Message. This excellent article explains why good Git commit messages are important, and explains what constitutes a good commit message. I wholeheartedly agree with what @cbeams writes in his article. (Have you read it yet? If not, go read it now. I'll wait.) It's sensible stuff. So I decided to start following the

@zapstar
zapstar / client.py
Created June 8, 2018 09:01
Python Asyncio SSL client and server examples
#!/usr/bin/env python3
import asyncio
import ssl
@asyncio.coroutine
async def echo_client(data, loop):
ssl_ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ssl_ctx.options |= ssl.OP_NO_TLSv1
@pjeby
pjeby / shelldown-demo
Last active March 14, 2025 19:26
"You got your markdown in my shell script!" "No, you got your shell script in my markdown!"

Mixed Markdown and Shell Scripting

: By the power of this magic string: ex: set ft=markdown ;:<<'```shell' #, this file is now both a markdown document and an executable shell script. chmod +x it and try running it!

The above line does just what it says. More specifically, when placed within in the first 5 lines and preceded only by blank lines or #-prefixed markdown headers:

  1. The first part of the magic string makes github and various editors (e.g. atom with the vim-modeline packge) treat the file as having markdown syntax (even if the file doesn't have an extension)
  2. The second part (if run in a shell), makes the shell skip execution until it encounters the next ```shell block.

(The line also has to start with a : so that it's valid shell code.)

@tomykaira
tomykaira / Base64.h
Last active April 23, 2025 22:58
C++ single header base64 decode/encoder for C++ 11 and above.
#ifndef _MACARON_BASE64_H_
#define _MACARON_BASE64_H_
/**
* The MIT License (MIT)
* Copyright (c) 2016-2024 tomykaira
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@igolaizola
igolaizola / EventSource.cs
Last active September 3, 2024 00:50
C# implementation of Server Side Event Source
/*
* Copyright 2014 Jonathan Bradshaw. All rights reserved.
* Redistribution and use in source and binary forms, with or without modification, is permitted.
*/
using System;
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
using System.Linq;
@Justasic
Justasic / CreateELF.c
Last active June 9, 2021 10:53
This program writes an ELF program out that returns 42 as it's exit value.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdint.h>
#include <sys/mman.h>
// NOTICE: The program this program generates is explicitly 32-bit only (working only on the x86 architecture)
// Reference Documents:
@jetstreamin
jetstreamin / appcmd-command-ref
Created July 8, 2015 20:02
appcmd most common commands
1. Add Site
appcmd add site /name:MySite /bindings:http://*:80 /physicalpath:”d:\MySitePath”
2. Add App Pool
appcmd add apppool /name:MyAppPool /managedRuntimeVersion:v4.0 (e.g. targeting .NET 4.0)
3. Set App Pool Credential
appcmd set config /section:applicationPools /[name='MyAppPool'].processModel.identityType:SpecificUser /[name='MyAppPool'].processModel.userName:MyDomain\MyAccount /[name='MyAppPool'].processModel.password:MyAccountPassword
4.Add App
appcmd add app /site.name:"MySite" /path:/MyApp /physicalpath:"d:\MySitePath\MyApp"
5. Assign/Change App Pool to an App