Skip to content

Instantly share code, notes, and snippets.

@yfe404
yfe404 / watcher.sh
Last active November 1, 2017 10:01
Simple directory watcher - allows you to monitor recursively a directory for changes in a file. Each time a changed is made, executes the comman that you specified
#/bin/bash
##################################################################
# SIMPLE DIRECTORY WATCHER
#
# Usage:
# bash test.sh
#
# Role:
# Simple Directory Watcher allows you to monitor
@yfe404
yfe404 / main.py
Created October 10, 2017 13:12
robo-matplotlib-image-reading
# Import some packages from matplotlib
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
# Uncomment the next line for use in a Jupyter notebook
#%matplotlib inline
# Define the filename, read and plot the image
filename = 'sample.jpg'
image = mpimg.imread(filename)
plt.imshow(image)
@yfe404
yfe404 / main.py
Created October 10, 2017 13:15
robo-matplotlib-numpy-image-rgb-viz
# Import some packages from matplotlib
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
# Import the "numpy" package for working with arrays
import numpy as np
# Uncomment the next line for use in a Jupyter notebook
#%matplotlib inline
# Define the filename, read and plot the image
filename = 'sample.jpg'
import json
import requests
from bottle import debug, request, route, run
GRAPH_URL = "https://graph.facebook.com/v2.6"
VERIFY_TOKEN = 'YOUR_VERIFY_TOKEN'
PAGE_TOKEN = 'YOUR_PAGE_TOKEN'
def send_to_messenger(ctx):
@yfe404
yfe404 / main.py
Created April 3, 2018 13:01
Basic flask app factory pattern
def create_app():
"""
Create Flask application using the app factory pattern.
:return: Flask app
"""
app = Flask(__name__, instance_relative_config=True)
app.config.from_object('config.settings')
@yfe404
yfe404 / main.py
Created May 25, 2018 16:57
scrap-instagram
"""
Scrap caption and images from instagram using https://deskgram.org
"""
import requests
from bs4 import BeautifulSoup
BASE_URL = 'https://deskgram.org'
USER = 'healthymealsberlin'
start_url = BASE_URL + '/' + USER
@yfe404
yfe404 / gist:01f7fb25e85ffb88b38c50ff23de4b69
Last active April 3, 2019 09:24
Emacs no window as git editor
git config --global core.editor "emacs -nw"
@yfe404
yfe404 / instagram.sh
Last active June 5, 2019 08:11
Scrap Instagram public information on a user including biography, number of followers, post image urls and captions, number of likes per post ...
curl https://www.instagram.com/USERNAME/ | grep 'window._sharedData = ' | python -c 'print(input()[64:-10])' | jq
@yfe404
yfe404 / website.py
Created June 5, 2019 12:00
Website abstraction in Python for scraping
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import WebDriverException
import os
import time
class Website(webdriver.Firefox):
def connect(self, user=os.environ['USERNAME'], password=os.environ['PASSWORD']):
self.get("https://www.example.com/login")
@yfe404
yfe404 / bootable.sh
Created June 13, 2019 07:48
Create a bootable usb from ISO image
sudo dd if=inputfile.iso of=/dev/disk<?> bs=4M && sync