Skip to content

Instantly share code, notes, and snippets.

View mohamagdy's full-sized avatar
🥖
Baking and feeding my sourdough

Mohamed Magdy mohamagdy

🥖
Baking and feeding my sourdough
  • Smartfrog & Canary
  • Berlin, Germany
View GitHub Profile
@mohamagdy
mohamagdy / aerospike_counter_benchmark.rb
Last active April 19, 2016 15:40
Aerospike vs MySQL Percona Benchmark
#!/usr/bin/env ruby
require 'time'
require 'thread'
require 'optparse'
require 'rubygems'
require 'aerospike'
include Aerospike
devices.each do |device_data|
device = Device.create!(name: device_data[:name], platform: device_data[:platform], audio: device_data[:audio], bluetooth: device_data[:bluetooth])
device_data[:countries].each do |country|
device.availabilities << Availability.create!(
pinplus: device_data[:pinplus],
chipsig: device_data[:chipsig],
country: Country.find_by_code(country)
)
end
class AvaiableCountry < ActiveRecord::Base
has_many :device_compatibilities
end
class device_compatibility < ActiveRecord::Base
belongs_to :available_country
end
@mohamagdy
mohamagdy / gist:fea0a091af66d850bc3c
Last active August 29, 2015 14:02
Removed Params
{
"id": ...,
"customer_email": ...,
"customer_mobile_phone": ...,
"paid_out_at": ...,
"merchant_id": ...,
"total_fee": ...,
"tax_enabled": ...,
"emv_data": ...,
"product_summary": ...
@mohamagdy
mohamagdy / gist:ac5d964444cfa4cca330
Last active August 29, 2015 14:02
Old JSON Response
{
"amount": 1.5,
"branding": {},
"card": {
"card_type": "cc",
"last_4_digits": "5384",
"masked_number": "**** **** **** 5384",
"scheme": "VISA",
"scheme_keyword": "VISA"
},
@mohamagdy
mohamagdy / gist:bb3d873ecf50d186af4a
Last active August 29, 2015 14:02
New JSON Response
{
"amount": 1.5,
"card": {
"card_type": "cc",
"last_4_digits": "0000",
"masked_number": "**** **** **** 0000",
"scheme": "VISA",
"scheme_keyword": "VISA"
},
"currency": "BRL",
@mohamagdy
mohamagdy / gist:adea58e4d799157007da
Created June 11, 2014 17:36
JSON transaction response for receipts/invoices
{
"amount": 1.5,
"card": {
"card_type": "cc",
"last_4_digits": "0000",
"masked_number": "**** **** **** 0000",
"scheme": "VISA",
"scheme_keyword": "VISA"
},
"currency": "BRL",
#!/usr/bin/env ruby
require 'rubygems'
require 'gmail'
require 'rails'
# Sets the log path
Rails.logger = Logger.new File.expand_path('../../log/fetcher.log', __FILE__)
# Makes sure the cron is set
Rails.logger.info("Gmail fetcher initialized at #{Time.now}.")
module ContentfulAPI
class Sync
def self.sync(access_token)
# Send HTTP call to Contentful API with the given access_token
# Contentful will response with a JSON array
response.inject([]) do |memo, response_item|
memo << self.parse(response_item); memo
end
end
function NameSpace = function() {
var fun = function() {
}
}
NameSpace.fun()