Skip to content

Instantly share code, notes, and snippets.

@leighmcculloch
leighmcculloch / README.md
Last active June 20, 2025 12:41
Example using a @stellar/stellar-sdk contract client

Example using a @stellar/stellar-sdk contract client

Uses the NPM @stellar/stellar-sdk package, and demonstrates using a contract client to call a function.

Uses the Deno Runtime for JavaScript.

Usage

With Deno:

/**
* Calculates the date of Easter Sunday for a given year using the Anonymous Gregorian algorithm.
* See https://en.wikipedia.org/wiki/Computus#Anonymous_Gregorian_algorithm
*
* @param year The year for which to calculate Easter.
* @returns A Date object representing Easter Sunday for that year.
*/
function getEaster(year: number): Date {
if (year < 1583) {
throw new Error("Algorithm is valid only for Gregorian calendar years (1583 onwards).");

Keybase proof

I hereby claim:

  • I am leighmcculloch on github.
  • I am stellarleigh (https://keybase.io/stellarleigh) on keybase.
  • I have a public key ASBQlejmudPGBeI2rqiqk9nuAdn5ksS_COmOJjN9Q8VSAgo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am leighmcculloch on github.
  • I am leighmcculloch (https://keybase.io/leighmcculloch) on keybase.
  • I have a public key ASDPQilNNnhp30sKWE6cXdrSsoarlm56Gy44ORVW82ntFgo

To claim this, I am signing this object:

@leighmcculloch
leighmcculloch / minimal-arq-aws-policy.json
Created December 24, 2017 22:02
Minimal AWS IAM policy for ARQ.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "0",
"Effect": "Allow",
"Action": ["s3:ListAllMyBuckets", "s3:ListObjects"],
"Resource": "*"
},
{
@leighmcculloch
leighmcculloch / mfa-delete-execute.rb
Created November 7, 2015 17:31
A simple tool that will help you delete files on buckets with MFA Delete feature enabled.
#!/usr/bin/env ruby
require 'aws-sdk'
print "AWS Account ID: "
aws_account_id = STDIN.gets.chomp
print "S3 bucket name: "
bucket_name = STDIN.gets.chomp
print "AWS Access Key ID: "
aws_id = STDIN.gets.chomp
print "AWS Access Secret Key: "
@leighmcculloch
leighmcculloch / mfa-delete-enable.rb
Last active November 7, 2015 17:29 — forked from petethepig/mfa-delete.rb
A simple tool that will help you enable MFA Delete feature on your S3 bucket
#!/usr/bin/env ruby
require 'aws-sdk-v1'
print "S3 bucket name: "
bucket_name = STDIN.gets.chomp
print "AWS Access Key ID: "
aws_id = STDIN.gets.chomp
print "AWS Access Secret Key: "
aws_key = STDIN.gets.chomp
print "AWS Root MFA Serial: "
@leighmcculloch
leighmcculloch / mdig.rb
Created August 20, 2014 18:22
Multi-Region DNS Lookup Utility
# Multi-Region DNS NameServer Propogation Check
#
# Uses the dns-lg.com API to retrieve the NS records for a zone (domain name)
# at 19 (more or less) different locations globally. Use this to monitor the
# propogation of nameserver changes at your registrar.
#
# Note: There is no such thing as a guarantee when it comes to whether your
# new nameservers have propogated fully or not. Rule of thumb is three days
# but often it is much faster and this check can help you weigh the risks.
@leighmcculloch
leighmcculloch / Android Screenshot.bat
Created December 5, 2013 10:22
This batch script will take a screenshot on an Android device using ADB, download the screenshot to the directory this script to the current directory and then remove the screenshot file from the device. Screenshots are saved with filename: screenshot-YYYYMMDD-HHMMSS.png. ADB must be connected to a device already.
@echo off
rem configurable parameters
set SCREENCAP_FILE_PREFIX=screenshot
rem the dir on the device where the screenshot will be stored temporarily
set SCREENCAP_WORKING_DIR=/sdcard/
rem adb path, leave blank if adb is already on the user or system path
set SCREENCAP_ADB_PATH=
@leighmcculloch
leighmcculloch / NSData+HexString.h
Last active December 29, 2015 05:39
A category for NSData that returns a hex string of the data within. Output is like: af459a2f
//
// NSData+HexString.h
//
// Copyright (c) 2013, Leigh McCulloch. All rights reserved.
// BSD-2-Clause License: http://opensource.org/licenses/BSD-2-Clause
//
#import <Foundation/Foundation.h>
@interface NSData (HexString)