Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View h4ck4life's full-sized avatar

Alif h4ck4life

  • Dev.
  • Kuala Lumpur
View GitHub Profile
@h4ck4life
h4ck4life / Dockerfile
Created December 28, 2023 15:09
golang + sqlite3 dockerfile
FROM golang:alpine3.18 AS build
# Important:
# Because this is a CGO enabled package, you are required to set it as 1.
ENV CGO_ENABLED=1
RUN apk add --no-cache \
# Important: required for go-sqlite3
gcc \
# Required for Alpine
@h4ck4life
h4ck4life / Dockerfile
Created January 8, 2024 07:47
PHP-FPM dockerfile with sendmail enabled
FROM php:7.4-fpm
# Install dependencies
RUN apt-get update && \
apt-get install -y telnet curl unixodbc unixodbc-dev gnupg2 libgssapi-krb5-2 wget iputils-ping openssl zlib1g-dev libzip-dev sendmail
# Add Microsoft repo for SQL Server ODBC Driver
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list
@h4ck4life
h4ck4life / main.go
Created December 31, 2023 03:08
Run go pprof with API server
package main
import (
"fmt"
"log"
"net/http"
_ "net/http/pprof" // Import for pprof
)
func main() {
@h4ck4life
h4ck4life / convert_sast_to_html_args.py
Created December 4, 2023 07:37
Gitlab SAST result HTML converter
import json
import sys
def parse_json_to_html(json_data):
vulnerabilities = json_data.get('vulnerabilities', [])
# Start HTML document
html = '''
<html>
<head>
@h4ck4life
h4ck4life / Scratch.java
Created December 2, 2022 18:21
Example code to find multiple JSON string in a text
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Scratch {
public static void main(String[] args) {
String text = "This text contains two JSON strings: {\"key1\": \"value1\"} and {\"key2\": \"value2\"} and {\"key2\": \"value2\"}";
Pattern pattern = Pattern.compile("(\\{.*?\\})");
Matcher matcher = pattern.matcher(text);
while (matcher.find()) {
@h4ck4life
h4ck4life / MessageQueueSpy.js
Created June 25, 2021 11:00 — forked from axemclion/MessageQueueSpy.js
Message Queue - Replay React Native Message Queue
import MessageQueue from 'react-native/Libraries/BatchedBridge/MessageQueue.js';
const WHITELIST = ['UIManager'];
const NOOP = () => { };
let queue = [];
let now = 0;
export default {
start() {
MessageQueue.spy(msg => {
@h4ck4life
h4ck4life / makeChange.js
Created June 17, 2021 13:12 — forked from furf/makeChange.js
Given a set of coin denominators, find the minimum number of coins to give a certain amount of change.
function makeChange (amount) {
var change = {},
i = 0,
coins = makeChange.COINS,
coin;
while (amount && (coin = coins[i++])) {
if (amount >= coin) {
change[coin] = ~~(amount / coin);
@h4ck4life
h4ck4life / DNSExternalResolver.py
Created June 7, 2021 06:05 — forked from czaux/DNSExternalResolver.py
Get External IP with whoami.cloudflare and DNSPython
import dns.resolver #dnspython
my_resolver = dns.resolver.Resolver()
#Cloudflares DNS Server
my_resolver.nameservers = ['1.1.1.1']
#Get IP from cloudflare chaosnet TXT record
#https://community.cloudflare.com/t/can-1-1-1-1-be-used-to-find-out-ones-public-ip-address/14971/6
result = my_resolver.resolve("whoami.cloudflare","TXT", "CH", tcp=True, lifetime=15)
response = result.response
answer = response.answer
ExternalIP = str(list(answer[0])[0]).replace('"', '')
@h4ck4life
h4ck4life / gist:6433506
Created September 4, 2013 06:51
Android blow detection via microphone. Source: http://stackoverflow.com/a/6186977
public boolean isBlowing()
{
boolean recorder=true;
int minSize = AudioRecord.getMinBufferSize(8000,AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT);
AudioRecord ar = new AudioRecord(MediaRecorder.AudioSource.MIC, 8000,AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT,minSize);
short[] buffer = new short[minSize];
@h4ck4life
h4ck4life / method_decorator_example.ts
Last active December 12, 2020 15:45
A simple example of method decorator in Typescript
class Greeter {
@ChangeName('Ammara')
greet(greeting: string) {
return "Hello, " + greeting;
}
}
function ChangeName(value: string) {
return function (
target: any,