Skip to content

Instantly share code, notes, and snippets.

@msadig
msadig / VisionLibrary.py
Created September 19, 2022 12:24 — forked from datakurre/VisionLibrary.py
Clicking Selenium elements with OpenCV library
from robot.libraries.BuiltIn import BuiltIn
import cv2
import shutil
import tempfile
class TemporaryDirectory(object):
def __enter__(self):
self.name = tempfile.mkdtemp()
@msadig
msadig / Create branch from issue.md
Last active July 26, 2021 08:49
TamperMonkey Script: Github - Create branch from issue
@msadig
msadig / image_migration.py
Last active February 19, 2021 08:23
Download content of directory from FTP server
# -*- coding: utf-8 -*-
import ftplib
import os
from time import sleep
SERVER_URL = ""
USER = ""
PASSWORD = ""
SRC_FOLDER = os.environ.get("SRC_FOLDER", "PUTFILESHERE/images/products")
#include <Key.h>
#include <Keypad.h>
#include <DS3231.h>
#include <Servo.h>
#include <LiquidCrystal.h>
const byte ROWS = 4; // Four rows
const byte COLS = 4; // Three columns
// Define the Keymap
@msadig
msadig / tweet-pic.gs
Created June 21, 2018 15:01
Post media files to Twitter using Google Apps Script
function getTwitterService() {
// Check https://github.com/gsuitedevs/apps-script-oauth1#usage
// for the docs
return OAuth1.createService('twitter')
// Set the endpoint URLs.
.setAccessTokenUrl('https://api.twitter.com/oauth/access_token')
.setRequestTokenUrl('https://api.twitter.com/oauth/request_token')
.setAuthorizationUrl('https://api.twitter.com/oauth/authorize')
// Set the consumer key and secret.
@msadig
msadig / docker-cleanup
Last active August 30, 2023 07:58 — forked from wdullaer/docker-cleanup
Cleanup unused Docker images and containers
#!/bin/sh
# Cleanup docker files: untagged containers and images.
#
# Use `docker-cleanup -n` for a dry run to see what would be deleted.
exited_containers() {
[ "$(docker ps -f status=exited -q)" ] && docker rm $(docker ps -f status=exited -q)
}
tangled_images() {
@msadig
msadig / docker-install.sh
Last active August 30, 2023 10:30
Install docker and docker compose
#!/bin/sh
DOCKER_COMPOSE_V=1.26.2
# Install Docker
# ref: https://github.com/docker/docker-install
# wget -qO- https://get.docker.com/ | sh
curl -fsSL get.docker.com -o get-docker.sh
bash get-docker.sh
@msadig
msadig / create_swap.sh
Created May 14, 2017 14:17 — forked from garystafford/create_swap.sh
From my blog post, Scripting Linux Swap Space: Scripting Linux Swap Space
#!/bin/sh
# size of swapfile in megabytes
swapsize=512
# does the swap file already exist?
grep -q "swapfile" /etc/fstab
# if not then create it
if [ $? -ne 0 ]; then
@msadig
msadig / remove_swap.sh
Created May 14, 2017 14:16 — forked from garystafford/remove_swap.sh
From my blog post, Scripting Linux Swap Space: Scripting Linux Swap Space
#!/bin/sh
# does the swap file exist?
grep -q "swapfile" /etc/fstab
# if it does then remove it
if [ $? -eq 0 ]; then
echo 'swapfile found. Removing swapfile.'
sed -i '/swapfile/d' /etc/fstab
echo "3" > /proc/sys/vm/drop_caches
//l.sauer 2011, public domain
//returns a hash table with the word as index and frequency as value; good for svg / canvas -plotting or other experiments
//[:punct:] Punctuation symbols . , " ' ? ! ; : # $ % & ( ) * + - / < > = @ [ ] \ ^ _ { } | ~
var wordcnt = function(id){
var hist = {}, words = document.getElementById(id).innerText.split(/[\s*\.*\,\;\+?\#\|:\-\/\\\[\]\(\)\{\}$%&0-9*]/)
for( i in words)
if(words[i].length >1 )
hist[words[i]] ? hist[words[i]]+=1 : hist[words[i]]=1;
return hist;
};