Skip to content

Instantly share code, notes, and snippets.

root@app:/var/tmp# /usr/bin/time -v cat www1/error.log www1/error.log.1 www2/error.log www2/error.log.1 | sed -r -n 's/^\[(\w)\w+ (\w+ \w+).+/\2 \1/p' | awk '{count[$1]++}END{for(j in count) print j" "count[j]}' FS=: | sort;
Command being timed: "cat www1/error.log www1/error.log.1 www2/error.log www2/error.log.1"
User time (seconds): 0.37
System time (seconds): 19.54
Percent of CPU this job got: 3%
Elapsed (wall clock) time (h:mm:ss or m:ss): 8:55.67
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
root@app:~# date;
Thu Oct 24 22:59:57 CDT 2013
root@app:~# cd /var/log/apache2; mkdir combined_error_logs;
root@app:/var/log/apache2# rsync -a -e ssh root@www1:/var/log/apache2/error* combined_error_logs/www1;You have new mail in /var/mail/root
root@app:/var/log/apache2# rsync -a -e ssh root@www2:/var/log/apache2/error* combined_error_logs/www2;You have new mail in /var/mail/root
root@app:/var/log/apache2# date;
Thu Oct 24 23:02:03 CDT 2013
root@app:/var/log/apache2# cd combined_error_logs/www1; gunzip *.gz; cd ../..;
root@app:/var/log/apache2# cd combined_error_logs/www2; gunzip *.gz; cd ../..;
root@app:/var/log/apache2# date;
@CNG
CNG / gist:11174202
Last active August 29, 2015 14:00
MTML highlighting for Coda 2 on OSX Mavericks
Trying to do this within Coda 2 -> Preferences -> Editor -> Custom Syntax Modes worked on one computer but gave me an error on another. So for that computer, I did this:
Used https://github.com/zenangst/Coda-2-Modes:
cd ~/Library/Application\ Support/Coda\ 2
mv Modes Modes.bak
git clone git@github.com:zenangst/Coda-2-Modes.git Modes
sed -i -e 's/<extension>xml<\/extension>/<extension>xml<\/extension><extension>mtml<\/extension>/' Modes/XML.mode/Contents/Resources/ModeSettings.xml
@CNG
CNG / gist:edd8f6210caede7a7f8e
Created June 16, 2014 06:16
Japanese katakana and hiragana in plain text
Katakana Codes
ァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶヷヸヹヺ・
Punctuation and Symbols
゛゜ーヽヾ
Phonetic Extensions for Ainu
ㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ
Circle Forms
@CNG
CNG / .php
Last active April 20, 2017 08:25
Author page views PHP
<?php
// 2013-10-16 charlie@gorichanaz.com: initial commit
/**
* Return Google Core Reporting API access token
* @return string|bool access token or false if embedded parameters invalid
*/
function getAccessToken()
{
@CNG
CNG / .mtml
Last active April 20, 2017 08:26
Author page views Movable Type template
<mt:Ignore>this is password protected by the accompanying .htaccess and .htpw files</mt:Ignore>
<mt:Section regex_replace="/\n\s*\n/mg","\n">
<$mt:Include module="timing" part="start"$>
<mt:Ignore>Number of years to show</mt:Ignore>
<$mt:Var name="total_years" value="2">
<mt:Ignore>Store values for past $total_years years to test entry dates against. Will result in something like: Y0=2013; Y1=2012; Y2=2011</mt:Ignore>
<$mt:Date format="%Y" setvar="now_year"$>
<mt:For from="1" to="$total_years">
@CNG
CNG / pop.php
Last active April 20, 2017 08:14
Movable Type + Field Day popular stories script
<?php
/*
This script looks up items most viewed according to Google Analytics in a given time span and given certain blog or entry restrictions, returning either a listing for debugging or JSON data for further processing.
The possible parameters are:
* days int Number of days of history to pull results from. Default is 7.
* entry_id int Entry IDs (from Movable Type) of entries that should NOT be included in results, such as to prevent the currently viewed story from showing up in a "Read Next" sidebar. Multiple IDs can be provided by supplying multiple instances of this parameter, i.e. entry_id=300&entry_id=301
@CNG
CNG / gist:c129161d15ef315a1a31
Created August 19, 2015 02:23
Detect if file changed in source files
CURRENT_VERSION=`find /var/solr/data/wordpress/conf -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f1 -d"."`
REPO_VERSION=`find /root/configs/var/solr/data/wordpress/conf -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f1 -d"."`
if [ "$CURRENT_VERSION" -lt "$REPO_VERSION" ]
then
cp -a /root/configs/var/solr/data/wordpress/conf /var/solr/data/wordpress
service solr restart
fi
@CNG
CNG / dump.pl
Created November 5, 2015 20:40
Mongo dump from Perl
#!/usr/bin/perl
use DateTime;
use File::Path;
use DBI;
use File::Basename;
require File::Spec->catfile(dirname(__FILE__),'nearme-dump.cnf');
my $root = '/mnt/nfs/bak/nearme';
my $time = DateTime->now()->ymd();
@CNG
CNG / .sh
Last active June 17, 2020 23:48
Fix special characters in filenames on FS and in WP DB
hostname=
username=
database=
password=
cd /var/www/html/wp-content/uploads
export MYSQL_PWD=$password
MYSQL_CONN="mysql -B -h$hostname -u$username $database --disable-column-names"