Skip to content

Instantly share code, notes, and snippets.

View mraaroncruz's full-sized avatar
🏃‍♂️

Aaron Cruz mraaroncruz

🏃‍♂️
View GitHub Profile
@andytill
andytill / web.rb
Created November 18, 2012 21:16
A Sinatra proxy to be used over a neo4j ReST API
# web proxy for a neo4j database, using Heroku but could be easily modified for anything else
# this code is a modified version of the code found here https://github.com/akollegger/nosql-now/blob/master/web.rb
# the main changes are...
# - authentication required for modification, although viewing is allowed without authentication (auth can be added by calling protected! in the get method)
# - the domain returned in the data is replaced with the proxy domain instead of being removed which was causing errors in the java jersey library
# - modified post routing, this wasn't catching all POST requests
require 'sinatra'
require 'rest-client'
require 'json'
@pocketkk
pocketkk / Raspberry Pi->Mopidy->Spotify
Last active April 1, 2016 11:31
Raspberry Pi instructions to install Mopidy with Spotify support.
Steps to get Raspberry Pi running with Mopidy and Spotify
1. Raspian Wheezy Installation
2. Install Python tools following these instructions
(had to run most of it as sudo):
http://raspberry.io/wiki/how-to-get-python-on-your-raspberrypi/
3. Install Spotify libspotify
https://developer.spotify.com/technologies/libspotify/#download
4. Install Mopidy following these directions:
http://docs.mopidy.com/en/latest/installation/raspberrypi/
@alunny
alunny / index.html
Created February 25, 2012 00:57
simple PhoneGap File API example
<html>
<body>
<form onsubmit="return saveText()">
<label for="name">Name</label><br>
<input id="name" /><br>
<label for="desc">Description</label><br>
<input id="desc" /><br>
<input type="submit" value="Save" />
@DevL
DevL / generate_sequel_migration.rake
Created December 14, 2012 14:48
Generate a timestamped, empty Sequel migration in the 'migrations' directory.
namespace :generate do
desc 'Generate a timestamped, empty Sequel migration.'
task :migration, :name do |_, args|
if args[:name].nil?
puts 'You must specify a migration name (e.g. rake generate:migration[create_events])!'
exit false
end
content = "Sequel.migration do\n up do\n \n end\n\n down do\n \n end\nend\n"
timestamp = Time.now.to_i
lock '3.5.0'
set :application, 'your-app'
set :repo_url, 'https://github.com/your/app'
set :deploy_to, '/home/deploy/apps/your-app/'
namespace :deploy do
after :updated, :build do
on roles(:web) do
execute "cd '#{release_path}' && shards install"
@maccman
maccman / juggernaut_channels.rb
Created June 26, 2012 04:56
Sinatra Server Side Event streaming with private channels.
# Usage: redis-cli publish message.achannel hello
require 'sinatra'
require 'redis'
conns = Hash.new {|h, k| h[k] = [] }
Thread.abort_on_exception = true
get '/' do
@brigand
brigand / app.js
Last active June 29, 2017 15:52
React JS Event-Emitter Mixin and Example
var React = require("react"), Dom = React.DOM;
var LogOutButton = require('./src/logout');
var events = require('api/events');
var Main = React.createClass({
// this mixin provides this.emitLogout, and if we set onLogout it'll be called when "logout" is emitted
mixins: [events.mixinFor("logout")],
getInitialState: function(){
return {
@alain75007
alain75007 / sidekiq.init.sh
Created May 4, 2013 16:10
sidekiq Launch script on Debian. Change APP "beta" by the environment you want. Important : don't forget to speciy a logfile and a pifile in config/sidekiq.yml of your Rail's app.
#!/bin/bash
### BEGIN INIT INFO
# Provides: sidekiq beta
# Required-Start: $syslog $remote_fs
# Required-Stop: $syslog $remote_fs
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: sidekiq beta - asynchronous rails
@tansengming
tansengming / crawl.rake
Created October 29, 2009 07:57
Rake task to crawl you rails app for broken links
# Use this to look for broken links in your app.
# crawls the development server http://localhost:3000
# Suggestion: Also check to make sure that intentional 404s
# are handled gracefully by app.
task :crawl => :environment do
require 'anemone'
root = 'http://localhost:3000'
options = {:discard_page_bodies => true, :verbose => true}
@sankalpk
sankalpk / image_proxy_controller.rb
Last active December 29, 2017 11:23
Image proxy in Rails
class ImageProxyController
def show
image = open(params[:url]) {|f| f.read }
send_data image, type: "image/jpeg", disposition: 'inline'
end
end