Skip to content

Instantly share code, notes, and snippets.

@kmussel
kmussel / gist:46438a9a381fde942a31
Last active August 29, 2015 14:10
rabbitmq publisher with celluloid
class Rabbitmq
include Celluloid
ACTOR_NAME = :rabbitmq_publisher
RETRY_COUNT = 2
attr_reader :retry_count
class << self
def publish(message, routing_key, headers = {}, &block)
@kmussel
kmussel / gist:e6787839b09ab5e38842
Created December 15, 2014 15:13
Oriented connection commit
def commit
@transaction_type = 0
Oriented.graph.raw_graph.transaction.current_record_entries.to_a.each do |r|
@transaction_type |= TRANSACTION_TYPES[r.type]
end
@graph.commit
Oriented::IdentityMap.clear
@retries = 0
rescue Java::ComOrientechnologiesOrientCoreException::OConcurrentModificationException => ex
@retries ||= 0
@kmussel
kmussel / gist:8b6b6f4e94ac4f52767b
Created February 18, 2016 15:42
Swift Socket Server
import Foundation
public class Client {
public var socket:Socket
public var sentdata:dispatch_data_t?
// public var channel:dispatch_io_t
public var hashValue: Int { return Int(socket.descriptor) }
init(socket sock:Socket, sentdata sdata:dispatch_data_t?) {
socket = sock
struct Favorite : CustomStringConvertible{
let ID: Int!
let name: String!
let category: Category!
// CustomStringConvertible conformance
var description : String {
return name
}
}
@kmussel
kmussel / CommonCrypto.podspec
Created January 17, 2017 20:53
Podspec to handle system libraries
Pod::Spec.new do |s|
s.name = 'CommonCrypto'
s.version = '0.0.1'
s.summary = 'Swift module map for CommonCrypto.'
s.description = 'Module maps for importing CommonCrypto C libs to Swift.'
s.homepage = 'https://github.com/kmussel/commoncrypto'
s.license = { :type => 'Public'}
s.author = 'Kevin Musselman'
s.platform = :ios, '9.0'
s.source = { :git => '[email protected]:kmussel/commoncrypto.git', tag: "#{s.version}" }
@kmussel
kmussel / SwiftHostFileParsing.swift
Created February 8, 2017 16:16
parse host file using swift regex
func captureGroups(withRegex pattern: String, with hosts:String) -> [String] {
var matches : [String] = []
var regex: NSRegularExpression
do {
regex = try NSRegularExpression(pattern: pattern, options: [.caseInsensitive, .anchorsMatchLines])
} catch {
return matches
}
regex.enumerateMatches(in: hosts, options: [], range: NSRange(location: 0, length: hosts.characters.count)) { (result: NSTextCheckingResult?, flags: NSRegularExpression.MatchingFlags, _) in
if let range = result?.rangeAt(1) {
@kmussel
kmussel / tada
Last active April 25, 2019 15:21
my test flow
sup