Skip to content

Instantly share code, notes, and snippets.

@poi519
poi519 / screenoff.c
Last active October 23, 2019 15:11
Turns off the screen. Build `cl screenoff.c user32.lib`
#include <windows.h>
int main() {
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2);
}
@poi519
poi519 / philosophers.c
Created October 23, 2019 14:10
Dining philosophers in C using WinApi. Running: philosophers.exe num_threads fix?
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
int fix = FALSE;
DWORD WINAPI dine(LPVOID param);
typedef struct {
int id;
@poi519
poi519 / philosophers.c
Created October 23, 2019 14:09
Dining philosophers in C using WinApi. Running: philosophers.exe 10
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
int fix = FALSE;
DWORD WINAPI dine(LPVOID param);
typedef struct {
int id;
#lang racket
(require compatibility/defmacro)
(define-macro (bin-search-macro name
quick-return-case
bounds-equal-case
middle-is-ok-case)
`(define (,name str v)
(define len (string-length str))
@poi519
poi519 / config.py
Last active February 2, 2017 14:08
class Conf:
pass
xmpp = Conf()
tele = Conf()
xmpp.jid = "[email protected]"
xmpp.password = "xxxx"
xmpp.room = "[email protected]"
xmpp.listener_nick = "anonka"
@poi519
poi519 / svg-font-to-pics.rb
Last active December 21, 2015 12:40
Ruby script to break svg font into individual glyphs.
require 'nokogiri'
input_file_name = ARGV[0] || "./font.svg"
input_file = File.open input_file_name
doc = Nokogiri::XML input_file
input_file.close
font_face = doc.css("font-face")[0]
units_per_em = font_face["units-per-em"]
import java.io.*;
import java.util.ArrayList;
import java.util.Comparator;
class MalformedContactStringException extends Exception {
public MalformedContactStringException(String str) {
super(str);
}
}
#lang racket
(require racket/generic)
(define (flip f)
(λ (x y) (f y x)))
(define-generics monad
(fmap f monad)
(join monad))