Skip to content

Instantly share code, notes, and snippets.

View bitsnaps's full-sized avatar
🌍
Working @ CorpoSense

Ibrahim H. bitsnaps

🌍
Working @ CorpoSense
View GitHub Profile
@bitsnaps
bitsnaps / learn_dart.dart
Last active August 3, 2021 18:34
A simple dart sheet summary
// Dart is a C-Like strongly static typed language
// variable are pass-reference-by-value
// Everything is an Object
/*
* Data Type in Dart
Data Type | Keyword | Description
Number | int, double, num | Numbers in Dart are used to represent numeric literals
Strings | String | Strings represent a sequence of characters
@bitsnaps
bitsnaps / docker-install.sh
Last active July 5, 2021 13:24
Automated installation of Docker 20.10.7 on Ubuntu 20.04 focal
# Install Docker 20.10.7 on Ubuntu 20.04 focal
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# This is for amd64_x86 architecture (checkout for other architectures: https://docs.docker.com/engine/install/ubuntu/)
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
@bitsnaps
bitsnaps / upload_doc.groovy
Created February 27, 2021 10:51
Upload a file to LogicalDOC DMS using a REST post request
@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 March 28, 2022 16:36
PHP-ML machine learning php library examples
<?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 December 13, 2020 11:20
PHP json string compression different examples and comparison
<?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
Last active November 26, 2021 20:07
Groovy json (from/to) conversions simple examples
// 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 November 24, 2020 17:38
Upgrade PostgreSQL cluster from 9.5 to 9.6
# 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 January 14, 2023 17:04
Scraping results from Quiz And Survey Master wordpress plugin using python3
import os, csv, requests, datetime, urllib, re
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&qmn_order_by=time_taken_real"
@bitsnaps
bitsnaps / MainActivity.java
Last active November 4, 2020 08:06
Using VolleyPlus to make a request API on Android
/**
* 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 September 15, 2020 16:58
Install LLVM OpenMP on Mac
# 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