Skip to content

Instantly share code, notes, and snippets.

defmodule StellarBase.StrKey do
@version_types %{<<48>> => :account_id, <<144>> => :seed}
def decode_check(expected_version, byte_string) do
{:ok, decoded} = Base.decode32("SCEJX4WZXWOMP7XYYMDC5XJB3USSPWSV3AI4LSZYYGIGCXZFG522O4HK")
version_byte = String.at(decoded, 0)
{:ok, expected_version} = Map.fetch(@version_types, version_byte)
payload = String.slice(decoded, 1..-2)
expected_check = String.slice(decoded, -2..-1)
@ramontayag
ramontayag / car.rb
Created November 8, 2016 01:32
Dry::Struct - omit value from init hash
class Car < Dry::Struct
attribute :brand_name, Types::String.optional
attribute :model_number, Types::String.optional
end
G-NET
STA_LUCIA_REALTY
TARLAC_CABLE
SUBIC_ENERZONE
NORKIS
CIGNAL
CASHSENSE
BAYANTEL
SORSOGON_WATER
UNISTAR
class TrackingNumberGenerator
include Virtus.model
attribute :size, Integer
attribute :letters, String, lazy: true, default: :default_letters
attribute :numbers, String, lazy: true, default: :default_numbers
attribute :code, String, lazy: true, default: :default_code
DIGITS = %w(2 3 4 7 9)
CONSONANTS = %w(C F G H J K L M N R T V W X Z)
@ramontayag
ramontayag / gist:a8b78a2707c6e28cbced1e2cb21df704
Created August 25, 2016 11:50
Download JCE UnlimitedJCEPolicyJDK7 on CircleCI via wget
dependencies:
pre:
- wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" -O UnlimitedJCEPolicyJDK7.zip http://download.oracle.com/otn-pub/java/jce/7/UnlimitedJCEPolicyJDK7.zip
- sudo mkdir -p $JAVA_HOME/jre/lib/security
- jar xvf UnlimitedJCEPolicyJDK7.zip
- sudo cp UnlimitedJCEPolicy/*.jar $JAVA_HOME/jre/lib/security
redis:
image: redis:3.0.5
expose:
- 6379
volumes:
- redis:/var/lib/redis/data
web:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
@ramontayag
ramontayag / sample.json
Created March 22, 2016 14:01
Sample pages
[
{
"name": "Home",
"body": "<h1>Welcome to our website!</h1><p>Feel free to browse around. Be <img src=\"http://qc.cisv.ph/assets/images/nice.jpg\"/></p>",
"children": [
{
"name": "Child of home page",
"body": "<h1>Welcome to our website!</h1><p>Feel free to browse around. Be <img src=\"http://qc.cisv.ph/assets/images/nice.jpg\"/></p>"
},
{
@ramontayag
ramontayag / run.rb
Last active October 14, 2015 23:49
Get a markdown list of the pull requests merged into master since production's HEAD
#!/usr/bin/env ruby
raise 'I require Ruby 2.0+!' unless RUBY_VERSION[/^2/]
def get_production_remote_name
ENV["PRODUCTION"] || "production"
end
def extract_hashes(production_remote_name:)
command = [
" Many stuff from http://www.drbunsen.org/text-triumvirate.html
" Visual mode unmap
" Bring back the functionality to press shift+e, shift+w, shift+b
" while in visual mode to go to the character right before the next
" whitespace
vunmap E
vunmap W
vunmap B
I, [2014-12-03T07:37:07.706901 #8446] INFO -- : Started GET "/bitsy/v1/blockchain_notifications?secret=XXXXXX" for 127.0.0.1 at 2014-12-03 07:37:07 -0500
I, [2014-12-03T07:37:08.252596 #8446] INFO -- : Processing by Bitsy::V1::BlockchainNotificationsController#index as HTML
I, [2014-12-03T07:37:08.265413 #8446] INFO -- : Parameters: {"secret"=>"XXXXXX"}
I, [2014-12-03T07:37:08.891505 #8446] INFO -- : Rendered text template (0.1ms)
I, [2014-12-03T07:37:08.896902 #8446] INFO -- : Completed 422 Unprocessable Entity in 629ms (Views: 28.1ms | ActiveRecord: 10.8ms)