Skip to content

Instantly share code, notes, and snippets.

@n5i
n5i / gist:4292187
Created December 15, 2012 08:45
Number httpd connection
netstat -anpt|grep httpd |grep ESTABLISHED
@n5i
n5i / gist:4358161
Created December 22, 2012 09:08
Sleep HDD
hdparm -Y /dev/sda
@n5i
n5i / gist:4954731
Created February 14, 2013 17:58
PHPExcel - break links to other sheets
// Replace calculated values with static data. From A to H from 1 to 70
function breakExcelLinksInSheet( $sheet ){
$labels = array( 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' );
foreach( $labels as $label ){
for( $i = 1; $i < 70; $i++ ){
$val = $sheet->getCell( $label.$i );
//for incorrect formulas take old value
@n5i
n5i / gist:5240169
Created March 25, 2013 20:01
whois
function whois_query($domain) {
// fix the domain name:
$domain = strtolower(trim($domain));
$domain = preg_replace('/^http:\/\//i', '', $domain);
$domain = preg_replace('/^www\./i', '', $domain);
$domain = explode('/', $domain);
$domain = trim($domain[0]);
// split the TLD from domain name
@n5i
n5i / gist:5240177
Created March 25, 2013 20:02
Email php error
<?php
// Our custom error handler
function nettuts_error_handler($number, $message, $file, $line, $vars){
$email = "
<p>An error ($number) occurred on line
<strong>$line</strong> and in the <strong>file: $file.</strong>
<p> $message </p>";
$email .= "<pre>" . print_r($vars, 1) . "</pre>";
@n5i
n5i / gist:6132125
Created August 1, 2013 14:50
Linux. Get folders size in one level deep
du -ch --max-depth=1
@n5i
n5i / gist:8867603
Created February 7, 2014 17:30
Search by text
grep -Rsl "GIF89a1" /home/ > hacked2.txt
@n5i
n5i / gist:9184360
Created February 24, 2014 09:17
GO: write log
// Write to log
logf, er := os.OpenFile("/home/go/src/app/event.log", os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0640)
if er != nil {
log.Fatalln(er)
}
log.SetOutput(logf)
log.Println("START")
log.SetFlags(log.Ldate | log.Ltime | log.Lmicroseconds | log.Lshortfile)
@n5i
n5i / gist:1dfde73c468f67e68c80
Created May 10, 2014 16:46
swiftmailer install
run in application folder:
echo '{"require":{"swiftmailer/swiftmailer": "5.2.*@dev"}}' > composer.json && composer install
@n5i
n5i / gist:000954eb6d2901cfa12c
Created August 21, 2014 20:54
Neo4j orphan nodes detection
MATCH (n)
WHERE NOT EXISTS((n)--())
RETURN n