Skip to content

Instantly share code, notes, and snippets.

<?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);
});
@cereal-s
cereal-s / appify
Last active August 29, 2015 14:21 — forked from mathiasbynens/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 / 1_README.md
Created May 14, 2016 13:40 — forked from Daniel15/1_README.md
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 http://stuff.dan.cx/js/filepicker/google/

@cereal-s
cereal-s / crawler-edit.php
Created September 6, 2016 14:54 — forked from jakzal/crawler-edit.php
Removing nodes with DomCrawler
<?php
<<<CONFIG
packages:
- "symfony/dom-crawler: ~2.3"
- "symfony/css-selector: ~2.3"
CONFIG;
use Symfony\Component\DomCrawler\Crawler;
$html = <<<HTML
@cereal-s
cereal-s / sublime-settings-osx.json
Created November 21, 2016 11:45 — forked from arvi/sublime-settings-osx.json
Sublime Settings OSX
{
"auto_complete_triggers":
[
{
"characters": "<",
"selector": "text.html"
},
{
"characters": ".",
"selector": "source.js"
@cereal-s
cereal-s / gist:4346df99d116786a3b54036b2e84a728
Created November 25, 2016 16:00 — forked from abesto/gist:3476594
Go: Newton's method for square root
/*
A Tour of Go: page 44
http://tour.golang.org/#44
Exercise: Loops and Functions
As a simple way to play with functions and loops, implement the square root function using Newton's method.
In this case, Newton's method is to approximate Sqrt(x) by picking a starting point z and then repeating: z - (z*z - x) / (2 * z)
@cereal-s
cereal-s / exercise.tour.go
Created November 27, 2016 22:33 — forked from zyxar/exercise.tour.go
tour.golang exercise solutions
/* Exercise: Loops and Functions #43 */
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := float64(2.)
@cereal-s
cereal-s / index.html
Created September 7, 2017 09:32 — forked from karbassi/index.html
How to handle single and double click events separately in javascript.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Single and Double Click</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="the_div"></div>
<span>Double click the block</span>
<?php
/**
* Trait helps to allow for some limited overloading of
* methods in the class this is attached to.
*/
trait Overloader {
/**
* Where the magic happens
@cereal-s
cereal-s / 00. tutorial.md
Created October 2, 2017 17:02 — forked from maxivak/00. tutorial.md
Importing/Indexing database (MySQL or SQL Server) in Solr using Data Import Handler