Skip to content

Instantly share code, notes, and snippets.

Avatar
🌍
Working @ CorpoSense

Ibrahim H. bitsnaps

🌍
Working @ CorpoSense
View GitHub Profile
@bitsnaps
bitsnaps / upload_doc.groovy
Created Feb 27, 2021
Upload a file to LogicalDOC DMS using a REST post request
View upload_doc.groovy
@Grapes([
@Grab('org.slf4j:slf4j-simple:1.7.25'),
@Grab('io.github.http-builder-ng:http-builder-ng-okhttp:1.0.4')
])
import groovyx.net.http.OkHttpBuilder
import groovyx.net.http.OkHttpEncoders
import groovyx.net.http.MultipartContent
import static groovyx.net.http.HttpBuilder.configure
@bitsnaps
bitsnaps / index.php
Last active Jan 20, 2021
PHP-ML machine learning php library examples
View index.php
<?php
/*
You should first install phpml library with composer:
```
composer require php-ai/php-ml
```
then create in the same directory of vendor a file (e.g. `index.php`) with this content.
*/
@bitsnaps
bitsnaps / php_json_compression.php
Created Dec 13, 2020
PHP json string compression different examples and comparison
View php_json_compression.php
<?php
$users = file_get_contents('https://jsonplaceholder.typicode.com/users');
$gz = base64_encode(gzencode($users));
if (!$gz){
die('content contains non base64 alpha');
}
echo $gz;
@bitsnaps
bitsnaps / json_examples.groovy
Created Dec 10, 2020
Groovy json (from/to) conversions simple examples
View json_examples.groovy
// Groovy from/to Json conversion
import groovy.json.*
// Object to Json
class Version {
int id
}
class User {
String className = this.class.simpleName.toLowerCase()
@bitsnaps
bitsnaps / upgrade_postgresql_from_9.5_to_9.6.sh
Created Nov 24, 2020
Upgrade PostgreSQL cluster from 9.5 to 9.6
View upgrade_postgresql_from_9.5_to_9.6.sh
# This script allows to upgrade postgres database server (e.g. 9.5 to 9.6)
# References:
#https://gorails.com/guides/upgrading-postgresql-version-on-ubuntu-server
#https://stackoverflow.com/questions/13733719/postgresql-which-version-of-postgresql-am-i-running/54514786#54514786
#https://stackoverflow.com/questions/46687645/upgrade-postgresql-from-9-6-to-10-0-on-ubuntu-16-10
#https://stackoverflow.com/questions/47029055/how-do-i-upgrade-my-postgresql-9-5-to-postgresql-10-on-ubuntu-16-04
#https://askubuntu.com/questions/831292/how-do-i-install-postgresql-9-6-on-any-ubuntu-version
#https://chartio.com/resources/tutorials/how-to-view-which-postgres-version-is-running/
@bitsnaps
bitsnaps / scraping_results.py
Last active Jan 16, 2021
Scraping results from Quiz And Survey Master wordpress plugin using python3
View scraping_results.py
import os, csv, requests, datetime, urllib
from bs4 import BeautifulSoup
# from dateutil.parser import parse # if you want to parse datetime
# This script allows you to grab results from your wordpress website if you're using "Quiz And Survey" plugin.
wp_host = 'https://your-wordpress-website.com'
wp_login = f"{wp_host}/login"
wp_admin = f"{wp_host}/wp-admin/"
wp_quiz = f"{wp_host}/wp-admin/admin.php?page=mlw_quiz_results"
@bitsnaps
bitsnaps / MainActivity.java
Last active Nov 4, 2020
Using VolleyPlus to make a request API on Android
View MainActivity.java
/**
* VolleySingleton
*
* This is just a wrapper around [VolleyPlus](https://github.com/DWorkS/VolleyPlus) library (tested with v0.1.4)
* You can update the UI without using AsyncTask neither runOnUiThread
* It comes with caching and full image caching without third party library, included options to clear cache
* It doesn't depend on any other libraries and you can send any type of request (String, JSON...)
* It works for both Java and Groovy (it should works for Kotlin as well)
* Tested on SdkVersion v19 up to v28.
*/
@bitsnaps
bitsnaps / llvm_install.sh
Created Sep 15, 2020
Install LLVM OpenMP on Mac
View llvm_install.sh
# Original source: https://openmp.llvm.org/
# 1- Clone the repo (~ 1Gb)
git clone --depth 1 https://github.com/llvm/llvm-project.git
cd llvm-project
mkdir build && cd build
# 2- Make sure clang & clang++ are both installed (I believe xcode should be installed as well), you'll some space (~ 16Gb)
cmake ../llvm -DLLVM_ENABLE_PROJECTS=openmp -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++)
make
# 3- (Optional) Running tests
make check-all
@bitsnaps
bitsnaps / ubuntu-20.04-lts-perfect-setup.sh
Created Jul 19, 2020 — forked from eRQee/ubuntu-20.04-lts-perfect-setup.sh
Ubuntu 20.04 LTS Apps Server Installation Wizard
View ubuntu-20.04-lts-perfect-setup.sh
clear
##############
# Am I root? #
##############
if [ "x$(id -u)" != 'x0' ]; then
echo 'Error: this script can only be executed by root.'
echo 'Try re-run the script after switched to root account by type "sudo su"'
exit 1
fi
@bitsnaps
bitsnaps / webrtc.js
Created May 20, 2020 — forked from tauren/webrtc.js
Using RxJS for WebRTC icecandidate handling via WebSocket signaling server
View webrtc.js
// Create WebRTC peer and setup event handlers
let peer = new RTCPeerConnection(iceConfig)
// Subject for the websocket signalling server
let socketSubject = Observable.webSocket({
// deserialize each binary message received
resultSelector: e => deserialize(e.data)
})
// Filter for only icecandidate messages
.filter(msg => msg && msg.header && msg.header.event === 'icecandidate' && msg.body && msg.body.candidate)