Skip to content

Instantly share code, notes, and snippets.

View rinaldifonseca's full-sized avatar

Rinaldi Fonseca rinaldifonseca

View GitHub Profile
@rinaldifonseca
rinaldifonseca / PaperclipStringFile
Created May 4, 2018 03:54 — forked from bendangelo/PaperclipStringFile
Paperclip string to file
module Paperclip
#converts a string into a file for paperclip to save
# useage
# self.avatar = Paperclip::string_to_file('bob.png', 'image/png', 'BASE64 here')
def self.string_to_file(name, type, data)
image = StringIO.new(data)
image.class.class_eval { attr_accessor :original_filename, :content_type }
image.original_filename = name
image.content_type = type
@rinaldifonseca
rinaldifonseca / deploy.rb
Created January 8, 2018 17:31 — forked from cannikin/deploy.rb
Notify Sentry of a new release via Capistrano
# This task will notify Sentry via their API[1] that you have deployed
# a new release. It uses the release timestamp as the `version`
# (like 20151113182847) and the git ref as the optional `ref` value.
#
# This task requires several environment variables be set (or just
# hardcode the values in here if you like living on the edge):
#
# ENV['SENTRY_API_ENDPOINT'] : API endpoint, https://app.getsentry.com
# ENV['SENTRY_ORG'] : the organization for this app
# ENV['SENTRY_PROJECT'] : the project for this app
FLCNBYGG-W4BMMPTX-QVOCMG4S-EG5CWUPH-BYMM6QKU-DI7HT4D2-GAWAEFBU-5PQPK3U6-KTLAYUKP-HEYE2CZA-B5L4DMQC-CRGQJKG5-AABZGREJ-LIEAPOBV-5LQ2HGOY-OUGQKQIP
module PayPal::SDK
module REST
module DataTypes
Payer.class_eval do
object_of :merchant_id, String
end
class ChargeModel < Base
object_of :id, String
object_of :type, String
package com.trailbehind.downloads;
import android.util.Log;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.GetObjectMetadataRequest;
import com.amazonaws.services.s3.model.GetObjectRequest;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.S3Object;
import com.crashlytics.android.Crashlytics;
package com.memtrip;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.graphics.Bitmap;
@rinaldifonseca
rinaldifonseca / flush.rb
Created April 21, 2015 02:26
redis-flushall
port = 6379
$redis = Redis.new(:port => port)
$redis.flushall
# ListRecurringDetailsResponse#details
def details
mapped_attributes = {
:recurring_detail_reference => "recurringDetailReference",
:creation_date => "creationDate",
:variant => "variant",
:card_holder_name => "card.holderName",
:card_expiry_month => "card.expiryMonth",
:card_expiry_year => "card.expiryYear",
require 'net/ftp'
CONTENT_SERVER_DOMAIN_NAME = "one-of-the-ftp-server.thought-sauce.com.hk"
CONTENT_SERVER_FTP_LOGIN = "saucy-ftp-server-login"
CONTENT_SERVER_FTP_PASSWORD = "saucy-ftp-server-password"
# LOGIN and LIST available files at default home directory
Net::FTP.open(CONTENT_SERVER_DOMAIN_NAME, CONTENT_SERVER_FTP_LOGIN, CONTENT_SERVER_FTP_PASSWORD) do |ftp|
files = ftp.list
@rinaldifonseca
rinaldifonseca / publisher.rb
Created September 30, 2014 20:55
Publisher
#Version 1
class Publisher
def initialize(page)
@page = page
end
def publish
# do things that publish @page
end
end