Skip to content

Instantly share code, notes, and snippets.

View daboross's full-sized avatar

daboross

View GitHub Profile
@daboross
daboross / prolog.kak
Last active May 19, 2018 23:07
Extremely basic prolog highlighting for kakoune
# Extremely basic prolog highlighting for kakoune
# Updated 2018-05-14
#
# It's pretty functional, but it doesn't support all the fanciness it could.
# The main bad thing right now is that it doesn't differentiate between calls
# to other rules and atoms.
hook global BufCreate .*\.(pro|pl)? %{
set-option buffer filetype prolog
}
@daboross
daboross / kakrc
Last active June 29, 2021 15:01
yet another rust developer's kakrc file
# daboross's kakrc
#
# ###
#
# Copyright (c) 2019 David Ross
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
change-directory /home/daboross/Projects/kakoune/save-session.kak
edit -debug '*debug*'
edit -scratch '*scratch*'
edit 'rc/save-session.kak'
edit 'src/main.rs'
buffer 'src/main.rs'
set-register '@' ''
set-register '^' ''
set-register '"' ''
set-register '/' 'restore'
match c.unwrap() {
Key::Esc => break,
Key::Char(c) => input.push(c),
Key::Backspace if !input.is_empty() => {
input.remove(input.len());
}
_ => {},
}
messages_future.map(move |redis_msg| {
let lock = refs.lock();
let res: u32 = lock.map(|subscriptions| {
subscriptions.get(&channel)
.map(|subscription| {
subscription.iter()
.cloned()
.map(|subscription_id| {
extern crate redis;
extern crate serde_json;
extern crate futures;
extern crate futures_cpupool;
use redis::Commands;
use std::collections::HashMap;
use std::thread;
use std::cell::Cell;
use futures::sync::mpsc::channel;
use futures::Sink;
@daboross
daboross / lib.rs
Last active October 10, 2023 08:09
Rust Vec vs. HashMap lookup performance - note: see comments! test is flawed (test never adds more than 7 items to HashMap).
#![feature(test)]
extern crate test;
use std::borrow::Cow;
use std::collections::HashMap;
pub fn test_vec(x: &Vec<(Cow<'static, str>, i32)>, module: &str) -> Option<i32> {
x.iter().find(|&&(ref test_module, _)| test_module == module).map(|&(_, level)| level)
}
pub fn test_map(x: &HashMap<Cow<'static, str>, i32>, module: &str) -> Option<i32> {
@daboross
daboross / original (ideal).rs
Created February 27, 2017 00:07
Rustfmt formatting example
fn main() {
let x = Struct {
a_field: vec![
AnotherStruct {
time_period: 8,
energy_harvested: stats_max.energyHarvested8,
energy_spent_creeps: stats_max.energyCreeps8,
energy_spent_control: stats_max.energyControl8,
energy_spent_construction: stats_max.energyConstruction8,
creep_parts_produced: stats_max.creepsProduced8,
@daboross
daboross / main.rs
Created February 26, 2017 23:56
Example of "strange" formatting.
fn main() {
let x = Struct {
a_field: vec![
AnotherStruct {
time_period: 8,
energy_harvested: stats_max.energyHarvested8,
energy_spent_creeps: stats_max.energyCreeps8,
energy_spent_control: stats_max.energyControl8,
energy_spent_construction: stats_max.energyConstruction8,
creep_parts_produced: stats_max.creepsProduced8,
"use strict";
// Transcrypt'ed from Python, 2017-01-31 15:24:02
function main () {
var __symbols__ = ['__py3.5__', '__esv6__'];
var __all__ = {};
var __world__ = __all__;
// Nested object creator, part of the nesting may already exist and have attributes
var __nest__ = function (headObject, tailNames, value) {
// In some cases this will be a global object, e.g. 'window'