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 / convert_sast_to_html_args.py
Created December 4, 2023 07:37
Gitlab SAST result HTML converter
View convert_sast_to_html_args.py
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
View Scratch.java
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
View MessageQueueSpy.js
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.
View makeChange.js
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
View DNSExternalResolver.py
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 / method_decorator_example.ts
Last active December 12, 2020 15:45
A simple example of method decorator in Typescript
View method_decorator_example.ts
class Greeter {
@ChangeName('Ammara')
greet(greeting: string) {
return "Hello, " + greeting;
}
}
function ChangeName(value: string) {
return function (
target: any,
@h4ck4life
h4ck4life / SimpleCORSFilter.java
Created November 6, 2020 01:07
Spring boot http interceptor
View SimpleCORSFilter.java
package com.touchngo.iap.apigatewayservice;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
@h4ck4life
h4ck4life / tips_increase_memory_limit_nodejs.js
Created May 8, 2020 16:26 — forked from motss/tips_increase_memory_limit_nodejs.md
[TIPS] Increase memory limit in Node.js
View tips_increase_memory_limit_nodejs.js
// By default the memory limit in Node.js is 512MB.
// This will cause FATAL ERROR- JS Allocation failed – process out of memory when processing large data files.
// It can be avoided by increasing the memory limit.
node --max_old_space_size=1024 server.js // increase to 1gb
node --max_old_space_size=2048 server.js // increase to 2gb
node --max_old_space_size=3072 server.js // increase to 3gb
node --max_old_space_size=4096 server.js // increase to 4gb
node --max_old_space_size=5120 server.js // increase to 5gb
node --max_old_space_size=6144 server.js // increase to 6gb
@h4ck4life
h4ck4life / Helloworld_C_Sharp.ps1
Created April 26, 2020 15:49 — forked from Sh1n0g1/Helloworld_C_Sharp.ps1
Run C# code in PowerShell
View Helloworld_C_Sharp.ps1
$assemblies=(
"System"
)
$source=@"
using System;
namespace Helloworld
{
public static class Hello{
public static void Main(){