Skip to content

Instantly share code, notes, and snippets.

cereal-s / curl_get_headers.php
Created Jan 20, 2014
Simple snippet, used to check the redirects of the links. Requires cURL.
View curl_get_headers.php
$url = false;
$url = $_POST['url'];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
cereal-s / php_get_header.php
Created Jan 20, 2014
Simple snippet, used to get the headers from link and his redirects. Requires PHP 5.1.3 and above.
View php_get_header.php
$url = false;
$url = $_POST['url'];
stream_context_set_default(array('http' => array('method' => 'HEAD')));
$headers = get_headers($url, 0);
cereal-s / dtime.php
Last active Jan 4, 2016
Format localized dates. Requires at least PHP 5.3.0 and the Intl library, the latter can be installed from cli: sudo apt-get install php5-intl
View dtime.php
class Dtime extends IntlDateFormatter
private $date;
public function __construct($datetime = '', $pattern = 'd MMMM yyyy HH:mm', $locale = 'it')
parent::__construct($locale, IntlDateFormatter::FULL, IntlDateFormatter::FULL);
View ajax-filter.php
# AJAX filter for Laravel 4.2
# this goes in app/start/global.php
Route::filter('ajax', function($route, $request) {
if ($request->ajax() === FALSE)
return App::abort(500);
View appify
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF
appify v3.0.1 for Mac OS X -
Creates the simplest possible Mac app from a shell script.
Appify takes a shell script as its first argument:
`basename "$0"`
cereal-s /
Created May 14, 2016 — forked from Daniel15/
Complete Google Drive File Picker example

Google Drive File Picker Example

This is an example of how to use the Google Drive file picker and Google Drive API to retrieve files from Google Drive using pure JavaScript. At the time of writing (14th July 2013), Google have good examples for using these two APIs separately, but no documentation on using them together.

Note that this is just sample code, designed to be concise to demonstrate the API. In a production environment, you should include more error handling.

See a demo at

cereal-s / helper.route.php
Last active Aug 23, 2016
_route() function for SlimPHP 3.4.2, it returns the path for the named route
View helper.route.php
if( ! function_exists('_route'))
* Return the path for the named route
* @see
* @param string $name
* @param array $parameters
cereal-s / crawler-edit.php
Created Sep 6, 2016 — forked from jakzal/crawler-edit.php
Removing nodes with DomCrawler
View crawler-edit.php
- "symfony/dom-crawler: ~2.3"
- "symfony/css-selector: ~2.3"
use Symfony\Component\DomCrawler\Crawler;
$html = <<<HTML
View sqlite.strstr.sql
-- return the domain name
SELECT SUBSTR('my@email.tld'
, INSTR('my@email.tld', '@') + 1
, LENGTH('my@email.tld') - INSTR('my@email.tld', '@'));
View sublime-settings-osx.json
"characters": "<",
"selector": "text.html"
"characters": ".",
"selector": "source.js"