Skip to content

Instantly share code, notes, and snippets.

@trigfa
trigfa / BBC-Radio-HLS-UK.m3u
Created June 2, 2022 11:23 — forked from bpsib/BBC-Radio-HLS.m3u
BBC Radio Streams
#EXTM3U
#EXTINF:-1,BBC - Radio 1
http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_med/ak/bbc_radio_one.m3u8
#EXTINF:-1,BBC - Radio 1Xtra
http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_med/ak/bbc_1xtra.m3u8
#EXTINF:-1,BBC - Radio 1Dance
http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_med/ak/bbc_radio_one_dance.m3u8
#EXTINF:-1,BBC - Radio 1Relax
http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_med/ak/bbc_radio_one_relax.m3u8
#EXTINF:-1,BBC - Radio 2
@trigfa
trigfa / setSystemPython.sh
Created April 1, 2017 16:06
In order to over ride anaconda python and replace temporarily with the system python, open a bash terminal and type:
export PATH="/usr/local/bin/:$PATH"
@trigfa
trigfa / pySQL.py
Created March 9, 2017 14:32
Connecting to an MS SQL database using pyodbc
import pyodbc
import pandas as pd
#DDefine our connection parameters
con = pyodbc.connect(   
r'DRIVER={SQL Server};'   
r'server=server_address;'   
r'database=database_name;'   
r'uid=user_name;'   
@trigfa
trigfa / gist:3bece15821bf7f008e78f9eac062e229
Created April 27, 2016 16:27
Searching for text in a file with context (2 lines before and after) and piping output to a file
grep -A 2 --after-context=2 --before-context=2 "Text we're searching for" input_file.txt >> output_file.txt
@trigfa
trigfa / gist:c47f7e3dbfddf95657d8
Created February 21, 2016 15:18
Replacing a string including a space and slashes using sed.
sed -i -- "s|/usr/bin/env python|/usr/bin/python|g" *.py
@trigfa
trigfa / spr.py
Created December 28, 2015 17:17
Spencer Attix stopping power ratios
def stoppingPowerRatio(R50D,z):
"""Given the beam quality R50,D calculates the Spencer Attix stopping power ratios at depth, z, using
the fit by Burns et al given in the 2003 IPEM code of practice for electron dosimetry.
This fit is valid for for beam qualities R50,D in the range 1-20 cm of water and for depths of 0.02 to
1.2 times R50,D"""
a = 1.075
b = -0.5087
@trigfa
trigfa / gist:8f0b45d6f71fa3956ff5
Created December 4, 2015 09:16
Hide input cells and prompts in Jupyter notebook. Useful if using RISE for slideshow
%%HTML
<script>
var code_show=true; //true -> hide code at first
function code_toggle() {
$('div.prompt').hide(); // always hide prompt
if (code_show){
$('div.input').hide();
} else {
import numpy as np
from math import pi, log
import pylab
from scipy import fft, ifft
from scipy.optimize import curve_fit
i = 10000
x = np.linspace(0, 3.5 * pi, i)
y = (0.3*np.sin(x) + np.sin(1.3 * x) + 0.9 * np.sin(4.2 * x) + 0.06 *
np.random.randn(i))
{%- extends 'html_full.tpl' -%}
{% block input_group -%}
<div class="input_hidden">
{{ super() }}
</div>
{% endblock input_group %}
{%- block header -%}
{{ super() }}
@trigfa
trigfa / .bashrc
Last active January 3, 2016 18:59
some useful aliases for ipython and ruby
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
alias designer='designer -qt=4'
alias python='python2'
alias ipython='ipython2'