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 / 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 / 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
// 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
$assemblies=(
"System"
)
$source=@"
using System;
namespace Helloworld
{
public static class Hello{
public static void Main(){
@h4ck4life
h4ck4life / TikaExtractor.java
Created January 1, 2020 15:32 — forked from LorisBachert/TikaExtractor.java
Using Apache TIKA to extract the following formats: DOC, DOCX, PPT, PPTX, XLS, XLSX, PDF, JPG, PNG, TXT Note: Tesseract must be installed in order to get JPG and PNG extraction working.
/**
* Uses Tikas {@link AutoDetectParser} to extract the text of a file.
*
* @param document
* @return The text content of a file
*/
@Override
public String extractTextOfDocument(File file) throws Exception {
InputStream fileStream = new FileInputStream(file);
Parser parser = new AutoDetectParser();
@h4ck4life
h4ck4life / PreventSleep.cs
Created November 6, 2019 14:17 — forked from brianhassel/PreventSleep.cs
Prevent Computer Sleep in C#
internal static class NativeMethods {
public static void PreventSleep() {
SetThreadExecutionState(ExecutionState.EsContinuous | ExecutionState.EsSystemRequired);
}
public static void AllowSleep() {
SetThreadExecutionState(ExecutionState.EsContinuous);
}
@h4ck4life
h4ck4life / vpn.md
Created October 23, 2019 03:03 — forked from joepie91/vpn.md
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

A Russian translation of this article can be found here, contributed by Timur Demin. There's also this article about VPN services, which is honestly better written (and has more cat pictures!) than my article.

Why not?

@h4ck4life
h4ck4life / deployment-tool-ansible-puppet-chef-salt.md
Created October 22, 2019 14:16 — forked from jaceklaskowski/deployment-tool-ansible-puppet-chef-salt.md
Choosing a deployment tool - ansible vs puppet vs chef vs salt

Requirements

  • no upfront installation/agents on remote/slave machines - ssh should be enough
  • application components should use third-party software, e.g. HDFS, Spark's cluster, deployed separately
  • configuration templating
  • environment requires/asserts, i.e. we need a JVM in a given version before doing deployment
  • deployment process run from Jenkins

Solution