Skip to content

Instantly share code, notes, and snippets.

View HassenIO's full-sized avatar
🚀
What's your Minimum Viable Fun?

Hassen HassenIO

🚀
What's your Minimum Viable Fun?
View GitHub Profile
@HassenIO
HassenIO / basic-http-query.py
Created May 11, 2021 17:33
Understanding PIP [blog article]
from urllib.request import urlopen, Request
url = "https://swapi.dev/api/people/42/"
httprequest = Request(url, headers={"Accept": "application/json"})
with urlopen(httprequest) as response:
print(response.status)
print(response.read().decode())
@HassenIO
HassenIO / drone.env
Created September 21, 2019 09:40
What is necessary to run Docker Drone
DRONE_SERVER_PROTO=http
DRONE_SERVER_HOST=VM_EXTERNAL_IP
DRONE_GITHUB_SERVER=https://github.com
DRONE_GITHUB_CLIENT_ID=GITHUB_CLIENT_ID
DRONE_GITHUB_CLIENT_SECRET=GITHUB_CLIENT_SECRET
DRONE_RUNNER_CAPACITY=2
@HassenIO
HassenIO / drone.env
Created September 21, 2019 08:40
What is necessary to run Docker Drone
DRONE_SERVER_PROTO=https
DRONE_SERVER_HOST=VM_EXTERNAL_IP
DRONE_GITHUB_SERVER=https://github.com
DRONE_GITHUB_CLIENT_ID=GITHUB_CLIENT_ID
DRONE_GITHUB_CLIENT_SECRET=GITHUB_CLIENT_SECRET
DRONE_RUNNER_CAPACITY=2
@HassenIO
HassenIO / test-sagemaker-post-processing.js
Created December 19, 2018 14:31
Post-processing script for AWS SageMaker Ground Truth
const AWS = require("aws-sdk");
const s3 = new AWS.S3();
exports.handler = async (event) => {
console.info(event);
try {
const consolidationRequestFile = await s3.getObject(event.payload.s3Uri);
const consolidationRequest = consolidationRequestFile.Body;
let consolidationLabels = [];
@HassenIO
HassenIO / test-sagemaker-pre-processing.js
Created December 19, 2018 14:30
Pre-processing script for AWS SageMaker Ground Truth
const ocrResults = require("./ocr-results.json");
const dataLocation = "<Data location in S3 bucket>";
exports.handler = async (event) => {
console.info(event);
const fileName = event.dataObject['source-ref'].substr(dataLocation.length);
const extracts = ocrResults[fileName] || {rekognition: "__error.rekognition__", gcVision: "__error.gcVision__"};
console.info(extracts);
const categories = [extracts["rekognition"], extracts["gcVision"], "Neither"];
const response = {
const getSMSText = async (warning, id, introduced) => {
const text = notificationTemplate[warning.type].find(group =>
group.categories.includes(warning.category)
).sentences[introduced ? 'next' : '1st'];
const link = await googl.shorten(`${decodeURIComponent(warning.url)}${id}`);
return `${text} ${link}`;
};
@HassenIO
HassenIO / sha256.sh
Last active January 21, 2022 10:27
Get SHA256 of a text in Mac OSX terminal
# Get SHA256 of a text
# Usage: sha256 password
# output: 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8
function sha256() {
echo -n $1 | shasum -a 256
# Source: http://albertech.blogspot.fr/2015/02/generate-sha-256-hash-from-command-line.html
}
@HassenIO
HassenIO / 0_reuse_code.js
Last active August 29, 2015 14:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@HassenIO
HassenIO / gist:5989820
Created July 13, 2013 07:35
Ruby: Next week date
7.days.since(Time.now).to_date.strftime("%d/%m/%Y")
@HassenIO
HassenIO / gist:5989547
Created July 13, 2013 05:36
Ruby: Get current date with d/m/Y format
Time.now.strftime("%d/%m/%Y")