Skip to content

Instantly share code, notes, and snippets.

@kmussel
kmussel / tada
Last active April 25, 2019 15:21
my test flow
sup
@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 / 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 => 'git@github.com:kmussel/commoncrypto.git', tag: "#{s.version}" }
struct Favorite : CustomStringConvertible{
let ID: Int!
let name: String!
let category: Category!
// CustomStringConvertible conformance
var description : String {
return name
}
}
@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
@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: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:41bfcd17fb2e2c8f1103
Created November 14, 2014 15:14
Remote Procedure Call class with rabbitmq
require_relative 'rabbitmq.rb'
class Rpc
attr_reader :connection
attr_reader :lock, :condition
attr_accessor :response, :call_id
DEFAULT_RETRY_TIMEOUT = 60
def initialize(opts = {})
@kmussel
kmussel / gist:8461886
Last active January 3, 2016 12:19
blueprints Add Edge
public static Object createLink(final ODocument iFromVertex,
final OIdentifiable iTo, final String iFieldName) {
final Object out;
Object found = iFromVertex.field(iFieldName);
if (found == null)
// CREATE ONLY ONE LINK
out = iTo;
else if (found instanceof OIdentifiable) {
if (found.equals(iTo))
// SAME LINK, SKIP IT
(develop)$ jruby -S trinidad
Deploying from /kyck_registrar_web as /
Initializing ProtocolHandler ["http-bio-0.0.0.0-4244"]
jruby 1.7.4 (1.9.3p392) 2013-05-28 fffffff on Java HotSpot(TM) 64-Bit Server VM 1.7.0_21-b12 [darwin-x86_64]
using 1:5 runtime pool with acquire timeout of 5.0 seconds
Config HA cluster, ha.server_id: 2, db: /db/ha_neo_server_2
Connecting to database specified by database.yml
/config/initializers/devise.rb:247 warning: already initialized constant VERIFY_PEER
added application to pool, size now = 1
Starting ProtocolHandler ["http-bio-0.0.0.0-4244"]