Skip to content

Instantly share code, notes, and snippets.

@CNG
CNG / main.sh
Created March 16, 2017 11:03
Movable Type: Backup DB and app, set up publish queue, logging and PQManager plugin
MT=/var/www/cgi-bin/mt
ADMIN="arck"
if test -L $MT; then
# dereference symlink
TEMP=$(pwd)
cd -P "$MT"
MT=$(pwd)
cd $TEMP
fi
@CNG
CNG / sample.sh
Created May 16, 2016 04:13
Concatenate GoPro MP4 videos
name=$(ls G* | head -1);
ls G* | while read line; do echo file \'$line\'; done | ffmpeg -f concat -i - -c copy "${name%%.*}-all.${name#*.}"
@CNG
CNG / keybase.md
Created April 26, 2016 21:05
keybase.md

Keybase proof

I hereby claim:

  • I am cng on github.
  • I am charlieg (https://keybase.io/charlieg) on keybase.
  • I have a public key ASDYS0iSzU2DXRIFcr_WM29EwqGxVP328Smd3RgYzs5nbAo

To claim this, I am signing this object:

@CNG
CNG / test.c
Created February 27, 2016 02:56
volatile int bufn,obufn;
uint16_t buf[5][128];
q15_t out[640];
q15_t outsq[1280];
void ADC_Handler(){
int f=ADC->ADC_ISR;
if (f&(1<<27)){
bufn=(bufn+1);if(bufn==5)bufn=0;
ADC->ADC_RNPR=(uint32_t)buf[bufn];
@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"
@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 / 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 / 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 / .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 / .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()
{