Instantly share code, notes, and snippets.

View wav_duration.go
package main
import (
View testing_hash_functions.go
package main
import (
#!/usr/bin/env python3
Example on how to do TCP port scanner in Python
import socket
def scan(address, port, timeout=3):
'''TCP Port Scanner'''
#!/usr/bin/env perl
use warnings;
use strict;
use v5.20;
use IO::Socket::INET;
use experimental qw( switch );
View scan.go
package main
import (
const (
View index.js
.then((data) => { return data.json() } )
.then((data) => { console.table(JSON.stringify(data)) } )
.catch((err) => { console.error(err) } )
View scan.rb
#!/usr/bin/env ruby
require 'socket'
def tcp_connect(address, port, timeout: 20)
# making sure we are talking with IP
connected = false
addr = Socket.getaddrinfo(address, nil)
sock_addr = Socket.pack_sockaddr_in(port, addr[0][3])[0][0]), Socket::SOCK_STREAM, 0).tap do |socket|
View fact_err
2018-04-25T09:22:15 [I|app|] Started POST "/api/v2/discovered_hosts/facts" for ::1 at 2018-04-25 09:22:15 +0300
2018-04-25T09:22:15 [I|app|13a50] Processing by Api::V2::DiscoveredHostsController#facts as JSON
2018-04-25T09:22:15 [I|app|13a50] Parameters: {"facts"=>"[FILTERED]", "apiv"=>"v2", "discovered_host"=>{"facts"=>"[FILTERED]"}}
2018-04-25T09:22:15 [I|app|13a50] Current user: foreman_admin (administrator)
2018-04-25T09:22:15 [D|app|13a50] Setting current user thread-local variable to foreman_admin
2018-04-25T09:22:15 [I|aud|13a50] create event for Nic::Managed with id 44
2018-04-25T09:22:15 [D|app|13a50] Setting current user thread-local variable to nil
2018-04-25T09:22:15 [W|app|13a50] Host discovery failed, facts: {"physicalprocessorcount"=>"3", "memorysize_mb"=>"900", "blockdevice.sda_size"=>"1234567890"
View simple_bench.rb
require 'benchmark'
N = 1_000_000
REGEX = /^abc/
STR = 'abc are letters'.freeze do |x|'start_with?') do
N.times do
View regexp_vs_start_with.rb
require 'benchmark'
require 'securerandom'
N = 1_000_000
REGEX = /^(abc|Abc|ABC)/
def gen_randstr(len = 24)