Skip to content

Instantly share code, notes, and snippets.

View progress44's full-sized avatar
Drinking coffee

Ani Sinanaj progress44

Drinking coffee
View GitHub Profile
@alirezamika
alirezamika / autoscraper-examples.md
Last active May 15, 2024 03:29
AutoScraper Examples

Grouping results and removing unwanted ones

Here we want to scrape product name, price and rating from ebay product pages:

url = 'https://www.ebay.com/itm/Sony-PlayStation-4-PS4-Pro-1TB-4K-Console-Black/203084236670' 

wanted_list = ['Sony PlayStation 4 PS4 Pro 1TB 4K Console - Black', 'US $349.99', '4.8'] 

scraper.build(url, wanted_list)
@kopiro
kopiro / yarn-x.sh
Last active July 29, 2020 13:27
Yarn run fuzzy matching
pkgj-run-list() {
jq .scripts package.json | grep -o '.*\":' | sed -nE 's/\"(.*)\":/\1/p' | awk '{$1=$1};1' | fzf | tr -d '\r' | tr -d '\n'
}
yarn-x() {
PKG_CMD=$(pkgj-run-list)
[ -n "$PKG_CMD" ] && print -s "yarn $PKG_CMD" && yarn "$PKG_CMD"
}
alias yx="yarn-x"
@kopiro
kopiro / xhr_fetch_hook.js
Last active June 16, 2020 08:32
XHR / Fetch Hook - Log requests directly in the Dev Console
formatBody = (body) => { if (!body) return body; try { return JSON.parse(body); } catch (err) { return body; } };
XMLHttpRequest.prototype._open = XMLHttpRequest.prototype._open || XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function() {
this._openArgs = arguments;
return XMLHttpRequest.prototype._open.apply(this, arguments);
};
XMLHttpRequest.prototype._send = XMLHttpRequest.prototype._send || XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function(body) {
@gadiener
gadiener / create-docker-credentials.sh
Created December 5, 2019 16:33
Create docker-registry secret file
#!/bin/sh
set -e
if [ -n "${DEBUG}" ]; then
set -x
fi
for var in "DOCKER_USERNAME" "DOCKER_PASSWORD" "DOCKER_EMAIL"; do
if [ -z "${!var}" ]; then
@vinzdef
vinzdef / index.js
Created August 6, 2019 11:18
Fork Process in Cluster
const server = require('./server.js')
const numCPUs = require('os').cpus().length
const cluster = require('cluster')
function makeCluster() {
return new Promise((resolve, reject) => {
if (cluster.isMaster) {
for (let i = 0; i < numCPUs; i++) {
cluster.fork()
}
@Polmonite
Polmonite / helpers.php
Last active March 31, 2023 17:21
dump and dd functions
<?php
if (!function_exists('dump')) {
function dump(...$args)
{
$message = implode(
"\n\n",
array_map(
function($value) {
return var_export($value, true);
@gadiener
gadiener / delete-evicted-pod.sh
Created June 21, 2019 12:06
Delete evicted pods
#!/bin/sh
kubectl get po --all-namespaces | awk '{if ($4 ~ /Evicted/) system ("kubectl -n " $1 " delete pods " $2)}'
#!/bin/bash
##
# Author: Andrea Jonus <andrea.jonus@caffeina.com>
# Version: 0.3
# Description: Setup the MacOS build environment for a Titanium project. Run this script once for every machine, copy the generated ssh public key and add it to GitLab.
##
# Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@vinzdef
vinzdef / togif.sh
Created January 9, 2019 13:31
togif - quickly convert video to hq gif with ffmpeg
ffmpeg -i $1 -filter_complex "[0:v] fps=40,scale=800:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" ${1%.*}.gif
@kopiro
kopiro / backup-repos.sh
Last active October 15, 2018 10:39
Backup all Repositories in current directory
backup-repos() {
for i in $(find . -type d -maxdepth 1 -mindepth 1); do
echo "Looking in $i..."
if [ -d "$i/.git" ]; then
echo "Found repository in $i, init backup..."
pushd $i > /dev/null
zip_name="$i-$(date +'%y%m%d').zip"
zip_path="/opt/backups/$zip_name"
echo "ZIP path: $zip_path"
if [ ! -f "$zip_path" ]; then