Skip to content

Instantly share code, notes, and snippets.

View unix-beard's full-sized avatar

Artem H. unix-beard

  • Toronto, Canada
View GitHub Profile
{"id":"https://schema.management.azure.com/schemas/2015-08-01/Microsoft.Compute.json#","$schema":"http://json-schema.org/draft-04/schema#","title":"Microsoft.Compute","description":"Microsoft Compute Resource Types","resourceDefinitions":{"availabilitySets":{"type":"object","properties":{"type":{"enum":["Microsoft.Compute/availabilitySets"]},"apiVersion":{"enum":["2015-05-01-preview","2015-06-15"]},"properties":{"type":"object","properties":{"platformUpdateDomainCount":{"$ref":"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/numberOrExpression","description":"Microsoft.Compute/availabilitySets - Platform update domain count"},"platformFaultDomainCount":{"$ref":"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/numberOrExpression","description":"Microsoft.Compute/availabilitySets - Platform fault domain count"}}}},"required":["type","apiVersion","properties","location"],"description":"Microsoft.Compute/availabilitySets"},"vir
{"id":"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#","$schema":"http://json-schema.org/draft-04/schema#","title":"Template","description":"An Azure deployment template","type":"object","properties":{"$schema":{"type":"string","description":"JSON schema reference"},"apiProfile":{"type":"string","enum":["2017-03-09-profile"],"description":"The apiProfile to use for all resources in the template."},"contentVersion":{"type":"string","pattern":"(^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$)","description":"A 4 number format for the version number of this template file. For example, 1.0.0.0"},"variables":{"type":"object","description":"Variable definitions"},"parameters":{"type":"object","description":"Input parameter definitions","additionalProperties":{"$ref":"#/definitions/parameter"}},"functions":{"type":"array","items":{"$ref":"#/definitions/functionNamespace"},"description":"User defined functions"},"resources":{"type":"array","description":"Collection of resources to be deployed","i
@unix-beard
unix-beard / disk_arbitration_test.c
Last active August 29, 2015 14:24
How to detect disk eject event on Mac OS X
#include <DiskArbitration/DiskArbitration.h>
void disk_event(DADiskRef disk, void *context)
{
printf("Disk removed: %s\n", DADiskGetBSDName(disk));
CFRunLoopStop(CFRunLoopGetCurrent());
}
int main()
{
@unix-beard
unix-beard / mouse_click.py
Created June 28, 2015 12:12
This is how you control the mouse programmatically under Mac OS X
import time, sys
from Quartz.CoreGraphics import CGEventCreateMouseEvent
from Quartz.CoreGraphics import CGEventCreate
from Quartz.CoreGraphics import CGEventPost
from Quartz.CoreGraphics import CGEventGetLocation
from Quartz.CoreGraphics import kCGEventMouseMoved
from Quartz.CoreGraphics import kCGEventLeftMouseDown
from Quartz.CoreGraphics import kCGEventLeftMouseUp
from Quartz.CoreGraphics import kCGMouseButtonLeft
from Quartz.CoreGraphics import kCGHIDEventTap
@unix-beard
unix-beard / array_length.cpp
Last active August 29, 2015 14:22
Idea for a work-around, when C++ 11 features are not available
#include <iostream>
template <typename T, unsigned int N>
unsigned int countof(T const (&array)[N])
{
return N;
}
void f1() { std::cout << "Hello from " << __func__ << "\n"; }
void f2() { std::cout << "Hello from " << __func__ << "\n"; }
@unix-beard
unix-beard / sm.cpp
Last active August 29, 2015 14:22
Template-based state machine (prototype)
#include <iostream>
#include <tuple>
#include <type_traits>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TBD:
// Recursively find the start state at compile time and make static_assert fail if one is not found
// (also terminate the recursive search as soon as the start state is found).
// Do the same of the end state but don't make static_assert fail, since a state machine is allowed not to have one.
@unix-beard
unix-beard / hexbase64.ml
Last active August 29, 2015 14:13
Convert hex to base64
(* The matasano crypto challenges
* http://cryptopals.com/sets/1/challenges/1/
*
* Compile it like this:
* $ ocamlfind ocamlc -package base64,batteries -o hexbase64 -linkpkg hexbase64.ml
*)
open Batteries
open B64
@unix-beard
unix-beard / hexbase64.py
Last active August 29, 2015 14:13
Convert hex to base64
#!/usr/bin/env python3
########################################################
# the matasano crypto challenges
# http://cryptopals.com/sets/1/challenges/1/
########################################################
from base64 import b64encode
from itertools import zip_longest
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <errno.h>
#include <sys/wait.h>
#include <sys/types.h>
#include "lib/testing.h"
/* Execute this while being in a child process */
@unix-beard
unix-beard / main.cc
Created June 28, 2013 19:05
scan linux procfs - C++ version
#include <thread>
#include <condition_variable>
#include <iostream>
#include <cstdlib>
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
std::vector<fs::path> proc_pids;