Skip to content

Instantly share code, notes, and snippets.

Avatar
🌍
Working @ CorpoSense

Ibrahim H. bitsnaps

🌍
Working @ CorpoSense
View GitHub Profile
@bitsnaps
bitsnaps / App.vue
Created May 7, 2022 — forked from bricksroo/App.vue
Reveal.js in Vue
View App.vue
<template>
<div id="app">
<!-- <img src="./assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/> -->
<div class="reveal">
<div class="slides">
<section>Single Horizontal Slide</section>
<section>
<section>Vertical Slide 1</section>
<section>Vertical Slide 2</section>
@bitsnaps
bitsnaps / simplest_tf.py
Last active Nov 11, 2021
keras (tensorflow) simplest linear model example
View simplest_tf.py
# Simplest linear model with keras 2.1.3 (using tensorflow backed) it worked with python 3.5
import numpy as np
import keras
model = keras.Sequential( [keras.layers.Dense(units=1, input_shape=[1])] )
model.compile(optimizer='sgd', loss='mean_squared_error')
# y = 2x - 1
xs = np.array([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0])
ys = np.array([-3.0, -1.0, 1.0, 3.0, 5.0, 7.0])
@bitsnaps
bitsnaps / groovyc.groovy
Last active Aug 26, 2021
Activate Type Checking and Compile Static for all Groovy classes in Gradle (or Android) project
View groovyc.groovy
// We know we can apply type checking and compile static on all groovy classes, the good news you can do this on gradle build, so it'll be applied in every class in your project, this works in android project.
/*/ In gradle project:
apply plugin: 'groovy'
compileGroovy.groovyOptions.configurationScript = file('gradle/config/groovyc.groovy')
// In Android project (app/build.gradle)
androidGroovy {
options {
configure(groovyOptions) {
@bitsnaps
bitsnaps / learn_dart.dart
Last active Aug 3, 2021
A simple dart sheet summary
View learn_dart.dart
// 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 Jul 5, 2021
Automated installation of Docker 20.10.7 on Ubuntu 20.04 focal
View docker-install.sh
# 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 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 Mar 28, 2022
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
Last active Nov 26, 2021
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/