Skip to content

Instantly share code, notes, and snippets.

View patrickarlt's full-sized avatar

Patrick Arlt patrickarlt

View GitHub Profile
cp /usr/local/Cellar/mongodb/1.6.5-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
Then reboot login and
ps -e | grep mongo
nothing
#This method defines a set of rules and a syntax
#to add then then checks all of the rules
def fizzbuzz(num, rules)
output_str=""
rules.each do |hash|
if num.remainder(hash[:number]).zero?
output_str << hash[:inserted_text]
end
@patrickarlt
patrickarlt / app.rb
Created March 4, 2011 04:04
Sinatra Authentication Issue
require 'sinatra'
require 'haml'
require 'digest/sha1'
require 'rack-flash'
require 'mongoid'
require 'sinatra-authentication'
use Rack::Session::Cookie, :secret => 'skey'
use Rack::Flash
---snip
<!--
Product view
-->
<catalog_product_view translate="label">
<label>Catalog Product View (Any)</label>
<!-- Mage_Catalog -->
<reference name="root">
@patrickarlt
patrickarlt / awesome_twitter.php
Created April 12, 2011 16:11
A dead simple wordpress plugin to get your tweets on a wordpress site.
<?php
/*
Plugin Name: Awesome Twitter Plugin
Plugin URI:
Description: Adds a function to grab your latest tweets and caches them in the database.
Author: Patrick Arlt
Version: 0.01
Author URI: http://patrickarlt.com
*/
@patrickarlt
patrickarlt / gist:1045549
Created June 24, 2011 19:58
Error in a form field
<!-- Error in a form field add class error to the field and insert-->
<div class="field error">
<label>
Name
<input name="application[name]" type="text" placeholder="My Cool App" size="20" maxlength="20" value="<%= h @application['name'] %>">
<small> Required. The name of your application.</small>
</label>
<em class="error">This field is required.</em>
</div>
@patrickarlt
patrickarlt / gist:1149804
Created August 16, 2011 18:36
socket.js
var socketio_connect = "http://subscribe.geoloqi.com:80";
var thePath = false;
function start_realtime_streaming() {
// Load up the history of the trip prior to this page loading
$.getJSON("/platform/share/history.json", {
token: share_token
}, function(data){
var historyLine = new google.maps.Polyline({
strokeColor: "#000000",
mapQuest = new L.TileLayer("http://{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png", {
maxZoom: 18,
subdomains: ['otile1','otile2','otile3','otile4']
});
mapBox = new L.TileLayer("http://{s}.tiles.mapbox.com/v3/mapbox.mapbox-streets/{z}/{x}/{y}.png", {
maxZoom: 18,
subdomains: ['a','b','c','d']
});
@patrickarlt
patrickarlt / distance_functions.js
Created May 31, 2012 15:39
Set of functions for determining the distance between 2 lat,lng points
var radiusOfEarth = 6378100.0;
function deg2rad(deg) {
return deg * (Math.PI / 180);
}
function rad2deg(rad) {
return rad * (180 / Math.PI);
}
map.on("popupopen", function(e){
date = new Date(parseint($("#timeago").html()));
$('#timeago').text($.timeago(date));
});