Skip to content

Instantly share code, notes, and snippets.

View ajax-filter.php
<?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
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF
appify v3.0.1 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a shell script.
Appify takes a shell script as its first argument:
`basename "$0"` my-script.sh
@cereal-s
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
<?php
$url = false;
if($_POST)
{
$url = $_POST['url'];
stream_context_set_default(array('http' => array('method' => 'HEAD')));
$headers = get_headers($url, 0);
@cereal-s
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
<?php
$url = false;
if($_POST)
{
$url = $_POST['url'];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
@cereal-s
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
<?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);
@cereal-s
cereal-s / 1_README.md
Created May 14, 2016 — forked from Daniel15/1_README.md
Complete Google Drive File Picker example
View 1_README.md

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 http://stuff.dan.cx/js/filepicker/google/

@cereal-s
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
<?php
if( ! function_exists('_route'))
{
/**
* Return the path for the named route
*
* @see http://www.slimframework.com/docs/objects/router.html#route-names
* @param string $name
* @param array $parameters
@cereal-s
cereal-s / crawler-edit.php
Created Sep 6, 2016 — forked from jakzal/crawler-edit.php
Removing nodes with DomCrawler
View crawler-edit.php
<?php
<<<CONFIG
packages:
- "symfony/dom-crawler: ~2.3"
- "symfony/css-selector: ~2.3"
CONFIG;
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
{
"auto_complete_triggers":
[
{
"characters": "<",
"selector": "text.html"
},
{
"characters": ".",
"selector": "source.js"