Skip to content

Instantly share code, notes, and snippets.

@sobiodarlington
sobiodarlington / decrypt.js
Created March 27, 2020 19:07 — forked from fratuz610/decrypt.js
Encrypt from Java and decrypt on Node.js - aes 256 ecb
// we determine the key buffer
var stringKey = "example";
var cipherText = ".........";
// we compute the sha256 of the key
var hash = crypto.createHash("sha256");
hash.update(stringKey, "utf8");
var sha256key = hash.digest();
var keyBuffer = new Buffer(sha256key);
@sobiodarlington
sobiodarlington / MainActivity.java
Created November 21, 2019 13:49
Android: How to collect the response of a USSD request (Including multi-session requests)
//Get the instance of TelephonyManager
final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
try {
if (tm != null) {
Class telephonyManagerClass = Class.forName(tm.getClass().getName());
if (telephonyManagerClass != null) {
Method getITelephony = telephonyManagerClass.getDeclaredMethod("getITelephony");
let accessBits = {
byte6: {
idx: {
C23: 0, C22: 1, C21: 2, C20: 3, C13: 4, C12: 5, C11: 6, C10: 7
},
bits: [],
},
byte7: {
idx: {
C13: 0, C12: 1, C11: 2, C10: 3, C33: 4, C32: 5, C31: 6, C30: 7
@sobiodarlington
sobiodarlington / async-await-example.js
Created August 17, 2019 05:56
Async await example
// Arithmetic addition function
async function add(a, b) {
return a + b;
}
// Usage:
add(1, 3).then(result => console.log(result));
// Prints: 4
@sobiodarlington
sobiodarlington / await-handle.js
Created August 13, 2019 19:21
A fix to Unhandled promise rejection error in javascript promises
/**
* @description ### Returns Go / Lua like responses(data, err)
* when used with await
*
* - Example response [ data, undefined ]
* - Example response [ undefined, Error ]
*
*
* When used with Promise.all([req1, req2, req3])
* - Example response [ [data1, data2, data3], undefined ]
sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev -y
sudo apt-get install libfreetype6 libfreetype6-dev -y
sudo apt-get install libfontconfig1 libfontconfig1-dev -y
cd ~
export PHANTOM_JS="phantomjs-2.1.1-linux-x86_64"
wget https://github.com/Medium/phantomjs/releases/download/v2.1.1/$PHANTOM_JS.tar.bz2
sudo tar xvjf $PHANTOM_JS.tar.bz2
sudo mv $PHANTOM_JS /usr/local/share
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin
@sobiodarlington
sobiodarlington / vhost.sh
Created August 19, 2018 09:22 — forked from mattmezza/vhost.sh
bash script to create virtual host vhost with apache httpd and CentOs 7
#!/bin/bash
# This script is used for create virtual hosts on CentOs.
# Created by alexnogard from http://alexnogard.com
# Improved by mattmezza from http://you.canmakethat.com
# Feel free to modify it
# PARAMETERS
#
# $usr - User
# $dir - directory of web files
# $servn - webserver address without www.