Skip to content

Instantly share code, notes, and snippets.

View matt-thomas's full-sized avatar

Matt Thomas matt-thomas

View GitHub Profile
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
from googleapiclient.discovery import build
import pickle
import os
import PyPDF2
import pandas as pd
from io import BytesIO
from googleapiclient.http import MediaIoBaseDownload
cat your_script.rb | heroku run "rails runner -" -a app-name
#!/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}')
$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";
@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
@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 "<"
'bank_aba_code' => '011002628',
'bank_acct_num' => '123456789123',
'bank_acct_type' => 'CHECKING',
'bank_name' => 'Bank of Earth',
'bank_acct_name' => 'Jane Doe',
<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;
@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\`"
@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