Skip to content

Instantly share code, notes, and snippets.

View jayshields's full-sized avatar
💻
Working hard!

Jamie Shields jayshields

💻
Working hard!
View GitHub Profile
@jayshields
jayshields / script.js
Last active November 7, 2015 12:46
NatWest online banking print statement fix
document.getElementById('ctl00_secframe').contentWindow.print();
@jayshields
jayshields / index.php
Created November 24, 2015 13:05
Dropbox API output images from directory
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.dropboxapi.com/2/files/list_folder');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer MY_DROPBOX_ACCESS_KEY',
'Content-Type: application/json',
'Accept: application/json'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@jayshields
jayshields / whitelist_access_origin.php
Created August 11, 2016 15:13
Access-Control-Allow-Origin whitelist for Silex
$app->after(function(Request $request, Response $response){
$access_whitelist = array('https://domain1.com', 'https://domain2.com', 'https://domain3.com');
if(in_array($_SERVER['HTTP_ORIGIN'], $access_whitelist))
$response->headers->set('Access-Control-Allow-Origin', $_SERVER['HTTP_ORIGIN']);
});
@jayshields
jayshields / ac_invoices_total_bookmarklet.js
Created September 28, 2016 13:33
Active Collab invoice total bookmarklet
$('[ng-repeat="invoices in grouped_invoices"]').each(function(){
var total = 0;
$(this).find('.invoice_card_amount_number').each(function(){
total += parseInt($(this).text().replace(',','').replace('.00',''));
});
$(this).find('h2.lighter').text($(this).find('h2.lighter').text()+' (£'+total+')');
});
@jayshields
jayshields / mysql-blank-root-password.sh
Last active July 26, 2018 08:48
MySQL 5.7.22 on Ubuntu 18.04 set root password to blank (for local dev only!)
sudo /etc/init.d/mysql stop
sudo mkdir /var/run/mysqld/
sudo chown mysql /var/run/mysqld/
sudo mysqld_safe --skip-grant-tables &
mysql -u root
use mysql;
update user set authentication_string = PASSWORD(""), plugin = "mysql_native_password" where User='root';
flush privileges;
quit;
sudo /etc/init.d/mysql stop
@jayshields
jayshields / playAudioAsBlobViaAjax.js
Created June 14, 2023 11:47 — forked from praveenpuglia/playAudioAsBlobViaAjax.js
Download Audio from AJAX and Play as Blob
var a = fetch("http://path/to/audio.wav")
.then(res => {
var reader = res.body.getReader();
return reader.read().then(result => {
return result;
});
})
.then(data => {
console.log(data);