Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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: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;