Skip to content

Instantly share code, notes, and snippets.

@siong1987
siong1987 / Dockerfile
Created July 3, 2023 13:11
Dockerfile to build 0.28.0 anchor with 1.14.18 solana.
#
# Docker image to generate deterministic, verifiable builds of Anchor programs.
# This must be run *after* a given ANCHOR_CLI version is published and a git tag
# is released on GitHub.
#
FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive
@siong1987
siong1987 / TPSMonitor.tsx
Created April 29, 2022 15:09
Solana TPS Tracking
import React, { useEffect, useState } from 'react';
import { Connection, PerfSample } from '@solana/web3.js';
import { useAppConfig, useConnection } from '@shared/components-ui/contexts';
import { Trans } from '@lingui/macro';
const WarningIcon = () => {
return (
<svg width="20" height="20" viewBox="0 0 20 21" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
fillRule="evenodd"
@siong1987
siong1987 / mrr.rb
Created October 24, 2014 18:31
Stripe MRR Calculation
require 'stripe'
require 'ostruct'
# modified from: https://gist.github.com/jacobpatton/a68d228bf2414852d862
#
# puts Stripe::Mrr.new(api_key: 'api_key').mrr
#
module Stripe
class Mrr
attr_reader :api_key
# OS X install instructions http://www.reddit.com/r/linux/comments/a3snu/pianobar_is_a_command_line_client_for_pandora_no/c0fupws
brew install libao
# brew install libfaad2 # not available with brew, skipped and is working ok...
brew install libmad
brew install cmake # (this takes a while)
# install
git clone git://github.com/PromyLOPh/pianobar.git
cd pianobar
class Calculator
def evaluate statement
symbols = statement.split(' ')
puts calculate(symbols)
end
def calculate symbols
if symbols.length == 1
return symbols[0]
else
@siong1987
siong1987 / RestKit.podspec
Created December 17, 2012 09:01
pod spec for Restkit that enables array.
Pod::Spec.new do |s|
s.name = 'RestKit'
s.version = '0.10.3'
s.summary = 'RestKit is a framework for consuming and modeling RESTful web resources on iOS and OS X.'
s.homepage = 'http://www.restkit.org'
s.author = { 'Blake Watters' => 'blakewatters@gmail.com' }
s.source = { :git => 'https://github.com/siong1987/RestKit.git', :tag => 'v0.10.4' }
s.license = 'Apache License, Version 2.0'
s.source_files = 'Code/RestKit.h'
func personName(firstName: String, lastName: String?) -> String {
guard let lastName = lastName else {
return "\(firstName)"
}
return "\(firstName) \(lastName)"
}
personName("Siong", lastName: "Ong") // prints "Siong Ong"
personName("Siong", lastName: nil) // prints "Siong"
require 'benchmark'
require 'yab62'
def generate_token(length)
(1..length).collect { (i = Kernel.rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr }.join
end
def generate_mod_token(length)
(rand(62**length)).encode62.rjust(length,rand(62).encode62)
end
@siong1987
siong1987 / forkbin.routes.js.coffee
Created September 22, 2012 22:16
sample routes for forkbin
$(document).ready ->
routes =
"":
"NavbarRouter": "index"
"ListsRouter": "index"
"lists/:id":
"NavbarRouter": "index"
"ListsRouter": "show"
@siong1987
siong1987 / db_copy.rake
Created July 29, 2012 08:38
copy db from mongo
namespace :db do
namespace :copy do
def get_mongohq_url(env)
"mongohq_url"
end
def parse_mongodb_url(url)
uri = URI.parse(url)
[ uri, uri.path.gsub("/", "") ]