This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {Storage} = require('@google-cloud/storage') | |
const storage = new Storage(); | |
const bucket = storage.bucket('fe-store'); | |
async function upload() { | |
const largeCustomMeta = () => { | |
let str = ''; | |
for (let i = 0; i < 2.1e6; i++) { | |
str += 'a'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'elasticsearch' | |
require 'pp' | |
index_name = 'test' | |
@client = Elasticsearch::Client.new log: true | |
@client.indices.delete(index: index_name) rescue '' | |
@client.indices.create index: index_name, | |
body: { | |
settings: { | |
analysis: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'faraday' | |
gem 'json' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bson' | |
# Undefine 'next' method which is define by c ext. | |
BSON::ObjectId::Generator.send :undef_method, :next | |
# Redefine next method. | |
module BSON | |
class ObjectId | |
class Generator | |
def next(time = nil) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'moped' | |
class MongoCopier | |
attr_accessor :source_addr, :dest_addr, :db_name | |
attr_reader :source_session, :dest_session | |
def initialize(db_name, addrs = {}) | |
@source_addr = addrs[:source] || 'localhost:27017' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'faraday_middleware' | |
require 'hashie/mash' | |
# Public: GeoIP service using freegeoip.net | |
# | |
# See https://github.com/fiorix/freegeoip#readme | |
# | |
# Examples | |
# | |
# res = GeoipService.new.call '173.194.64.19' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source :rubygems | |
# We are not loading Active Record, nor Active Resources etc. | |
# We can do this in any app by simply replacing the rails gem | |
# by the parts we want to use. | |
gem "actionpack", "~> 3.2" | |
gem "railties", "~> 3.2" | |
gem "tzinfo" | |
# Let's use thin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/local/bin/ruby -w | |
# This simple program takes a bunch of images and creates a sprite image along with the corrosponding | |
# css. It also generates the datauri css. So, we can serve performance optimized CSS depending on the | |
# Browsers. | |
# | |
# Browsers which do not support datauri, like IE7 and below get the sprite image and the sprite css. | |
# Browsers which support datauri, get the datauri.css | |
# | |
# Usage: |