Skip to content

Instantly share code, notes, and snippets.

@SixArm
SixArm / gist:9b5641accf56ff936e65
Created April 16, 2015 01:27
Xcode Swift Home PageControl
import UIKit
class HomeViewController: UIViewController {
@IBOutlet weak var pageControl: UIPageControl!
@IBOutlet weak var pageImageView: UIImageView!
@IBOutlet weak var pageCaptionLabel: UILabel!
var pageIndex = 0
let pageIndexMin = 0
@SixArm
SixArm / gist:a83405d36fb4406ca0db
Created March 3, 2015 22:23
Roman numeral conversion sample code
class Roman
Memo = {}
Code = [["","I","II","III","IV","V","VI","VII","VIII","IX"],
["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"],
["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"],
["","M","MM","MMM"]]
def self.to_roman(n)
Memo[n] ||= begin
l = Math.log10(n).to_i
require 'ostruct'
class Transaction
attr_accessor :name, :last_name, :nation_id
def nation; OpenStruct.new(name: "Nation ID " + nation_id); end
end
@transaction = Transaction.new
@SixArm
SixArm / exportable.rb
Created November 29, 2014 06:39
Exportable module for exporting XML
##
# Exportable module to help create XML from models.
#
# Author: Joel Parker Henderson (joel@joelparkerhenderson.com)
# License: GPL
#
module Exportable
##
# Get this object's export string, such as an XML element string.
@SixArm
SixArm / exportable_example_with_project_and_items.rb
Created November 29, 2014 06:37
Exportable example with project and items
require_relative 'exportable'
class Project
include Exportable
attr_accessor :name
attr_accessor :description
attr_accessor :items
def initialize(args)
@name, @description, @items = args.values
@SixArm
SixArm / Ruby Exportable
Created November 29, 2014 06:32
Ruby example of Exportable module for creating XML
##
# Exportable methods to help create XML from models.
#
# Author: Joel Parker Henderson (joel@joelparkerhenderson.com)
# License: GPL
#
module Exportable
##
# Get this object's export string, such as an XML element string.
@SixArm
SixArm / cumulative_performance.patch
Created January 26, 2012 01:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p0 cumulative performance patch.
diff --git a/common.mk b/common.mk
index ea244cc..4f22609 100644
--- a/common.mk
+++ b/common.mk
@@ -629,7 +629,8 @@ file.$(OBJEXT): {$(VPATH)}file.c $(RUBY_H_INCLUDES) {$(VPATH)}io.h \
gc.$(OBJEXT): {$(VPATH)}gc.c $(RUBY_H_INCLUDES) {$(VPATH)}re.h \
{$(VPATH)}regex.h $(ENCODING_H_INCLUDES) $(VM_CORE_H_INCLUDES) \
{$(VPATH)}gc.h {$(VPATH)}io.h {$(VPATH)}eval_intern.h {$(VPATH)}util.h \
- {$(VPATH)}debug.h {$(VPATH)}internal.h {$(VPATH)}constant.h
+ {$(VPATH)}debug.h {$(VPATH)}internal.h {$(VPATH)}constant.h \
@SixArm
SixArm / ld.rb
Created August 12, 2011 23:57
Levenshtein Distance coding challenge: find all words in a set that are connected
#!/usr/bin/env ruby
#
# Two words are "directly connected" if one word can transform into the other by any of:
# * substitution of one character for another, e.g. "tan" => "ton"
# * insertion of one character, e.g. "tan" => "than"
# * deletion of one character, e.g. "tan" => "an"
#
# Two words are "connected" if applying the rules above repeatedly can directly connect words:
# * e.g. "tan" => "ton" => "tone" => "one" => "on"
# * e.g. "tan" => "an" => "in" => "pin" => "pink"
=begin rdoc
= WebGet Ruby Gem: HashMore
Author:: Joel Parker Henderson, joelparkerhenderson@gmail.com
Copyright:: Copyright (c) 2007-2010 Joel Parker Henderson
License:: CreativeCommons License, Non-commercial Share Alike
License:: LGPL, GNU Lesser General Public License