Skip to content

Instantly share code, notes, and snippets.

View ik5's full-sized avatar
🎯
Focusing

ik5 ik5

🎯
Focusing
View GitHub Profile
@ik5
ik5 / prefix_function.sql
Created January 6, 2022 07:10
example on how to use postgresql to find the biggest prefix from content at a table
CREATE OR REPLACE FUNCTION public.prefixes(character varying) RETURNS character varying[]
LANGUAGE sql IMMUTABLE
AS $_$
SELECT ARRAY(SELECT substring($1 FROM 1 FOR i)
FROM generate_series(1, GREATEST(length($1))) g(i))::varchar[];
$_$
SELECT MAX(prefix) FROM MY_TABLE WHERE prefix=ANY(content);
@ik5
ik5 / notify_watch.php
Created October 24, 2021 16:52
PECL inotify example for close_write on watch directory
<?php
$fd = inotify_init();
$watch_descriptor = inotify_add_watch($fd, './watch', IN_CLOSE_WRITE);
while (true) {
$events = inotify_read($fd);
foreach ($events as $event) {
@ik5
ik5 / read_stdin.php
Created October 24, 2021 16:40
example on reading from stdin in php
<?php
while (!feof(STDIN)) {
$f = fgets(STDIN);
if ($f) {
echo ">> $f\n";
}
}
@ik5
ik5 / thread_pool.rb
Last active October 10, 2021 06:42
example on how to do threadpool in ruby
require 'thread'
queue = Queue.new
threads = []
1.step(1000) do |i|
queue << i
end
8.times do
@ik5
ik5 / main.go
Last active June 23, 2021 17:19
Example on how to look for the date based on a day of the week
package main
import (
"fmt"
"time"
)
func main() {
t, _ := time.Parse("2006-01-02 15:04", "2021-05-17 10:55")
today := t.Weekday()
@ik5
ik5 / main.go
Created February 7, 2021 14:48
Example for getting machine hostname and all of it's IP numbers based on local devices
package main
import (
"fmt"
"net"
"os"
"strings"
)
// GetMachineInfo return a list of:
@ik5
ik5 / html_dom_example.php
Last active September 9, 2020 06:51
A simple example on reading a PHP <head> tag and print it's content including attributes
<?php
$doc = new DOMDocument();
$doc->loadHTMLFile('test.html', LIBXML_NOWARNING | LIBXML_NOERROR);
$nodes = $doc->getElementsByTagName('head');
if ($nodes->length <= 0) {
die('no head found');
}
@ik5
ik5 / israeli_id.py
Created September 7, 2020 18:26
calc israeli id number for valid last number in python 2
#!/usr/bin/env python2
def validate_id_number(id_num):
anID = id_num.zfill(9)
return sum(
sum(
map(
int, str(int(a)*(i % 2 + 1))
)

Assembly Language / Reversing / Malware Analysis -resources

Twitter: Muffin

⭐Assembly Language

@ik5
ik5 / concat-wav.go
Created March 8, 2020 08:55
example on concating two (or more) wav files
package main
import (
"io"
"io/ioutil"
"github.com/moutend/go-wav"
)
func main() {