Skip to content

Instantly share code, notes, and snippets.

View fracasula's full-sized avatar
🏋️‍♂️
One pomodoro after another

Francesco Casula fracasula

🏋️‍♂️
One pomodoro after another
View GitHub Profile
@fracasula
fracasula / AcmeBundlenameExtension.php
Last active December 22, 2015 15:28
Symfony2 Bundle basic parameters configuration tree (config.yml)
<?php
namespace Acme\Bundle\Bundlename\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
/**
@fracasula
fracasula / Curl.php
Created August 14, 2013 15:08
Basic curl class
<?php
class Curl
{
const HTTP_OK = 200;
const HTTP_NOT_FOUND = 404;
const HTTP_INTERNAL_SERVER_ERROR = 500;
const TEXT_HTML = 'text/html';
const TEXT_PLAIN = 'text/plain';
@fracasula
fracasula / ajaxRouter.js
Last active December 20, 2015 18:39
Ajax Router
;(function (w, $, undefined) {
"use strict";
w.ajaxRouter = function (event, url) {
if (event.ctrlKey)
return true; // CTRL+CLICK opens link in new tab -> no ajax, default behaviour
else {
var url = url || $(this).attr('href'),
matches = /^http[s]?\:\/\/([^/]+)/.exec(url);
@fracasula
fracasula / getMp3StreamTitle.php
Last active September 7, 2025 21:45
How to get the MP3 metadata (StreamTitle) from a streaming URL
<?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';