Skip to content

Instantly share code, notes, and snippets.

View Rio517's full-sized avatar

Mario Olivio Flores Rio517

View GitHub Profile
@Rio517
Rio517 / api-sample-doc.json
Last active August 29, 2015 14:14
api-sample-doc
{
"swagger": "2.0",
"info": {
"version": "0.0.1",
"title": "MAYDAY"
},
"paths": {
"/stats": {
"get": {
"description": "returns list of global stats\n",
@Rio517
Rio517 / all-locatoin-map-viz.json
Last active August 29, 2015 14:19
Fake map viz
[{
"map_key": "SD-JUNIOR",
"coordinates": [12, 12],
"legislator": {
"name": "Mike Rounds",
"title": "Senator",
"party": "R",
"support_max": "cosponsored",
"targeted": false,
"image_url": "https://s3.amazonaws.com/audio.mayday.us/congress-photos/99x120/R000605.jpg",
@Rio517
Rio517 / reforms.json
Created June 2, 2015 21:04
Government Reform Data
{
"reforms": [{
"active": true,
"slug": "government-by-the-people-act",
"title": "Government By the People Act",
"reformType": "legislative",
"url": "http://ofby.us",
"parties": ["D"],
"id": 0,
"descriptionShort": "The Government by the People Act is a proposed bill to reform the campaign finance system, introduced into the House by 2014 by John Sarbanes (D-MD). A companion bill, the Fair Elections Now Act, was also introduced into the Senate.\n\nUnder the proposed bill, political contributions of up to $150 would be matched by a factor of six times more than the original donation as long as candidates meet certain requirements. They must not use their own money, not accept donations over $1000, have already received at least $50,000 from 1000 in-state donors, and decline most political action committee money.\n",
#
# Paperclip convert id => id_partition
#
require 'ftools' #FileUtils
class PaperclipExtend
def self.obtain_class
class_name = ENV['CLASS'] || ENV['class']
uploads_path = ENV['UPLOADS_PATH'] || ENV['uploads_path']
raise "Must specify CLASS" unless class_name
@Rio517
Rio517 / file.rb
Created April 15, 2011 03:47
This is from the activo-rails gem
module Activo
module Rails
module Helper
# Displays a breadcrumb trail
#
# options - A hash of attributes to apply to the wrapping div tag
#
# Example:
# <div class="block">
@Rio517
Rio517 / fuzzy matching from
Created April 29, 2011 16:16
fuzzymatch.rb
#http://rcoder.net/content/testing-string-similarity-using-ruby-and-zlib
#see also: http://www.postgresql.org/docs/8.3/static/fuzzystrmatch.html
#see also: http://flori.github.com/amatch/
require 'zlib'
# this is optimized to store a relatively smaller subset of common index
# terms against which new strings should be tested
class ZlibDistanceCalc
def initialize
@Rio517
Rio517 / elasticsearch.yml
Created September 28, 2011 17:22
elasticsearch configuration fail
#/usr/local/elasticsearch/elasticsearch-0.17.7/logger.yml/elasticsearch.yml
# The cluster name
cluster.name: traceful_elasticsearch
cloud:
aws:
access_key: AKIAIPILOGJA7ORIBDNQ
secret_key: sdyXUTxPqDTL7vr2axB7Ufa1ikFqmAR+J63FgYAJ
@Rio517
Rio517 / show.html.erb
Created October 17, 2011 01:27
Stripe.com api feedback example
<% count = 1 %>
<% if @invoice.lines.subscriptions.any? %>
<% @invoice.lines.subscriptions.each do |subscription| -%>
<tr class="<%= count % 2 == 0 ? 'even' : 'odd' %>">
<td class="first"><%= format_unix_time(subscription.period.end) %></td>
<td><%= subscription.plan.name %> subscription from <%= format_unix_time(subscription.period.start) %> to <%= format_unix_time(subscription.period.end) %></td>
<td><%= number_to_currency(subscription.amount/100) %></td>
</tr>
<% count += 1 %>
<% end %>
@Rio517
Rio517 / fix_salsa.html
Created January 12, 2012 01:14
Fix SalsaLabs.com problems with CRM embeds. Click view source, then copy and paste this into your page before adding content.
<style>
.contentWrap{float:left;width:630px;}
.formRow{float:right;position:releative;}
.wrapper.site_wrapper .salsa FORM .supporterInfo{float:right;margin:0;padding:0 0 0 30px;position:relative;height:auto;top:-40px !important}
.wrapper.site_wrapper .salsa FORM .supporterInfo SELECT{padding:8px;width:203px;}
.formRow INPUT.blockInput{padding:8px;}
.wrapper.site_wrapper .salsa FORM{position:relative;overflow:hidden;}
@Rio517
Rio517 / example-post-ajax-through-iframe.html
Last active October 4, 2015 21:47
Example: Submit post requests across domains using an intermediary targeted Iframe.
<form action="http://anotherdomain/save" method="post" target="myiframe" id="myform">
<!-- standard form here -->
</form>
<iframe src="about:blank" name="myiframe" style="display: none;"></iframe>
<!-- Then, javascript something like: -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script>