Skip to content

Instantly share code, notes, and snippets.

@ascalabro
ascalabro / audio_stream_parse.php
Created July 11, 2018 13:11
Parses and outputs audio stream
<?php
/**
* Please be aware. This gist requires at least PHP 5.4 to run correctly.
* Otherwise consider downgrading the $opts array code to the classic "array" syntax.
*/
function getMp3StreamTitle($streamingUrl, $interval, $offset = 0, $headers = true)
{
$needle = 'StreamTitle=';
$ua = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36';

Keybase proof

I hereby claim:

  • I am ascalabro on github.
  • I am ascalabro (https://keybase.io/ascalabro) on keybase.
  • I have a public key ASCfgtfTWKjgzi7sf4dXRly_pg0fZv1pGsHXhwtX-q4cygo

To claim this, I am signing this object:

@ascalabro
ascalabro / codevember-8-2017.markdown
Last active November 9, 2017 14:08
Codevember #8 - 2017
@ascalabro
ascalabro / sqlSync.sh
Last active November 15, 2022 05:58
sync two MySQL servers
#!/bin/sh
MINIMUM_ARGS=2 # Require a database name and table name(s). Change to 1 if need to do whole database and only provide database name
# These are the two servers being worked on
# Change configuration here
FROM_MYSQL_HOST=localhost
FROM_USERNAME=myuser
FROM_PASSWORD=mypas
#!/bin/sh
MINIMUM_ARGS=1
if [ $# -lt $MINIMUM_ARGS ]
then
echo "Usage: $0 database_name [table_names]"
else
echo "Dumping $* to file..."
mysqldump -hhostname -uadmin -ppassword $* > /tmp/dbdump.sql
echo "DONE"
echo "Importing dump file..."
#!/bin/sh
# Adds line to your hosts file
# Tested in Mac OS X El Capitan
if [ "$#" -ne 2 ]; then
echo "Usage: $BASH_SOURCE <new IP address> <new hostname>" >&2
exit 1
fi
awk '1; END {print "'$1' '$2'"}' /etc/hosts > tmp && sudo mv tmp /etc/hosts
@ascalabro
ascalabro / tailmysqllog
Created January 19, 2016 18:01
tail the MySQL log in Linux
#!/bin/sh -e
#
echo "*****************************************************"
echo "Default usage runs this command:"
echo " sudo tail -f /var/log/mysql/mysql.log"
echo "Optional usage: $0 ### --- Show last ### of lines"
echo "Optional usage will run this command instead: "
echo " sudo tail --lines=### /var/log/mysql/mysql.log | more"
echo "*****************************************************"
@ascalabro
ascalabro / hunter.sh
Created January 19, 2016 18:00
search thru directory and record the large files to text file
#! /bin/bash
sudo du -ah /var | sort -n -r | head -n 50 > largeFiles.txt
cat largeFiles.txt
@ascalabro
ascalabro / post-receive
Created February 6, 2015 18:14
post-receive hook for bare repo, pushes files to web root, then backs up the web root
#!/bin/bash
set -e
SITENAME="mywebsite.com"
echo "Received commit at" $HOSTNAME
echo "executing post-receive hook"
GIT_WORK_TREE=/var/www/${SITENAME}/public_html git checkout -f
LATESTREV=$(cat refs/heads/master)
echo "latest revision $LATESTREV"
DIRECTORY="/var/www/backups/${SITENAME}/"
if [ ! -d $DIRECTORY ]; then
@ascalabro
ascalabro / conw.bat
Created September 29, 2014 01:47
Quickly change Windows internet connection from wireless interface to ethernet interface and vice versa.
@echo off
:: Usages
:: >conw w #switch to wireless interface
:: >conw e #switch to ethernet interface
IF %1% == e (
echo Switching to Ethernet
netsh interface set interface name="Local Area Connection" admin=enabled
netsh interface set interface name="Wireless Network Connection" admin=disabled
GOTO :DONE
)