Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

ik5 ik5

🎯
Focusing
View GitHub Profile
@ik5
ik5 / prefix_function.sql
Created Jan 6, 2022
example on how to use postgresql to find the biggest prefix from content at a table
View prefix_function.sql
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 Oct 24, 2021
PECL inotify example for close_write on watch directory
View notify_watch.php
<?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 Oct 24, 2021
example on reading from stdin in php
View read_stdin.php
<?php
while (!feof(STDIN)) {
$f = fgets(STDIN);
if ($f) {
echo ">> $f\n";
}
}
@ik5
ik5 / thread_pool.rb
Last active Oct 10, 2021
example on how to do threadpool in ruby
View thread_pool.rb
require 'thread'
queue = Queue.new
threads = []
1.step(1000) do |i|
queue << i
end
8.times do
@ik5
ik5 / main.go
Last active Jun 23, 2021
Example on how to look for the date based on a day of the week
View main.go
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 Feb 7, 2021
Example for getting machine hostname and all of it's IP numbers based on local devices
View main.go
package main
import (
"fmt"
"net"
"os"
"strings"
)
// GetMachineInfo return a list of:
@ik5
ik5 / html_dom_example.php
Last active Sep 9, 2020
A simple example on reading a PHP <head> tag and print it's content including attributes
View html_dom_example.php
<?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 Sep 7, 2020
calc israeli id number for valid last number in python 2
View israeli_id.py
#!/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))
)
View resources.md

Assembly Language / Reversing / Malware Analysis -resources

Twitter: Muffin

Assembly Language

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