Skip to content

Instantly share code, notes, and snippets.

@davesherratt
davesherratt / gist:1408695
Created November 30, 2011 11:04
mysql radius
select asciiname,latitude,longitude, acos(SIN( PI()* 40.7383040 /180 )*SIN( PI()*latitude/180 )
)+(cos(PI()* 40.7383040 /180)*COS( PI()*latitude/180) *COS(PI()*longitude/180-PI()* -73.99319 /180)
)* 3963.191 AS distance
FROM allcountries
WHERE 1=1
AND 3963.191 * ACOS( (SIN(PI()* 40.7383040 /180)*SIN(PI() * latitude/180)) +
(COS(PI()* 40.7383040 /180)*cos(PI()*latitude/180)*COS(PI() * longitude/180-PI()* -73.99319 /180))
) < = 1.5
ORDER BY 3963.191 * ACOS(
(SIN(PI()* 40.7383040 /180)*SIN(PI()*latitude/180)) +
@davesherratt
davesherratt / app.js
Created July 24, 2012 23:15 — forked from joemaffia/app.js
foursquare OAuth in Titanium
/**
*
*
* Copyright 2011 Aaron K. Saunders, Clearly Innovative Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>
@davesherratt
davesherratt / app.js
Created July 24, 2012 23:18 — forked from aaronksaunders/app.js
LinkenIn IOS Javascript Module for Use with Appcelerator
/*
This is a minified javascript module because I have not had a chance to refactor and
clean up the horrible hacks I have done to make this work, and I don't want to expose
the code and then spend alot of time responding to issues and/or questions.
This code is released AS IS and I will clean it up, document it better and eventually
re-release it as a module or open source
*/
Ti.include('linkedin_module-min.js');
@davesherratt
davesherratt / etc_init.d_unicorn_example.co.uk
Created September 2, 2012 21:13 — forked from rubysolo/etc_init.d_unicorn_example.co.uk
Ruby on Rails server setup on Ubuntu 11.04 with Nginx, Unicorn, Rbenv
#! /bin/bash
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the unicorn web server
# Description: starts unicorn
@davesherratt
davesherratt / gist:3799434
Created September 28, 2012 12:07
Centos 6.3 - Nginx ruby 1.9.3 rails unicorn
yum -y update
yum -y install emacs readline-devel ncurses-devel libevent-devel glib2-devel libjpeg-devel freetype-devel bzip2 bzip2-devel bzip2-libs openssl-devel pcre pcre-devel gpg make gcc yum-utils unzip
yum grouplist |grep -i Development
rpm -ihv http://centos.alt.ru/repository/centos/6/x86_64/centalt-release-6-1.noarch.rpm
rpm -Uvh http://mirrors.ukfast.co.uk/sites/dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm
def upload
ajax_upload = params[:qqfile].is_a?(String) # either a file name (set) or a file (NOT SET, but qqFileUploader allows for it)
filename = ajax_upload ? params[:qqfile] : params[:qqfile].original_filename
if ajax_upload
csv_source = request.body.read
else
csv_source = params[:qqfile].read
end
tmp_file = "#{Rails.root}/data/tmp-#{cookies[:remember_token]}.csv"
csv_valid = false
class PromotionsController < ApplicationController
require 'barby/barcode/ean_8'
require 'barby/barcode/ean_13'
require 'csv'
require 'nokogiri'
require 'cgi'
require 'json'
require 'builder/xchar'
set var %a
on *:text:!ring *:#: {
if ( $nick ison #fang.priv) { %a = $2- }
if (+* iswm %a) { /ring %a }
else { /msg #fang.priv 9looking up number for %a
/msg angelica .phone show %a }
}
on *:TEXT:*valid*:?: {
This file has been truncated, but you can view the full file.
'use strict';
var COMPILED = !0, goog = goog || {};
goog.global = this;
goog.DEBUG = !1;
goog.LOCALE = "en";
goog.provide = function (a) {
if (!COMPILED) {
if (goog.isProvided_(a))
throw Error('Namespace "' + a + '" already declared.');
delete goog.implicitNamespaces_[a];
#!/bin/sh
SCP_USER='user'
SCP_HOST='host'
SCP_PASS='pass'
SCP_PATH='/path/to/file'
HTTP_URL="http://url"
FILENAME=`(cat /dev/random|head -c 10; date) | md5 -q | head -c 10`.png