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
const levelup = require('levelup') | |
const leveldown = require('leveldown') | |
const config = require('../config')('persistent') | |
const path = require('path') | |
const lodash = require('lodash') | |
const { promisify } = require('util') | |
const { decode, encode } = require('./de') | |
const openDatabase = (file, options) => | |
promisify(levelup)(leveldown(file, options)) |
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::fmt::Debug; | |
use std::any::Any; | |
use std::io; | |
// Logger function for any type that implements Debug. | |
fn log<T: Any + Debug>(value: &T) { | |
let value_any = value as &Any; | |
// try to convert our value to a String. If successful, we want to | |
// output the String's length as well as its value. If not, it's a |
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>, | |
} |
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
#[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
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
#![feature(core_intrinsics)] | |
#[warn(dead_code)] | |
//#[warn(unused_assignments)] | |
extern crate mmap; | |
extern crate libc; | |
use libc::*; | |
use std::ffi::CString; | |
use std::path::Path; | |
use mmap::{MemoryMap,MapOption}; |
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
#!/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 | |
struct Regex { | |
let pattern: String | |
let options: NSRegularExpressionOptions! | |
private var matcher: NSRegularExpression { | |
return NSRegularExpression(pattern: self.pattern, options: self.options, error: nil)! | |
} | |
NewerOlder