Skip to content

Instantly share code, notes, and snippets.

@slavikme
slavikme / freefit-get-info-json.py
Created March 26, 2018 11:08
Scrape all clubs and their info from FreeFit.co.il service
import requests
from requests_html import HTMLSession
import json
import datetime
session = HTMLSession()
now = datetime.datetime.now()
def getMoreInfo(id):
url = 'https://freefit.co.il/CLUBS/?CLUB=%d&SUBCLUBCATEGORY=-1' % id
@slavikme
slavikme / send-telegram-on-high-loads.sh
Last active March 28, 2018 10:19
On high system loads turn off http service and send Telegram notification
#!/bin/bash
MAX_THRESHOLD=${MAX_THRESHOLD:-4}
MIN_THRESHOLD=${MIN_THRESHOLD:-2}
TELEGRAM_API="https://api.telegram.org/bot$BOT_API_TOKEN"
monit=`cat /proc/loadavg`
load=`echo $monit | cut -d' ' -f1`
pid=`echo $monit | cut -d' ' -f5`
pinfo=`ps -p $pid u`
@slavikme
slavikme / 1-parallel-job-runner.js
Last active September 19, 2024 07:15
Parallel Job Runner
/**
* Creates a function that performs any promisable task in parallel.
* @param {number} [concurrency] - The maximum number of concurrent jobs that are able to run simultaneously.
* @return {Promise}
*/
const createJobRunner = (concurrency = 3) => {
const EMPTY_SLOT = false;
const BUSY_SLOT = true;