Skip to content

Instantly share code, notes, and snippets.

View maietta's full-sized avatar

Nick Maietta maietta

View GitHub Profile
@maietta
maietta / PhonecallReceiver.java
Created August 20, 2016 23:29 — forked from ftvs/PhonecallReceiver.java
Detecting an incoming call coming to an Android device. Remember to set the appropriate permissions in AndroidManifest.xml as suggested in the Stackoverflow link. Usage example in comments. Source: http://stackoverflow.com/a/15564021/264619 Explanation: http://gabesechansoftware.com/is-the-phone-ringing/#more-8
package com.gabesechan.android.reusable.receivers;
import java.util.Date;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
public abstract class PhonecallReceiver extends BroadcastReceiver {
# Raspberry software used
2015-02-16-raspbian-wheezy.img
# Install dependencies
sudo apt-get update
sudo apt-get install -y python-pip python-virtualenv python-dev
# Enable audio 3.5mm: 1=>3.5mm 2=>HDMI
amixer cset numid=3 1
#!/bin/sh
# Author: Nicolas Schneider
# Mounts all volumes that are mounted in a Docker container
# under a given root relative to their mount point in the container.
# Usage: bindMountDockerData.sh container /mnt/path
#
# Example: Docker container 'demo' which has a volume mounted at /somedata and
# another at /home/userdata.
# Running 'bindMountDockerData.sh demo /mnt/dockerdemo'
# will result in:
@maietta
maietta / gist:f445c428665a1ba33bfbc40faa544dc6
Created June 24, 2017 01:38
If you need to do this on a running container you can use docker exec (added in 1.3).
First, find the container's name or ID:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b9b7400ddd8f ubuntu:latest "/bin/bash" 2 seconds ago Up 2 seconds elated_hodgkin
In the example above we can either use b9b7400ddd8f or elated_hodgkin.
If you wanted to copy everything in /tmp/somefiles on the host to /var/www in the container:
$ cd /tmp/somefiles
(Linux Example) Create partitions:
# parted -s /dev/vdb mklabel gpt
# parted -s /dev/vdb unit mib mkpart primary 0% 100%
(Linux Example) Create filesystem:
# mkfs.ext4 /dev/vdb1
(Linux Example) Mount block storage:
# mkdir /mnt/blockstorage
# echo >> /etc/fstab
@maietta
maietta / decades_function.php
Created July 10, 2017 12:07
Decades with years by range of Years (PHP)
/* To get a list of decades with the years, from a range selection. Useful for navigational elements on webpages, for example. */
Array
(
[2010] => Array
(
[0] => 2018
[1] => 2017
[2] => 2016
[3] => 2015
@maietta
maietta / clean_bootdir.sh
Created July 17, 2017 02:47
One liner to clean up /boot on Ubuntu/Debian
sudo apt-get purge $(for tag in "linux-image" "linux-headers"; do dpkg-query -W -f'${Package}\n' "$tag-[0-9]*.[0-9]*.[0-9]*" | sort -V | awk 'index($0,c){exit} //' c=$(uname -r | cut -d- -f1,2); done)
@maietta
maietta / build_inventory.php
Created July 17, 2017 18:33
Build an inventory of PDF data in a SQL database, via PDO
<?php
$group = "pcldtmdv";
//$years = range(2002, 2012);
$years = range(2013, 2018);
try {
$db = new PDO('mysql:dbname=arb01_data;host=localhost', 'arb01_automation', '6@yyM^cl42!0s44ai5');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@maietta
maietta / gist:63ed80e698275ab6e47599a489cb2857
Created July 17, 2017 19:41
SQL: Select unique column along with count of each
SELECT
page_size,
COUNT(1) AS `count`
FROM
pdf_inventory
GROUP BY
page_size
ORDER by count DESC
@maietta
maietta / gist:8f01b0e5890715361257c3dd08607f78
Created July 17, 2017 19:59
Points Pixels Ems Percent conversion chart
http://reeddesign.co.uk/test/points-pixels.html
Points Pixels Ems Percent
6pt 8px 0.5em 50%
7pt 9px 0.55em 55%
7.5pt 10px 0.625em 62.5%
8pt 11px 0.7em 70%
9pt 12px 0.75em 75%
10pt 13px 0.8em 80%
10.5pt 14px 0.875em 87.5%