Skip to content

Instantly share code, notes, and snippets.

@shmaltorhbooks
shmaltorhbooks / gist:5553774
Created May 10, 2013 11:08
delete from multiple tables
DELETE c, t
FROM crm_calls c
LEFT JOIN crm_tickets t on t.call_id=c.id
WHERE c.last_main_ticket_type_id=0
@shmaltorhbooks
shmaltorhbooks / delete_empty.php
Created May 10, 2013 11:10
delete empty items from array
$clearArr = array_diff($clearArr, array(''));
// 500 000 array_diff => 0.21610689163208
public static function removeEmpty($var) {
return (!empty($var));
}
$clearArr = array_filter($clearArr, "removeEmpty");
// 500 000 removeEmpty => 0.067395925521851
@shmaltorhbooks
shmaltorhbooks / ip2long.sql
Created May 10, 2013 11:13
ip => long / long => ip
select INET_ATON('94.27.106.191') => 1578855103
select INET_NTOA(1578855103) => 94.27.106.191
@shmaltorhbooks
shmaltorhbooks / kill.php
Created May 10, 2013 11:15
kill all user processes
<?php
$params = $_SERVER['argv'];
if (!$params[1])
die("Enter user name...\n");
$link = mysql_connect('IP', 'UserName', 'Pwd');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo "Connected successfully\n";
@shmaltorhbooks
shmaltorhbooks / file.sql
Last active December 17, 2015 04:58
select sights
SELECT
`sights_lang`.`name`,
`sights_lang`.`address`,
`sights`.`category_id`,
`sights_categories_lang`.`categoryName`,
`sights`.`latitude`,
`sights`.`longitude`,
`sights`.`sights_id`
FROM `partner_hotels`.`sights_lang`
JOIN `partner_hotels`.`sights`
<?php
$dir = opendir ("./mails");
while ( $file = readdir ($dir)) {
if (( $file != ".") && ($file != "..")) {
system('sendmail -t < ./mails/'.$file);
unlink('./mails/'.$file);
echo "$file\n";
}
}
closedir ($dir);
@shmaltorhbooks
shmaltorhbooks / replace.sql
Last active December 17, 2015 04:58
find and replace CR
SELECT * FROM auto4.model WHERE `name` like '%\n';
UPDATE auto3.model m SET name=REPLACE(name, '\n', '')
yum remove selinux-policy evolution -y;
wget http://archive.fedoraproject.org/pub/archive/fedora/linux/releases/12/Everything/x86_64/os/Packages/mysql-gui-common-5.0r14-1.fc12.x86_64.rpm http://archive.fedoraproject.org/pub/archive/fedora/linux/releases/12/Everything/x86_64/os/Packages/mysql-gui-tools-5.0r14-1.fc12.x86_64.rpm http://archive.fedoraproject.org/pub/archive/fedora/linux/releases/12/Everything/x86_64/os/Packages/mysql-query-browser-5.0r14-1.fc12.x86_64.rpm http://archive.fedoraproject.org/pub/archive/fedora/linux/releases/12/Everything/x86_64/os/Packages/mysql-administrator-5.0r14-1.fc12.x86_64.rpm;
rpm -ihv ./*.rpm
yum install libXv-1.0.5-1.fc13.i686 libXScrnSaver-1.2.0-1.fc12.i686 qt-4.6.3-8.fc13.i686 qt-x11-4.6.3-8.fc13.i686 -y;
yum install skype -y;
yum install cowsay -y;
yum install mc -y;
@shmaltorhbooks
shmaltorhbooks / permissions.sh
Created May 10, 2013 11:27
644 to files 755 to folders
find ./ -type f -exec chmod 644 {} \;
find ./ -type d -exec chmod 755 {} \;
@shmaltorhbooks
shmaltorhbooks / remove.sh
Created May 10, 2013 11:29
remove .svn recursively
rm -rf `find . -type d -name .svn`