Skip to content

Instantly share code, notes, and snippets.

View kjk's full-sized avatar

Krzysztof Kowalczyk kjk

View GitHub Profile
#include <iostream>
constexpr long long factorial(int n)
{
long long result = 1;
for (int i = 1; i <= n; ++i) {
result *= i;
}
return result;
}
#include <iostream>
constexpr long long factorial(long long n)
{
if (n == 0)
return 1;
else
return n * factorial(n - 1);
}
#include <iostream>
constexpr long long factorial(long long n)
{
return (n == 0) ? 1 : n * factorial(n - 1);
}
int main()
{
char test[factorial(3)];
#include <iostream>
#include <type_traits>
template<long long n>
struct factorial :
std::integral_constant<long long, n * factorial<n - 1>::value> {};
template<>
struct factorial<0> :
std::integral_constant<long long, 1> {};
#include <iostream>
template<unsigned int n>
struct factorial
{
enum
{
value = n * factorial<n - 1>::value
};
};
@kjk
kjk / create_zip_file.go
Last active June 29, 2020 08:45
Create ZIP file in Go (made with https://codeeval.dev)
package main
import (
"archive/zip"
"fmt"
"io"
"log"
"os"
"path/filepath"
)
@kjk
kjk / check default program windows.txt
Created April 9, 2020 03:02
checking / setting default programs on windows (made with https://codeeval.dev)
Source code examples:
* https://grep.app/search?q=IApplicationAssociationRegistration&filter[lang][0]=C%2B%2B
* https://github.com/QupZilla/qupzilla/blob/master/src/lib/other/registerqappassociation.cpp
* https://github.com/mpc-hc/mpc-hc/blob/master/src/mpc-hc/FileAssoc.cpp
* https://github.com/syndicodefront/infekt/blob/master/src/win32/default_app_win7.cpp
* https://github.com/syndicodefront/infekt/blob/master/src/win32/default_app_win8.cpp
In gecko-dev source code:
* Telemetry.cpp
package main
// https://blog.kowalczyk.info/article/wOYk/advanced-command-execution-in-go-with-osexec.html
import (
"bytes"
"fmt"
"io"
"log"
"os"
package main
// https://blog.kowalczyk.info/article/wOYk/advanced-command-execution-in-go-with-osexec.html
import (
"fmt"
"os/exec"
)
func checkExeExists(exe string) {
package main
// https://blog.kowalczyk.info/article/wOYk/advanced-command-execution-in-go-with-osexec.html
import (
"fmt"
"log"
"os"
"os/exec"
)