This file contains 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
# Okasaki style Functional Red Black Tree | |
# https://www.cs.tufts.edu/comp/150FP/archive/chris-okasaki/redblack99.pdf | |
# | |
# leaves and root are black | |
# BST | |
# No red node has a red child | |
# Every path from the root to a leaf has the same number of black nodes | |
module RBTree | |
class Leaf |
This file contains 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
# USAGE: | |
# rails runner rails-models-to-typescript-schema.rb > app/javascript/types/schema.d.ts | |
Rails.application.eager_load! | |
models = ActiveRecord::Base.descendants.reject { |i| i.abstract_class? } | |
belongs_to = true | |
has_many = true |
This file contains 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
from aws_cdk import core | |
from aws_cdk.aws_ec2 import Vpc, CfnRouteTable, RouterType, CfnRoute, CfnInternetGateway, CfnVPCGatewayAttachment, \ | |
CfnSubnet, CfnSubnetRouteTableAssociation, CfnSecurityGroup, CfnInstance | |
from . import config | |
class VpcStack(core.Stack): | |
def __init__(self, scope: core.Construct, id: str, **kwargs) -> None: |
This file contains 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
version: 0.2 | |
phases: | |
pre_build: | |
commands: | |
- echo Logging in to Amazon ECR... | |
- aws --version | |
- $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION) | |
- IMAGE_TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7) | |
- REPOSITORY_URI="$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME" |
This file contains 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
def pmap(enum) | |
return to_enum(:pmap, enum) unless block_given? | |
enum.map { |e| Thread.new { yield e } }.map(&:value) | |
end | |
# Returns elements in order, as expected. | |
pmap(1..10) { |e| e } #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
# Returns elements in nondeterministic order on MRI >= 1.9.3. | |
# Works as expected on JRuby, Rubinius, and earlier versions of MRI. |
This file contains 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 'aws-sdk' | |
AWS.config({:access_key_id => "your-access-key-id", | |
:secret_access_key => "your-secrect-access-key", | |
:region => "eu-west-1"}) #region is optional | |
log_uri = "s3n://dynamo-backups/dynamo-backup-resources/logs" #Can be anywhere you like on S3 | |
emr = AWS::EMR.new | |
job = emr.job_flows.create('dynamo-db-backup', {log_uri: log_uri, |
This file contains 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
# For context, this was inspired by the RubyRogues podcast #79 where they talked about | |
# documentation in Ruby, and specifically grumbled quite a bit about the failings of RDoc. | |
# | |
# http://rubyrogues.com/079-rr-documenting-code/ | |
# | |
# As someone who's spent a lot of time using an IDE for programming C# and Java, I think | |
# Ruby could do a lot better at putting documentation at our fingertips as we program. | |
# | |
# Maybe making the documentation part of the structure of the code would facilitate this? | |
# |
This file contains 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
@mixin respond-to($media) { | |
@if $media == iphone { | |
@media only screen and (device-width: 320px) and (device-height: 480px) { @content; } | |
} | |
@else if $media == iphone-portrait { | |
@media only screen and (device-width: 320px) and (device-height: 480px) and (orientation: portrait) { @content; } | |
} | |
@else if $media == iphone-landscape { | |
@media only screen and (device-width: 320px) and (device-height: 480px) and (orientation: landscape) { @content; } | |
} |
This file contains 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
// | |
// CoreTextLabel.h | |
// Frost | |
// | |
// Created by David Kasper on 10/1/12. | |
// | |
#import <UIKit/UIKit.h> | |
#import <CoreText/CoreText.h> |
This file contains 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/bin/env bash | |
# | |
# install all of http://github.com/phuibonhoa's TM bundles (OS X only) | |
# | |
echo "Installing bundles..." | |
# backup dir | |
if [ -d ~/desktop/_tm_bundle_backups ]; then rm -rf ~/desktop/_tm_bundle_backups; fi |
NewerOlder