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
class Document { | |
func properties() -> [String] { | |
var array: [String] = [] | |
var mirror = reflect(self) | |
for i in 0..<mirror.count { | |
if mirror[i].0 != "super" { | |
array.append(mirror[i].0) | |
} | |
} | |
return array |
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
import Foundation | |
struct Regex { | |
let pattern: String | |
let options: NSRegularExpressionOptions! | |
private var matcher: NSRegularExpression { | |
return NSRegularExpression(pattern: self.pattern, options: self.options, error: nil)! | |
} | |
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
#!/bin/bash | |
# ----------------------------------------------------------------------- | |
# Installs Ruby 2.2 using rbenv/ruby-build on the Raspberry Pi (Raspbian) | |
# | |
# Run from the web: | |
# bash <(curl -s raw_script_url_here) | |
# ----------------------------------------------------------------------- | |
# Set up variables |
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
import Foundation | |
@objc class Timer: NSObject { | |
var timer: NSTimer? | |
var handler: (() -> ())! | |
let duration: Double | |
init(duration: Double) { | |
self.duration = duration | |
super.init() |
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
extern crate gpio_pi; | |
use std::thread; | |
use gpio_pi::Gpio; | |
// use gpio::sys::Gpio; | |
fn main() { | |
let gpio = Gpio::new().unwrap(); | |
let pinopt = gpio.pin(17); | |
let pin = pinopt.output(); |
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
#[derive(Debug)] | |
pub struct Selector { | |
sys: File | |
} | |
impl FromRawFd for Selector { | |
unsafe fn from_raw_fd(fd: RawFd) -> Selector { | |
Selector { sys: File::from_raw_fd(fd) } | |
} | |
} |
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
use std::io; | |
#[derive(Debug, Copy, Clone)] | |
pub enum Logic { | |
High, | |
Low | |
} | |
#[derive(Debug, Copy, Clone)] | |
pub enum Logic3 { |
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 generate_token(length=8) | |
alphanumerics = ('a'..'z').to_a.concat(('A'..'Z').to_a.concat(('0'..'9').to_a)) | |
self.token = alphanumerics.sort_by{rand}.to_s[0..length] | |
# Ensure uniqueness of the token.. | |
generate_token unless Widget.find_by_token(self.token).nil? | |
end |
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
# populate test database before running tests | |
Rake::Task["db:test:prepare"].enhance do | |
Customer.establish_connection "test" | |
Domain.establish_connection "test" | |
PopulationHelper.populate | |
end |
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
pub trait Index { | |
fn from_usize(i: usize) -> Self; | |
fn as_usize(&self) -> usize; | |
} | |
#[derive(Debug)] | |
pub struct Fragments<E, I: Index> { | |
list: Vec<Option<E>>, | |
free: Vec<I>, | |
} |
OlderNewer