Skip to content

Instantly share code, notes, and snippets.

View m93a's full-sized avatar
🥔
omw to start a commune

Michal m93a

🥔
omw to start a commune
View GitHub Profile
@m93a
m93a / getRelativeURL.js
Created August 26, 2016 10:54
JavaScript URL processing library
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
(function(){
/**
* Rewrite this URL as an URL relative to the base.
* TODO: Doesn't support backslashes!
*
* @parameter {string|URL} base The resulting URL will be relative to this one.
@m93a
m93a / LV Haack nose cone.js
Created February 28, 2017 15:40
This computes the radius of a LV Haack nose cone at each point
function LVHaack(n){
n=+n;
with(Math){
return sqrt( 1/PI * ( acos(1-n/12) - 0.5*sin(2*acos(1-n/12)) + (1/3)*pow(sin(acos(1-n/12)),3) ) )
}
}
/* For LD Haack change `(1/3)*pow` to `0*pow`,
for tangent Haack change it to `(2/3)*pow` */
@m93a
m93a / example.cs
Created June 11, 2017 21:46
Turns a C# event into a Task – this way you can await an event.
namespace App
{
class App
{
public async void Main()
{
var form = new MyForm();
await form.Loaded.Once(); // Magic happens!
form.Activate();
}
@m93a
m93a / .XCompose
Last active August 26, 2023 08:44
Unicode emoticons for Compose key
# Emoji
# http://unicode.org/emoji/charts/full-emoji-list.html
<Multi_key> <e> <m> <o> <colon> <D> : "😀"
<Multi_key> <e> <m> <o> <x> <D> : "😁"
<Multi_key> <e> <m> <o> <x> <apostrophe> <D> : "😂"
<Multi_key> <e> <m> <o> <colon> <apostrophe> <D> : "😂"
<Multi_key> <e> <m> <o> <r> <o> <f> <l> : "🤣"
<Multi_key> <e> <m> <o> <colon> <d> : "😃"
<Multi_key> <e> <m> <o> <x> <parenright> : "😄"
@m93a
m93a / Rozepiš implicitní seznam.vba
Last active August 24, 2017 14:21
Rozepíše implicitní seznam na řádky.
Sub MakeExplicit()
' je potřeba přidat referenci na RegExp:
' v okně maker Nástroje > Reference
' zaškrtnout Microsoft VBScript Regular Expressions 5.5
' detekuje všechny mezery
Dim whitespace As RegExp
Set whitespace = New RegExp
@m93a
m93a / Odděl série řádkem.vba
Created August 24, 2017 13:24
Vlož nový řádek každých 10 čísel. Vhodné pokud máte např. databázi sériových čísel a víte, že každá série má 10 kousků. Tento kód vloží volný řádek mezi série.
Sub InsertSeparatorLines()
' každé číslo má tvar:
' n * signif + c; signif = konst.
'
' když se změní n, tj. číslo série,
' vlož prázdný řádek
' significance
Dim signif As Integer
signif = 10
namespace HydraExtensions
{
/**
* <summary>
* This class contains extensions to event-related
* types, such as EventHandler and EventHandler&lt;T>.
* </summary>
**/
public static class EventExtensions
@m93a
m93a / bash.bat
Created November 7, 2017 10:18
Enable bash.exe for 32-bit programs
@echo off
rem To use bash seamlessly from 32bit apps,
rem add this file to your %PATH%.
if exist C:\Windows\Sysnative\bash.exe (
start "bash.exe" /D "%cd%" /B /wait "C:\Windows\Sysnative\bash.exe" %*
) else (
start "bash.exe" /D "%cd%" /B /wait "C:\Windows\System32\bash.exe" %*
)
@m93a
m93a / fibonacci.js
Created January 15, 2018 23:54
Yet another Fibonacci
(function(){
window.fibonacci = function(){
var n = new Number(1);
n.next = next;
return n;
};
function next(){
var n = new Number( this + (this.prev||0) );
@m93a
m93a / prog.cpp
Created February 10, 2018 16:14
C++ template for empty file
int main(int args_length, char** args){
freopen("prog.txt","w",stdout);
cout.precision(17);
cout << fixed;