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
// This is a hash map implementation for maps with string keys only, designed to maximize performance. Similar in some ways to LLVM's StringMap | |
#include <iostream> | |
#include <unordered_map> | |
#include <memory> | |
#include <absl/container/flat_hash_map.h> | |
#ifndef HASH_H | |
#define HASH_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
void fallback(double d, char *buffer) { | |
snprintf(buffer, 25, "%0.16e", d); | |
} | |
void handleUncommonCases(double d, char *buffer) { | |
if (std::isinf(d)) { | |
if (d < 0) { | |
(*buffer++) = '-'; | |
} | |
strcpy(buffer, "Infinity"); |
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
<?xml version="1.0" encoding="UTF-8" ?> | |
<package> | |
<id>asdfasdfasd.insto</id> | |
<title>insto</title> | |
<owner> | |
<name>Michael Eisel</name> | |
</owner> | |
<import-schema>kdebug-strings</import-schema> | |
<ktrace-point-schema> | |
<id>com-eisel-asdf</id> |
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/ruby | |
def try(cmd) | |
puts cmd | |
success = system(cmd) | |
raise unless success | |
end | |
def current_commit() | |
`git rev-parse head`.chomp |
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/ruby | |
def try(cmd) | |
puts cmd | |
success = system(cmd) | |
raise unless success | |
end | |
def current_commit() | |
`git rev-parse head`.chomp |
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
//Copyright (c) 2018 Michael Eisel. All rights reserved. | |
import Foundation | |
import QuartzCore | |
// import IkigaJSON | |
import ZippyJSON | |
import os | |
func dataFromFile(_ file: String) -> Data { | |
return try! String(contentsOfFile: Bundle.main.path(forResource: file, ofType: nil)!).data(using: .utf8)! |
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
Here's the license (it's the MIT license) that applies to all of my public gists: | |
Copyright Michael Eisel | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERW |
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
func f() { | |
let max = range.product(range).maxWith { (topRow, leftCol) -> (Int) in | |
return (0..<3).product(0..<3).map { rowOffset, colOffset in // (rowOffset: Int, colOffset: Int) -> (Int) in | |
return scores[topRow + rowOffset][leftCol + colOffset] | |
}.reduce(0, +) | |
} | |
} |
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
postfix operator ~ | |
public postfix func ~<T>(lhs: (T, T)) -> [T] { | |
return [lhs.0, lhs.1] | |
} | |
func go() { | |
(0, 0)~ // '~' is not a postfix unary operator | |
} |
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
public extension Sequence { | |
public func mySequence() -> AnySequence<Element> { | |
return AnySequence { () -> AnyIterator<Element> in | |
var iterator = self.makeIterator() | |
return AnyIterator { | |
return iterator.next() | |
} | |
} | |
} | |
} |
NewerOlder