Skip to content

Instantly share code, notes, and snippets.

Avatar

Thomas Munk mmmunk

View GitHub Profile
View RunAsAdmin_OpretFlyt.cmd
@echo off
mkdir C:\Flyt
icacls C:\Flyt /grant:r Everyone:(CI)(OI)M
net share Flyt=C:\Flyt /GRANT:Everyone,CHANGE /USERS:2 /CACHE:None
pause
@mmmunk
mmmunk / Python_Tornado_MySQL_Demo.py
Created Sep 22, 2016
Demo of web-app using Python, Tornado and MySQL
View Python_Tornado_MySQL_Demo.py
import time
import tornado.ioloop
import tornado.web
import pymysql
# HTML templates
html_begin = '''<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
@mmmunk
mmmunk / UKeepAwake.pas
Created Sep 22, 2016
Keep Windows awake
View UKeepAwake.pas
unit UKeepAwake;
interface
uses
Windows;
type
EXECUTION_STATE = DWORD;
View freestanding_hello.c
// Freestanding with MinGW:
// http://nullprogram.com/blog/2016/01/31/
// http://nullprogram.com/blog/2016/02/28/
// https://support.microsoft.com/da-dk/kb/99456
#include <windows.h>
int WINAPI mainCRTStartup(void)
{
char msg[] = "Hello, world!\n";
@mmmunk
mmmunk / setup-static-png-jpeg-libraries.txt
Last active Nov 11, 2016
Guidelines for setting up libpng and libjpeg for embedding
View setup-static-png-jpeg-libraries.txt
For alle: Start med cd til roden af projekt-mappe
----- ZLIB -----
# wget -P ./download/ http://zlib.net/zlib-1.2.8.tar.gz
- Slet eksisterende zlib dir
- Udpak i zlib dir således at strukturen er: ./zlib/zlib.h
# cd zlib
@mmmunk
mmmunk / valpwd.sh
Created Dec 2, 2016
Script for validating a Linux password. Method SHA-512 (Type ID 6 - first shadow col) expected.
View valpwd.sh
#!/bin/bash
L1=`grep $1 /etc/shadow|cut -d ":" -f 2`
if [ $L1 ]; then
SALT=`echo $L1|cut -d "$" -f 3`
L2=`mkpasswd --salt=$SALT --method=sha-512 $2`
if [ "$L1" == "$L2" ]; then
exit 0
else
exit 1
@mmmunk
mmmunk / generate-text.py
Created Jan 6, 2017
Generate some non-lorem-ipsum random text to use for tests
View generate-text.py
# fold -s -w 70
import sys
import random
cons = 'bcdfghjklmnpqrstvwxz'
consx = 'hjqvwx'
vows = 'aeiouy'
cvless = 'qxyz'
def generate_word(cap):
@mmmunk
mmmunk / RunProcessAndCaptureOutput.pas
Last active May 14, 2018
Delphi procedure to run an external command line program and capture and display the output.
View RunProcessAndCaptureOutput.pas
procedure RunProcessAndCaptureOutput(const CmdLine: string; Memo: TMemo; HideLinesCount: Integer = 0);
var
SecAttr: TSecurityAttributes;
PipeR, PipeW: THandle;
StartupInfo: TStartupInfo;
ProcessInfo: TProcessInformation;
Buffer: packed array[0..4096-1] of AnsiChar;
Count: Cardinal;
S, Leftover: AnsiString;
i, P: Cardinal;
View HTML5-template.css
body {
background-color: white;
color: black;
font-family: sans-serif;
font-size: 100%;
}
View RefCountObject.pas
type
TRefCountObject = class(TObject)
protected
ExtraReferencesCount: Integer; { Default 0 }
public
procedure Free;
function GetReference: TRefCountObject;
end;
procedure TRefCountObject.Free;
You can’t perform that action at this time.