Skip to content

Instantly share code, notes, and snippets.

@simofacc
simofacc / index.js
Created August 6, 2020 07:43
Tick multiple checkboxes and trigger onChange event
document.querySelectorAll("input[type=checkbox]").forEach(c => { c.checked = true; c.onchange(); });
@simofacc
simofacc / README.MD
Created February 15, 2020 19:19
Squarespace.com to Ghost export/import
@simofacc
simofacc / wordpress-permissions
Created July 31, 2018 10:25
Wordpress Permissions
chown www-data:www-data -R *;
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
@simofacc
simofacc / crontab -e
Created June 26, 2018 08:39
Dokku Ruby Scraper Cron Jobs
* * * * * dokku --rm-container run stats rake scraper:run_scraper
0 * * * * dokku --rm-container run stats rake scraper:hourly_cleanup
0 1 * * * dokku --rm-container run stats rake scraper:nightly_cleanup
* * * * * dokku --rm-container run stats rake scraper:backup_check
@simofacc
simofacc / .buildpacks
Created June 26, 2018 08:09
Dokku Ruby Scraper Buildpacks
https://github.com/heroku/heroku-buildpack-ruby.git
https://github.com/heroku/heroku-buildpack-chromedriver.git
https://github.com/heroku/heroku-buildpack-google-chrome.git
@simofacc
simofacc / changelog.sh
Created April 7, 2016 07:38
Github changelog generator
#!/bin/bash
# Author:Andrey Nikishaev
# Modified: Simon Facciol
echo "CHANGELOG"
echo ----------------------
git for-each-ref --sort=-taggerdate --format '%(tag)-%(*authordate)' refs/tags | grep 'release' | while read RES ; do
IFS='-' read -a arrRES <<< "${RES}"
TAG=${arrRES[0]}
DAT=${arrRES[1]}
echo
@simofacc
simofacc / gulp.js
Last active March 16, 2016 18:13
Gulp setup
/**
* Created by simonfacciol on 13/02/16.
*/
var gulp = require('gulp'),
fs = require('fs'),
del = require('del'),
plugins = require('gulp-load-plugins')({
pattern: ['gulp-*', 'gulp.*'],
replaceString: /\bgulp[\-.]/,
lazy: true,
@simofacc
simofacc / rename.py
Created March 13, 2016 00:49
Python, rename files using csv file map
import os
import csv
with open('old-names-new-names.csv', 'rb') as csvfile:
csvreader = csv.reader(csvfile, delimiter=',', quotechar='"')
for row in csvreader:
name = row[0] + '.jpg'
new = row[1] + '.jpg'
if os.path.exists(name):
os.rename(name, new)
@simofacc
simofacc / mysql-slug.sql
Last active March 13, 2016 00:28
MySQL trigger to generate a slug before inserting a new row
CREATE DEFINER=`[USER_NAME]`@`%` TRIGGER `[DATABASE_NAME]`.`Slug` BEFORE INSERT ON `[TABLE_NAME]`.`games` FOR EACH ROW
BEGIN
IF NEW.slug IS NULL THEN
SET NEW.slug = LOWER(TRIM(NEW.name));
SET NEW.slug = REPLACE(NEW.slug, ':', '');
SET NEW.slug = REPLACE(NEW.slug, ')', '');
SET NEW.slug = REPLACE(NEW.slug, '(', '');
SET NEW.slug = REPLACE(NEW.slug, ',', '');
SET NEW.slug = REPLACE(NEW.slug, '\\', '');
SET NEW.slug = REPLACE(NEW.slug, '?', '');
@simofacc
simofacc / check_resolution.py
Created February 24, 2016 09:20
Check the resolution of images in a directory and output the incorrect image filenames
import Image
import os
files = [f for f in os.listdir('.') if os.path.isfile(f)]
for file in files:
if file.endswith(('.jpg')):
img = Image.open(os.path.join(os.curdir, file))
size = img.size
if ((410, 300) != size):
name = file + ' '