Skip to content

Instantly share code, notes, and snippets.

View 488 GT3 In Gear Acceleration Test.csv
lap_time throttle mph rpm gear hg fg
172264 1.00 27.66 3139.65 2 -0.04 0.52
172280 1.00 27.86 3161.41 2 -0.04 0.57
172296 1.00 28.06 3177.08 2 -0.04 0.59
172316 1.00 28.32 3205.00 2 -0.03 0.60
172332 1.00 28.53 3229.73 2 -0.01 0.60
172348 1.00 28.74 3254.50 2 0.00 0.62
172364 1.00 28.95 3279.07 2 0.01 0.61
172384 1.00 29.23 3310.62 2 0.03 0.61
172396 1.00 29.39 3331.57 2 0.03 0.63
@bradland
bradland / ac-telemetry.rb
Last active May 13, 2020
Beginnings of a rudimentary CLI telemetry utility for Assetto Corsa written in Ruby.
View ac-telemetry.rb
#!/usr/bin/env ruby
$: << './lib'
require 'socket'
require 'bindata'
require 'json'
class UTF8String < BinData::String
def snapshot
View pingr
#!/usr/bin/env ruby
require 'logger'
require 'open3'
require 'optparse'
require 'ostruct'
require 'thread'
class ShellScript
View movtogif
#!/bin/bash
# argument one is the input base file name
#ffmpeg -i $1.flv -vcodec png -vframes 1 -ss 00:00:$2 -an -f rawvideo -s 640x480 $1-640x480.png
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=15 > out.gif
View pcars_net.rb
require 'bindata'
# Record definition
class PCarsNet < BinData::Record
endian :little
uint16 :build_version_number # 0
uint8 :packet_type # 2
bit4 :session_state # 3
bit4 :game_state # 3
View axlsx_defined_name_issue.md

Description and reproduction

Running the script axlsx_print_area.rb (provided at end of issue) will produce an Excel workbook that, when unzipped, contains the workbook.xml contents; also provided below. It can be observed that the name attributes of the <definedName> nodes have been altered from their original form. This has a couple of undesirable side-effects.

  1. It breaks behavior specified in the examples (repeating headers). Repeating headers are not actually produced.

  2. Tangentially, it prevents one from using any of the built-in names specified in the source of Axlsx::DefinedName.

  3. It mangles valid defined names, leading to confusion. For example, if the defined name "Example_Range" is specified, it will be converted to "ExampleRange".

View axlsx_print_area.rb
require 'axlsx'
require 'pry'
p = Axlsx::Package.new
wb = p.workbook
# Build up a matrix of data
cols = ("A".."L").to_a
rows = (1..100).map do |i|
cols.zip(cols.dup.fill(i.to_s)).map(&:join)
View fosl_ext_layout.txt
─ lib
├── fosl_ext
│   └── parser.rb
└── fosl_ext.rb
View hash_array_access.rb
# Allows access to deep hashes by passing an array of keys, which will be used
# in a serial chain of hash key lookups. For example, the array:
# [:one, :two, :three]
# Would translate to the key structure:
# hash[:one][:two][:three]
# Usage:
View count-v-scan-v-gsub.rb
require 'benchmark/ips'
TEST_STRING = "FooBar" * 10
Benchmark.ips do |x|
x.report("count") do
TEST_STRING.count('[A-Z]')
end
x.report("gsub") do