Skip to content

Instantly share code, notes, and snippets.

View scottrobertson's full-sized avatar

Scott Robertson scottrobertson

View GitHub Profile
<?php
$value1 = 0.0116;
$value2 = 0.01158;
echo $value1 - $value2; // 1.9999999999999E-5

This is an example command for Backtick. A Backtick command consists of some executable JavaScript and a bit of metadata in JSON.

Here are the required steps to create a command:

  1. Create a new Gist with a command.js and command.json file, or simply fork this one.

  2. Write your JavaScript in command.js. This will be injected into and executed on the page the user is currently on when they run it.

  3. Add some metadata to the command.json file:

  • name: The name of the command.
  • The file is hosted on a remote server, the user cannot know this URL.
  • Need to perform validation on the URL in PHP
  • File needs to be served without downloading to PHP and serving again (they can be ~1gb files)
  • Right now, its served via secure_link in Nginx, but i need to be able to do more checks on the download links.
@scottrobertson
scottrobertson / .criterion.yml
Created December 25, 2013 09:17
Example of upcoming Criterion config file.
services:
composer:
dev: true
method: install
phpunit:
config : phpunit.xml.dist
hooks:
post:
url: http://requestb.in/1jmdmqh1
@scottrobertson
scottrobertson / sublime.json
Created November 28, 2013 13:35
My Sublime Settings
{
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"trim_trailing_white_space_on_save": true
}
function switch_php {
NEW_VERSION="php$1"
EXISTS=`brew info $NEW_VERSION >> /dev/null 2>&1`
if [ ! $? -eq 0 ]
then
echo "PHP Version does not exist"
return 1
fi
@scottrobertson
scottrobertson / nexus5_released.php
Created October 18, 2013 12:34
Really simple, and hacky PHP Script to check if Nexus 5 has been released.
<?php
$url = 'https://play.google.com/store/devices/details?id=nexus_5_32gb';
while(true) {
$time = date('h:i:s');
$contents = @file_get_contents($url);
$size = strlen($contents);
file_put_contents('/tmp/nexus.txt', $size);
$old_size = @file_get_contents('/tmp/nexus.txt');
@scottrobertson
scottrobertson / git.sh
Created October 18, 2013 09:01
Fix slow autocomplete when running "git checkout". Add to .zshrc file.
__git_files () {
_wanted files expl 'local files' _files
}
@scottrobertson
scottrobertson / case.js
Created September 10, 2013 08:08
Random idea for text case management on text fields.
$('[data-case]').on('change', function () {
var field = $(this);
var case = field.data('case');
if (case === 'upper') {
var newVal = field.val().toUpper();
} else {
var newVal = field.val().toLower();
}
@scottrobertson
scottrobertson / gist.sh
Created August 29, 2013 14:59
Quick gist bash function
function g {
if [ -f $1 ];
then
GIST=$(gist $1)
else
GIST=$(gist <<< $1)
fi
echo $GIST | pbcopy