Skip to content

Instantly share code, notes, and snippets.

maztch maztch

Block or report user

Report or block maztch

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@maztch
maztch / docker-clean.sh
Last active May 25, 2019
Remove all docker images and containers
View docker-clean.sh
#!/bin/bash
#stop all containers
docker kill $(docker ps -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
View gist:0daf64463e561508fb85bc34448dc3ab
https://github.com/phpstan/phpstan
https://github.com/phpstan/phpstan-strict-rules
https://github.com/rectorphp/rector
https://github.com/phpDocumentor/phpDocumentor2
https://github.com/FriendsOfPHP/PHP-CS-Fixer
https://github.com/karlosagudo/fixtro
https://github.com/vimeo/psalm
https://github.com/phpmetrics/phpmetrics
@maztch
maztch / sw.js
Created Apr 25, 2019 — forked from ireade/sw.js
Handle broken images with the service worker
View sw.js
self.addEventListener('install', (e) => {
e.waitUntil(
caches.open("precache").then((cache) => cache.add("/broken.png"))
);
});
function isImage(fetchRequest) {
return fetchRequest.method === "GET" && fetchRequest.destination === "image";
}
@maztch
maztch / cors.js
Created Sep 10, 2018
node CORS route sample
View cors.js
// all our previous code should be here
// this array is used for identification of allowed origins in CORS
const originWhitelist = ['http://localhost:3000', 'https://example.net'];
// middleware route that all requests pass through
router.use((request, response, next) => {
console.log('Server info: Request received');
let origin = request.headers.origin;
@maztch
maztch / waitfor.js
Created Jun 7, 2018
wait for jquery on async load (or other class)
View waitfor.js
function doSomething() {
console.log('do something with jQuery');
}
var waitInterval = window.setInterval(function () {
try {
if (jQuery === 'function') {
clearInterval(waitInterval);
doSomething();
}
@maztch
maztch / queue checker
Last active Oct 28, 2017
a process count check for php-enqueue/enqueue-bundle
View queue checker
<?php
/**
* It's just a sample helper
* I'm sure it can be done better...
**/
class QueueHelper
{
static public function check(){
$out = [];
@maztch
maztch / brew-perms.sh
Created Apr 10, 2017 — forked from jaibeee/brew-perms.sh
Configure homebrew permissions to allow multiple users on MAC OSX. Any user from the admin group will be able to manage the homebrew and cask installation on the machine.
View brew-perms.sh
#!/bin/sh
# Configure homebrew permissions to allow multiple users on MAC OSX.
# Any user from the admin group will be able to manage the homebrew and cask installation on the machine.
# allow admins to manage homebrew's local install directory
chgrp -R admin /usr/local
chmod -R g+w /usr/local
# allow admins to homebrew's local cache of formulae and source files
chgrp -R admin /Library/Caches/Homebrew
@maztch
maztch / ads_block_detect.js
Created Mar 3, 2017
Detects ads blockers
View ads_block_detect.js
var adBlockEnabled = false;
var testAd = document.createElement('div');
testAd.innerHTML = '&nbsp;';
testAd.className = 'adsbox';
document.body.appendChild(testAd);
window.setTimeout(function() {
if (testAd.offsetHeight === 0) {
adBlockEnabled = true;
}
testAd.remove();
@maztch
maztch / magento_clean.sql
Created Nov 30, 2016
Delete test data (sales, customers, logs) and reset index for tables
View magento_clean.sql
# Tested on Magento CE 1.4.1.1 - 1.9.2.4
SET FOREIGN_KEY_CHECKS=0;
##############################
# SALES RELATED TABLES
##############################
TRUNCATE `db5j_sales_flat_creditmemo`;
TRUNCATE `db5j_sales_flat_creditmemo_comment`;
TRUNCATE `db5j_sales_flat_creditmemo_grid`;
@maztch
maztch / backupdb.sh
Created Nov 16, 2016
database backup script
View backupdb.sh
#!/bin/bash
# this script makes a database backup and delete files older than 15 days
# to make script execuable use 'chmod +x backupdb.sh'
# change username, password and database for yours and modify your path if needed
mysqldump -u [username] -p[password] [database_name] > /root/backups/db_backup_`date +"%Y%m%d%H%M%S"`.sql
# change '-mtime +15' to keep more or less days (and path if needed)
find /root/backups/* -mtime +15 -exec rm {} \;
You can’t perform that action at this time.