Skip to content

Instantly share code, notes, and snippets.

@zarza
zarza / ajax-cache-include.js
Created Nov 17, 2018 — forked from jasondmoss/ajax-cache-include.js
jQuery: Load external scripts and cache them.
View ajax-cache-include.js
/**
* Cache AJAX-included scripts.
*/
$.cachedScript = function (url, options) {
options = $.extend(
options || {}, {
dataType: "script",
cache: true,
url: url
}
@zarza
zarza / fastestRandomSelect.sql
Last active Mar 10, 2018
Fastest SQL to get random rows from MySQL in LARGE and small databases
View fastestRandomSelect.sql
# Ejemplo 1
SELECT * FROM post AS r1 JOIN (SELECT (RAND() * (SELECT MAX(postid) FROM post)) AS postid) AS r2 WHERE r1.postid >= r2.postid ORDER BY r1.postid ASC LIMIT 10
# Ejemplo 2
SELECT * FROM (SELECT * FROM `comprobantes` WHERE `ind-estado` = 'procesando' OR (`ind-estado` = 'rechazado' AND `respuesta-xml` IS NULL)) AS r1 JOIN (SELECT (RAND() * (SELECT MAX(id) FROM comprobantes)) AS id) AS r2 WHERE r1.id >= r2.id ORDER BY r1.id ASC LIMIT 100
@zarza
zarza / checknstart_service_if_down.sh
Created Jan 19, 2018
If this found your service stopped it will try to start it
View checknstart_service_if_down.sh
#!/bin/bash
echo '[Start service if it is down]'
echo
# ZARZA | A HEAD OF OUR TIME
# https://zarza.com
service=nginx
if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 ))
then
echo "$service is up!"
@zarza
zarza / create_emails_from_txt.sh
Created Oct 14, 2017
Create multiple email addresses in Plesk from a text file easily
View create_emails_from_txt.sh
#!/bin/bash
echo '[Create multiple email addresses in Plesk from a text file easily]'
echo
# ZARZA | A HEAD OF OUR TIME
# https://zarza.com
FILE='mails.txt'
if [ -f $FILE ]; then
while read p; do
@zarza
zarza / gist:75b907583ecef3c46531
Last active Mar 15, 2016
MySQL error: Table './..../postparsed' is marked as crashed and Should be repaired
View gist:75b907583ecef3c46531
#Try 'REPAIR TABLE postparsed;' first.
DROP TABLE `postparsed`;
CREATE TABLE IF NOT EXISTS `postparsed` (
`Postid` int (10) unsigned NOT NULL default '0',
`Dateline` int (10) unsigned NOT NULL default '0',
`Styleid` smallint (5) unsigned NOT NULL default '0',
`Languageid` smallint (5) unsigned NOT NULL default '0',
`Hasimages` smallint (6) NOT NULL default '0',
`Pagetext_html` medium text,
You can’t perform that action at this time.