Skip to content

Instantly share code, notes, and snippets.

View RumataEstor's full-sized avatar

Dmitry Belyaev RumataEstor

  • Melbourne, Australia
View GitHub Profile
@RumataEstor
RumataEstor / migrate.ps
Last active July 20, 2017 04:33
Migrate Active Directory DNS records from subdomain
Get-DnsServerResourceRecord -ZoneName $zone -RRType A | Where-Object {$_.HostName.EndsWith("." + $sub)} | ForEach {Add-DnsServerResourceRecordA -ZoneName ($sub + "." + $zone) -Name $_.HostName.Remove($_.HostName.Length - 1 - $sub.Length) -IPv4Address $_.RecordData.IPv4Address -TimeToLive $_.TimeToLive -AllowUpdateAny -AgeRecord}
Get-DnsServerResourceRecord -ZoneName $zone -RRType CName | Where-Object {$_.HostName.EndsWith("." + $sub)} | ForEach {Add-DnsServerResourceRecordCName -ZoneName ($sub + "." + $zone) -Name $_.HostName.Remove($_.HostName.Length - 1 - $sub.Length) -HostNameAlias $_.RecordData.HostNameAlias -TimeToLive $_.TimeToLive}
Get-DnsServerResourceRecord -ZoneName $zone -RRType SRV | Where-Object {$_.HostName.EndsWith("." + $sub)} | ForEach {Add-DnsServerResourceRecord -Srv -ZoneName ($sub + "." + $zone) -Name $_.HostName.Remove($_.HostName.Length - 1 - $sub.Length) -DomainName $_.RecordData.DomainName -Port $_.RecordData.Port -TimeToLive $_.TimeToLive -Weight $_.RecordData.Weight -Priority $_.R
@RumataEstor
RumataEstor / send_after_test.erl
Created February 6, 2014 05:49
Shows how much different is the direct message send and `erlang:send_after(0, self(), ...)`.
-module(send_after_test).
-export([main/0]).
main() ->
Self = self(),
Ref = make_ref(),
spawn(fun() -> test(Self, Ref) end),
receive Ref -> ok end.
-module(binaries).
-export([by_char/2, whole/2, by_list/2, count/0]).
by_char(Rest, <<>>) ->
Rest;
by_char(<<C, String/binary>>, <<C, Pattern/binary>>) ->
by_char(String, Pattern);
by_char(_, _) ->
no_match.
@RumataEstor
RumataEstor / close_bug.erl
Created October 11, 2012 21:06
Reveals bug in prim_inet:close/1
-module(close_bug).
-export([bad_ports/0, start/1]).
bad_ports() ->
[{P, element(2, erlang:port_info(P, connected))} || {P, {links, []}} <- [{P, erlang:port_info(P, links)} || P <- erlang:ports()]].
opts() ->
[binary, {active, false}, {exit_on_close, false}, {packet, 1}, {nodelay, true}].
@RumataEstor
RumataEstor / erlasm
Created December 12, 2010 00:59
A script to take erlang code from the command line and display the generated BEAM assembler.
#! /usr/bin/env escript
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% erlasm
% A script to take erlang code from the command line and display the generated
% BEAM assembler. The passed-in code must consist of one or more complete
% functions.
%
main (Strings) ->
Asm = lists:flatten(