Skip to content

Instantly share code, notes, and snippets.

Avatar

Fabian Keller bluenote10

  • Bosch
  • Ludwigsburg, Germany
View GitHub Profile
@bluenote10
bluenote10 / main.dart
Last active Aug 12, 2021
Flutter: Center Positioned
View main.dart
import "package:flutter/material.dart";
void main() {
runApp(App());
}
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
View plot_oscillations.py
import numpy as np
import matplotlib.pyplot as plt
from ssqueezepy import ssq_cwt, cwt
SAMPLE_RATE = 44100
def sine(freq, num_samples=SAMPLE_RATE // 4, amp=1.0):
View iterate_and_borrow.rs
// https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=8921bcc0302b066ef5e39bc6e9a8b7e3
#![allow(dead_code)]
use std::collections::HashMap;
struct Test {
offset: f64,
buffers: HashMap<i32, Vec<f64>>,
data: Vec<f64>,
View flatmap.nim
import future
import options
#[
proc flatMap[X](iter: iterator(): X, mapper: X -> iterator(): X): (iterator(): B) =
result = proc() =
yield X
proc iter(): int =
@bluenote10
bluenote10 / data1.csv
Created Jan 1, 2017
Issues with d3 tip
View data1.csv
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
value
100
150
200
@bluenote10
bluenote10 / chantest.nim
Created Aug 30, 2015
Nim Channel Test
View chantest.nim
import os, threadpool
proc spawnBackgroundJob[T](channel: ptr Channel[T], f: iterator (): T) =
type Args = tuple[iter: iterator (): T, channel: ptr Channel[T]]
proc threadFunc(args: Args) {.thread.} =
echo "Thread is starting"
let iter = args.iter
var channel = args.channel # note: still a `ptr Channel`
View stringParseTest.nim
macro stringParseTest(s: string): stmt =
let trueString = s.strVal
let ne = parseExpr(trueString)
let ns = parseStmt(trueString)
echo treeRepr(ne)
echo treeRepr(ns)
# looking good:
# Infix
# Ident !"+"
# Ident !"y"
View nimrun
#!/usr/bin/env sh
# A wrapper around the Nim compiler to allow for easy scripting of Nim. Puts
# all temporary files in a temporary directory and cleans up after itself.
#
# Usage:
# - add `#!/usr/bin/env nimrun` at the beginning of your script
# - execute the nim file with it, for example, `nimrun file.nim args`
#
# Possible future extentions:
View notNilTest
type
Test = object
field: seq[int] not nil
var t: Test
echo t.field.isNil() # true
View gist:fc7907f2538606912799
import os, threadpool
proc spawnBackgroundJob[T](f: iterator (): int): TChannel[T] =
type Args = tuple[iter: iterator (): T, channel: ptr TChannel[T]]
#type Args = tuple
# iter: iterator (): T
# channel: ptr TChannel[T]
proc threadFunc(args: Args) {.thread.} =