Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Suleiman namieluss

🏠
Working from home
View GitHub Profile
View initialize-DataTable.js
function initDataTable() {
$('#example').dataTable({
scrollX: true,
scrollY: (window.innerHeight / 2) + "px",
dom: 'Bfrtip',
buttons: [
'colvis',
{
extend: 'csv',
text: 'Download CSV',
View html_table_generator.js
function htmlTableGenerator(content) {
let csv_preview = document.getElementById('csv-preview');
let html = '<table id="example" class="table table-condensed table-hover table-striped" style="width:100%">';
if (content.length == 0 || typeof(content[0]) === 'undefined') {
return null
} else {
const header = content[0];
const data = content.slice(1);
View preview_csv_papaparse.js
window.onload = function() {
document.getElementById('csv-file').addEventListener(
'change', preview_csv, false
);
}
function preview_csv(e) {
if (!e.target.files.length) {
alert("Please choose a csv file...");
return
@namieluss
namieluss / youtube-clip.sh
Created Jul 7, 2020
A simple script to download and clip out youtube videos with youtube-dl and ffmpeg.
View youtube-clip.sh
#!/bin/bash
# to run and extract clip
# ./youtube-clip.sh UF8uR6Z6KLc --trim 00:03:32 00:05:32
# youtube video id
vid="$1";
echo "[youtube-dl] download video from youtube in .mp4 format...";
youtube-dl --format mp4 $vid -o '%(title)s.%(ext)s';
@namieluss
namieluss / flask-celery-mongodb-task.py
Created Jun 6, 2020
This is a simple app written in Python Flask with MongoDB mongodb database. Celery is used to manage task queue.
View flask-celery-mongodb-task.py
__author__ = "Suleiman"
from datetime import datetime
from flask import request
from requests import get as http_getter
from . import app, db, celery
@namieluss
namieluss / flask-celery-mongodb-app.py
Created Jun 6, 2020
This is a simple app written in Python Flask with MongoDB mongodb database. Celery is used to manage task queue.
View flask-celery-mongodb-app.py
__author__ = "Suleiman"
from celery import Celery
from flask import Flask, render_template
from pymongo import MongoClient
from .constants import *
app = Flask(__name__, template_folder="templates")
@namieluss
namieluss / nginx-server-static-html-file.sh
Created Apr 5, 2020
Serving static index.html file in nginx server
View nginx-server-static-html-file.sh
server {
listen 80;
listen 443 ssl;
server_name localhost;
root /home/mywebstite/;
index index.html;
location / {
@namieluss
namieluss / spreadsheet-authorize.js
Created Mar 18, 2020
Firebase Cloud Functions with Google Spreadsheet
View spreadsheet-authorize.js
const fs = require("fs");
const readline = require("readline");
const { google } = require("googleapis");
// If modifying these scopes, delete token.json.
const SCOPES = ["https://www.googleapis.com/auth/spreadsheets"];
// The file token.json stores the user's access and refresh tokens, and is
// created automatically when the authorization flow completes for the first
// time.
const TOKEN_PATH = "token.json";
@namieluss
namieluss / python-pillow-image-add-border.py
Created Mar 16, 2020
Add Borders to Images using Python Pillow
View python-pillow-image-add-border.py
from PIL import Image, ImageOps
# open image
img = Image.open("test_image.jpg")
# border color
color = "green"
# top, right, bottom, left
border = (20, 10, 20, 10)
@namieluss
namieluss / python-pillow-image-edge-blur.py
Created Mar 16, 2020
Blur Image borders using Python Pillow
View python-pillow-image-edge-blur.py
from PIL import Image, ImageFilter
# blur radius and diameter
radius, diameter = 20, 40
# open an image
img = Image.open("test_image.jpg")
# Paste image on white background
background_size = (img.size[0] + diameter, img.size[1] + diameter)