Skip to content

Instantly share code, notes, and snippets.

View lights0123's full-sized avatar

Ben Schattinger lights0123

View GitHub Profile
fn escape_str<W: fmt::Write>(mut f: W, mut s: &str, replacements: &[(u8, &str)]) -> fmt::Result {
while !s.is_empty() {
let (idx, replacement) = s
.as_bytes()
.iter()
.enumerate()
.find_map(|(i, c)| {
replacements
.iter()
.find(|(r, _)| c == r)
use test::Bencher;
#[derive(Debug)]
pub struct Rate {
pub id: u8,
pub from: String,
pub to: String,
pub exchange: String,
pub rate: f64,
pub vol: f64,
import java.util.*;
import java.util.stream.Collectors;
public class RelearnJava {
public static void main(String[] args) {
{
Scanner scanner = new Scanner(System.in);
String s = scanner.next();
int a = scanner.nextInt();
long l = scanner.nextLong();
@lights0123
lights0123 / HighlightedCode.vue
Last active August 17, 2020 06:00
vue-highlight with line numbers
<template>
<pre><code :style="{ tabSize, fontSize: `${fontSize}px` }" :class="['hljs', lang]" v-html="formattedCode"></code></pre>
</template>
<script lang="ts">
import { Component, Prop, Vue, Watch } from 'vue-property-decorator';
import hljs from 'highlight.js';
import highlightLines from './highlightLines';
@Component
use alloc::boxed::Box;
use core::ptr::null_mut;
use cty::c_void;
use num_derive::FromPrimitive;
use num_traits::FromPrimitive;
use pros_sys::lv_obj_t;
use crate::lvgl::{LVGLObject, Object};
format:
.Lfunc_begin63:
.loc 20 28 0 is_stmt 1
.fnstart
.cfi_startproc
.save {r4, r5, r6, r7, r8, r9, r11, lr}
push {r4, r5, r6, r7, r8, r9, r11, lr}
.cfi_def_cfa_offset 32
.cfi_offset lr, -4
.cfi_offset r11, -8
@lights0123
lights0123 / index.js
Created January 22, 2019 22:55
TP9605 Datalogger
const btSerial = new (require('bluetooth-serial-port')).BluetoothSerialPort();
const readline = require('readline');
const chalk = require('chalk');
let start = new Date();
let data = [['time', 'temp']];
let go = false;
function log(...data){
if(go) console.log(chalk.green(...data));
else console.log(chalk.yellow(...data));
@lights0123
lights0123 / .clang-format
Created October 28, 2018 17:09
.clang-format
AccessModifierOffset: -4
AlignEscapedNewlinesLeft: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
################################################################################
######################### User configurable parameters #########################
# filename extensions
CEXTS:=c
ASMEXTS:=s S
CXXEXTS:=cpp c++ cc
# probably shouldn't modify these, but you may need them below
ROOT=.
FWDIR:=$(ROOT)/firmware
{
"bridge": {
"name": "Bridge",
"username": "08:E5:AE:7A:77:8F",
"port": 51826,
"pin": "031-45-154"
},
"description": "A pumpkin that shoots Silly String!",
"platforms": [