Skip to content

Instantly share code, notes, and snippets.

@dasegn
dasegn / sanitize
Created June 14, 2013 18:41
Sanitize database inputs
<?php
function cleanInput($input) {
$search = array(
'@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
'@<style[^>]*?>.*?</style>@siU', // Strip style tags properly
'@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments
);
@dasegn
dasegn / gist:27fe1234289c4ee1c248
Created July 15, 2014 23:16
Toma en cuenta al archivo authorized keys si la carpeta de home está encriptada
# Make your public key accessible
mkdir -m 700 /home/.ecryptfs/$USER/.ssh
echo $YOUR_PUBLIC_KEY > /home/.ecryptfs/$USER/.ssh/authorized_keys
ln -s /home/.ecryptfs/$USER/.ssh/authorized_keys ~/.ssh/authorized_keys
ecryptfs-umount-private
chmod 700 $HOME
mkdir -m 700 ~/.ssh
ln -s /home/.ecryptfs/$USER/.ssh/authorized_keys ~/.ssh/authorized_keys
# Make it auto-mount with first login.
@dasegn
dasegn / uninstall_visual_studio
Created January 29, 2015 19:23
Uninstall all Visual Studio
:: Uninstall visual studio, need admin permissions an patience
wmic product where "name like 'Microsoft Visual%'" call uninstall /nointeractive
wmic product where "name like 'Microsoft ASP%'" call uninstall /nointeractive
wmic product where "name like 'Microsoft SQL Server%'" call uninstall /nointeractive
@dasegn
dasegn / cambia_documentroot.sh
Last active August 29, 2015 14:26
Cambia DocumentRoot para SELINUX de RedHat
chcon -R -t httpd_sys_content_t /home/user/html
@dasegn
dasegn / split_and_join.sh
Created December 24, 2015 06:50
Split one big TAR file in little parts / join back all in original file
# Create and split file (4GB parts)
sudo tar -zcf - directory_or_file | split -b 4000m - part.tar.gz.
# Join all parts in one file
cat part.tar.gz.* > big-file.tar.gz
# Join all parts and extract (actual path)
cat part.tar.gz.* | tar xzf -
@dasegn
dasegn / ubuntu-command-line-wireless.sh
Last active January 26, 2016 21:34
Ubuntu 14.04 - Connect to wireless network in terminal
nmcli is a command‐line tool for controlling NetworkManager.
Disconnect:
nmcli d disconnect iface wlan0
Connect:
nmcli d wifi connect <WiFiSSID> password <WiFiPassword> iface wlan0
Just change wlan0, <WiFiSSID>, <WiFiPassword> to reflect your setup.
@dasegn
dasegn / disable_theme.sql
Created February 3, 2016 23:27
Disable a Drupal 7 theme in MySQL DB
# Update theme variables
UPDATE variable SET value='s:7:"garland"' WHERE name = 'theme_default';
UPDATE system SET status=1 WHERE name = 'garland';
UPDATE system SET status=0 WHERE name = 'other_theme';
# Truncate cache tables
TRUNCATE cache;
TRUNCATE cache_bootstrap;
TRUNCATE cache_block;
@dasegn
dasegn / upgrade_node_stable.sh
Created April 6, 2016 21:33
Upgrade Node.js to last stable version in OS X
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
@dasegn
dasegn / check-all-radio-and-checkbox.js
Created April 12, 2016 16:46
Check all the radio/checkbox controls in the page
(function() {
var aa = document.querySelectorAll("input[type=checkbox]");
for (var i = 0; i < aa.length; i++){
aa[i].checked = true;
}
var ab = document.querySelectorAll("input[type=radio]");
for (var i = 0; i < ab.length; i++){
ab[i].checked = true;
}
})()
#This line get one single table from the full DB dump file in MySQL
sed -n -e '/CREATE TABLE.*`mytable`/,/CREATE TABLE/p' mysql.dump > mytable.dump