Skip to content

Instantly share code, notes, and snippets.

@stakach
stakach / job_object.ps1
Last active September 4, 2024 01:09
powershell code for cleaning up all processes and child processes launched as part of the script
if (-not [System.Management.Automation.PSTypeName]'JobObject'.Type) {
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class JobObject
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern IntPtr CreateJobObject(IntPtr lpJobAttributes, string lpName);
@stakach
stakach / dns.cr
Last active October 16, 2024 04:20
crystal lang native DNS
require "socket"
@[Flags]
enum Resolve
IPv4 = 1
IPv6 = 2
ALPN = 4
end
module DNSResolver
Invalid memory access (signal 11) at address 0x0
[0x564255739966] *Exception::CallStack::print_backtrace:Nil +118 in /home/steve/projects/client-projects/crystal/.build/crystal
[0x56425570fab6] ~procProc(Int32, Pointer(LibC::SiginfoT), Pointer(Void), Nil) +310 in /home/steve/projects/client-projects/crystal/.build/crystal
[0x7f159c1ff140] ?? +139730790379840 in /lib/x86_64-linux-gnu/libpthread.so.0
[0x7f159d2b57f3] _ZN4llvm11PointerType3getEPNS_4TypeEj +19 in /lib/x86_64-linux-gnu/libLLVM-11.so.1
[0x7f159d1bd090] ?? +139730806886544 in /lib/x86_64-linux-gnu/libLLVM-11.so.1
[0x7f159d1de412] ?? +139730807022610 in /lib/x86_64-linux-gnu/libLLVM-11.so.1
[0x7f159d1ed685] ?? +139730807084677 in /lib/x86_64-linux-gnu/libLLVM-11.so.1
[0x7f159d1ed5dd] LLVMBuildInBoundsGEP +77 in /lib/x86_64-linux-gnu/libLLVM-11.so.1
[0x56425681a36f] *LLVM::Builder#inbounds_gep<LLVM::Value, LLVM::Value, LLVM::Value, String>:LLVM::Value +175 in /home/steve/projects/client-projects/crystal/.build/crystal
@stakach
stakach / google_auth.cr
Created August 7, 2019 08:08
Crystal Lang Google Calendar
require "jwt"
require "json"
require "http"
require "uri"
require "./http_proxy"
class GoogleAuth
GOOGLE_URI = URI.parse("https://www.googleapis.com")
TOKEN_PATH = "/oauth2/v4/token"
@stakach
stakach / manager.rb
Created May 30, 2018 02:35
SNMP Manager
# frozen_string_literal: true
require 'netsnmp'
require 'logger'
module NETSNMP
# Provides a base class for building SNMP Managers
#
# Does not implement a transport so must be subclassed
@stakach
stakach / dtls_api.md
Created January 5, 2017 06:49 — forked from Jxck/dtls_api.md
OpenSSL DTLS API

OpenSSL DTLS API

The API used for DTLS is mostly the same as for TLS, because of the mapping of generic functions to protocol specifc ones. Some additional functions are still necessary, because of the new BIO objects and the timer handling for handshake messages. The generic concept of the API is described in the following sections. Examples of applications using DTLS are available at [9].

DTLS の API は TLS とほぼ同じ。 BIO オブジェクトの生成とタイマのために追加でいくつか必要。

@stakach
stakach / $namedRoute.js
Last active May 13, 2018 08:12
Augments AngularJS $route provider with route naming.
(function(angular) {
'use strict';
/*
Usage:
-----
FILE --app.js--
@stakach
stakach / gist:5335327
Created April 8, 2013 08:57
AngularJS Mobile + Desktop Events
(function(angular, undefined) {
'use strict';
angular.module('Core.SafeApply', []).
service('Core.SafeApply', function() {
this.do = function(scope, fn) {
var phase = scope.$root.$$phase;
if(phase == '$apply' || phase == '$digest') {
fn();
@stakach
stakach / gist:5204160
Created March 20, 2013 12:07
Fiber vs Thread using futures
require 'celluloid'
require 'benchmark'
class Example
include Celluloid
def slow_method
sleep 5
end
@stakach
stakach / gist:5204063
Created March 20, 2013 11:47
Celluloid Actors vs Actor Pools - Fibres vs Threads
require 'celluloid'
require 'benchmark'
$mutex = Mutex.new
$resource = ConditionVariable.new
class Example
include Celluloid
def slow_method