Skip to content

Instantly share code, notes, and snippets.

View matt-thomas's full-sized avatar

Matt Thomas matt-thomas

View GitHub Profile
@matt-thomas
matt-thomas / gist:10896657
Last active August 29, 2015 13:59
Tag And Delete Git Branches
git checkout mybranch
git pull
git tag -m 'final commit for mybranch' archive/mybranch mybranch
git branch -D mybranch
git push --tags origin :mybranch
<?php
/**
* Remove any non-ASCII characters and convert known non-ASCII characters
* to their ASCII equivalents, if possible.
*
* @param string $string
* @return string $string
* @author Jay Williams <myd3.com>
* @license MIT License
* @link http://gist.github.com/119517
@matt-thomas
matt-thomas / gist:fa76c0ab890f3ad9a8c4
Created January 15, 2015 16:04
database export outline
for database in /var/lib/mysql; do mysqldump -uroot -p $database | bzip2 - > /mnt/s3fs/$database.`date +%F`.sql.bz2; done
@matt-thomas
matt-thomas / gist:aea150b68ed86abf694b
Created January 15, 2015 16:04
mysql prefix delete
#!/bin/bash
DB_STARTS_WITH="sb6-"
DBS="$(mysql -Bse 'show databases')"
for db in $DBS; do
if [[ "$db" == $DB_STARTS_WITH* ]]; then
echo "Deleting $db"
mysql -Bse "drop database \`$db\`"
<style><!--
/*****
* Site version alert block - admin theme
****/
.header-siteversion div,
.header-siteversion p,
.header-siteversion .block {
line-height: 1.5em;
text-transform: uppercase;
margin: 0;
'bank_aba_code' => '011002628',
'bank_acct_num' => '123456789123',
'bank_acct_type' => 'CHECKING',
'bank_name' => 'Bank of Earth',
'bank_acct_name' => 'Jane Doe',
@matt-thomas
matt-thomas / gist:fc2a2e5ccbf9458e2db7da1563a67369
Created October 3, 2017 15:45
mysql parallel import osx
# Split MYSQL dump file
gunzip -c database.sql.gz | awk '/DROP TABLE IF EXISTS/{n++}{filename = "out" n ".sql"; print > filename; close(filename)}'
# Parallel import using GNU Parallel http://www.gnu.org/software/parallel/
ls -rS *.sql | parallel --joblog joblog.txt mysql -uXXX -pYYY db_name "<"
@matt-thomas
matt-thomas / gist:b2bb4f2334a693b72632da2f4083eb1d
Created May 7, 2018 13:59
How to make Ralink RT5370 USB WIFI Card work on Linux
modinfo rt2800usb | grep 5370
modprobe rt2800usb
$entity_type = '';
$field_name = 'field_';
$bundle_name = '';
$info_config = field_info_field($field_name);
$info_instance = field_info_instance($entity_type, $field_name, $bundle_name);
unset($info_config['id']);
unset($info_instance['id'], $info_instance['field_id']);
include_once DRUPAL_ROOT . '/includes/utility.inc';
$output = "field config: " . drupal_var_export($info_config) . ";\n";
#!/usr/bin/env bash
from="1 March, 2021"
to="10 June, 2021"
users=$(git shortlog -sn --no-merges --since="$from" --before="$to" | awk '{printf "%s %s\n", $2, $3}')
IFS=$'\n'
echo -e "User name;Files changed;Lines added;Lines deleted;Total lines (delta);Add./Del. ratio (1:n);Commit count"
for userName in $users
do
result=$(git log --author="$userName" --no-merges --shortstat --since="$from" --before="$to" | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6; delta+=$4-$6; ratio=deleted/inserted} END {printf "%s;%s;%s;%s;%s", files, inserted, deleted, delta, ratio }' -)
countCommits=$(git shortlog -sn --no-merges --since="$from" --before="$to" --author="$userName" | awk '{print $1}')