Skip to content

Instantly share code, notes, and snippets.

@sergioska
sergioska / gist:9955949
Last active August 29, 2015 13:58
Delete items from a table with a constraint
-- disable foreign check
SET FOREIGN_KEY_CHECKS=0;
-- execute delete query
DELETE FROM BridgeDomainsTags;
-- enable foreign check
SET FOREIGN_KEY_CHECKS=1;
@sergioska
sergioska / gist:9956037
Created April 3, 2014 15:03
kill a process by name
# replace <process_name> with real process name
kill -s KILL `ps faux | grep <process_name> | grep php | egrep -o '\s+([0-9]*)\s+.*' | egrep -o '[0-9]+\s*' | head -1`
@sergioska
sergioska / gist:9956159
Last active August 29, 2015 13:58
JSON-RPC service with Zend_Json_Server
<?php
/* path to Zend library*/
set_include_path(__DIR__ . "/libs");
/* include Zend loader (Zend root) */
require_once __DIR__ . "/libs/Zend/Loader.php";
/* load class */
Zend_Loader::loadClass('Zend_Json_Server');
$server = new Zend_Json_Server();
@sergioska
sergioska / svg2png.sh
Created October 27, 2017 14:00
Convert svg to png on mac from command line
#!/bin/bash
rm -f *.svg.png
for f in *.svg; do
echo "File -> $f"
qlmanage -t -s 1000 -o . $f
done
for f in *.svg.png; do
@sergioska
sergioska / honeypot.html
Last active March 19, 2020 08:19
Honeypot (js bot trap)
<html>
<head>
<title>test bot trap</title>
<script type="text/javascript">
// Set cookie.
function setCookie(name, value, expires, path, domain, secure) {
document.cookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires : "") +
((path) ? "; path=" + path : "") +
@sergioska
sergioska / .htaccess
Last active March 31, 2018 09:16
webpack configuration to use dev server without add localhost switch on source
<IfModule mod_rewrite.c>
RewriteEngine On
# redirect every requested real file (.js, .css, ecc ...) to webpack dev server
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^public/assets/(.*)$ http://localhost:3000/assets/$1 [L]
</IfModule>
@sergioska
sergioska / versions.sh
Created May 10, 2018 08:14
VERSIONS AWS
#!/bin/bash
EMI=/etc/issue
NODE=`which node`
NPM=`which npm`
APACHE=httpd
echo AMI VERSION: `cat $EMI | grep -Eo [0-9\.]+`
echo NODE VERSION: `$NODE -v`
echo NPM VERSION: `$NPM -v`
@sergioska
sergioska / ssl.conf
Last active June 28, 2018 09:02
https apache2
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile "/etc/ssl/ssl_certificate.crt"
SSLCertificateKeyFile "/etc/ssl/ssl_certificate.key"
SSLCACertificateFile "/etc/ssl/ssl_certificate.ca-bundle"
ServerAdmin admin@mysite.com
DocumentRoot /var/www/html/mysite
ServerName www.mysite.com
@sergioska
sergioska / cors.conf
Created September 13, 2018 14:07
CORS Apache Configuration
<VirtualHost *:80>
# add this in apache virtualhost configuration file to avoid CORS problem enabling request from multiple origin
# (optionally change LocationMatch path)
<LocationMatch "/">
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header set Access-Control-Max-Age "1000"
Header set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
</LocationMatch>
</VirtualHost>
@sergioska
sergioska / swapon.sh
Created October 21, 2019 08:18
Enable swap allocation
# swap space allocation
sudo fallocate -l 1G /var/swap.1
# or use following command that agnostic about distro
#sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo chmod 600 /var/swap.1
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1
# check if swap is up in the right way
sudo swapon --show