Skip to content

Instantly share code, notes, and snippets.

View plvhx's full-sized avatar
🏠
Working from home

Paulus Gandung Prakosa plvhx

🏠
Working from home
View GitHub Profile
@plvhx
plvhx / tcp.rb
Created May 1, 2025 12:05
Simple TCP server using Ruby
require 'socket'
require 'thread'
socket = Socket.new Socket::AF_INET, Socket::SOCK_STREAM, Socket::IPPROTO_TCP
socket.setsockopt :SOCKET, :REUSEADDR, 1
socket.bind Addrinfo.tcp('0.0.0.0', 31338)
socket.listen 0
puts "Listen on 0.0.0.0 port 31338"
@plvhx
plvhx / h1.S
Created August 20, 2024 10:51
helper #1
.section .text
.globl le32_to_be32
.type le32_to_be32, @function
le32_to_be32:
pushl %ebp
movl %esp, %ebp
subl $0x14, %esp
pushl %ebx
pushl %ecx
pushl %edx
@plvhx
plvhx / sqrt.go
Created July 27, 2024 09:39
ieee754 and newton-raphson
package main
import (
"fmt"
"math"
"unsafe"
)
// IEEE-754 floating-point representation.
func ieee754BinRep(x float64) uint64 {
@plvhx
plvhx / madhttp.s
Last active February 22, 2024 08:53
pwn.college are mad as hell..
# this is an implementation of creating mad and stupid yet concurrent
# web server with only 65535 iteration before calling fork() syscall.
#
# fyi: this is pwn.college web server challenge
#
# Paulus Gandung Prakosa <[email protected]>
#
.section .rodata
.resp:
@plvhx
plvhx / 1.ohm
Created January 22, 2023 14:41
ohm sample script
namespace foobar
module [
ohm.encoding.json
ohm.util.io
ohm.lang.types.String
org.project.foo
org.project.bar
ohm.native.syscall
]
@plvhx
plvhx / four-rules.txt
Created October 8, 2022 19:17
bangkok dangerous
- Don't ask questions
- Don't take an interest in people outside of work
- Erase every trace
- Know when it's time to get out
@plvhx
plvhx / full_adder.py
Last active October 22, 2022 13:44
full-adder implementation
# Full adder implementation
# Paulus Gandung Prakosa <[email protected]>
# ref: https://en.wikipedia.org/wiki/Adder_(electronics)#Full_adder
import math
import sys
def bit_count(x):
return x if x == 0 else math.floor(math.log2(x)) + 1
@plvhx
plvhx / lsb_msb.py
Created July 10, 2022 08:59
lsb to msb (two's complement)
#
# https://en.wikipedia.org/wiki/Two%27s_complement#Working_from_LSB_towards_MSB
#
# (c) 2022 Paulus Gandung Prakosa <[email protected]>
#
import sys
import math
num = int(sys.argv[1])
@plvhx
plvhx / rtab.go
Created March 7, 2022 14:29
Routing method approach #1 (Regex Table)
// Routing approach using Regex Table method.
// 2022 (c) Paulus Gandung Prakosa <[email protected]>
package main
import (
"fmt"
"log"
"regexp"
"sync"
@plvhx
plvhx / hell.regex
Created March 1, 2022 10:28
hellish currency detector
'(?:(?:Rp)(?:\s*)(\d+)|(?:IDR)(?:\s*)(\d+)(?:\,(\d+))+(?:\.\d+)*|(?:Rp\.)(?:\s*)(\d+)(?:\.(\d+))+|(?:RP)(?:\s*)(\d+)(?:(?:\,)(\d+))+(?:\.\-)?|(\d+)((?:(?:\.)(?:\d+))+)(?:\,00)?)'