Skip to content

Instantly share code, notes, and snippets.

View kjk's full-sized avatar

Krzysztof Kowalczyk kjk

View GitHub Profile
@kjk
kjk / fakemenu.c
Last active September 24, 2021 13:19
how to implement menu-like pop-up the right way in win32
/*****************************************************************************
* Sample program to demonstrate how a program can display a
* popup window which does not deactivate its parent. This
* can be used for things like a magnifying glass window or
* a pseudo-menu.
*****************************************************************************/
#define STRICT
#include <windows.h>
#define COMPILE_MULTIMON_STUBS
@kjk
kjk / main.go
Created June 22, 2021 02:27
pretty print JSON (made with https://codeeval.dev)
package main
import (
"fmt"
"encoding/json"
"github.com/tidwall/pretty"
)
var prettyOpts = pretty.Options{
Width: 80,
#include <iostream>
int main()
{
int x = 1;
if (x > 0) {
std::cout << "x (" << x << ") is greater than zero\n";
}
}
package main
// https://blog.kowalczyk.info/article/wOYk/advanced-command-execution-in-go-with-osexec.html
import (
"fmt"
"io"
"log"
"os"
"os/exec"
package main
import (
"flag"
"fmt"
"log"
"os"
"runtime/debug"
"runtime/pprof"
"strconv"
@kjk
kjk / windows.h__.js
Created October 4, 2016 00:08
windows.h.js INFINITY
var ffi = require('ffi'),
ref = require('ref'),
Struct = require('ref-struct'),
Library = require('./Library'),
Type = ref.Type,
NULL = ref.NULL,
isNull = ref.isNull;
var groups = ['libs', 'types', 'structs', 'callbacks', 'enums'];
#include <iostream>
#include <string>
#include <bitset>
int main(int argc, char **argv) {
int a = 0b0101;
a |= 0b1101;
std::cout << "a = " << std::bitset<8>(a) << std::endl;
}
#include <iostream> // std::cout
#include <atomic> // std::atomic, std::memory_order_relaxed
#include <thread> // std::thread
std::atomic_int foo (0);
void set_foo(int x) {
foo.store(x); // set value atomically
}
@kjk
kjk / main.cc
Created July 21, 2020 08:33
Example for sort (made with https://codeeval.dev)
#include <algorithm> // std::sort
#include <iostream>
#include <vector> // std::vector
using namespace std;
int main()
{
vector<int> a{3, 8, 1, 5, -8, 33, 4};
sort( a.begin(), a.end() );
int const n = a.size();
#include <complex>
#include <iostream>
int main()
{
using namespace std::literals::complex_literals;
std::complex<double> c = 2.0 + 1i; // {2.0, 1.}
std::complex<float> cf = 2.0f + 1if; // {2.0f, 1.f}
std::complex<long double> cl = 2.0L + 1il; // {2.0L, 1.L}