Skip to content

Instantly share code, notes, and snippets.

View julik's full-sized avatar
💭
🎺

Julik Tarkhanov julik

💭
🎺
View GitHub Profile
require 'benchmark'
def rc
rand(127).chr
end
ITER = 1_000_000
puts "\n\n rb_format_str"
Benchmark.bm do | x|
require 'strscan'
class SloppyParser < StringScanner
def skip_until(pattern)
pattern.is_a?(String) ? super(/#{Regexp.escape(pattern)}/m) : super(pattern)
end
def scan_until(pattern)
pattern.is_a?(String) ? super(/#{Regexp.escape(pattern)}/m) : super(pattern)
end
$KCODE = 'u'
require 'test/unit'
module Vodka
const_set("TАБЛИЦА", {
"R" => "Я",
"Y" => "Ч",
"U" => "Ц",
"B" => "Б",
"N" => "И",
const char *pluginSignature = "my.super.expensive.plugin";
#ifdef APL
// Mac-specific: it IS possible to have plugin installed twice, once in the ACF folder
// and once in the X-System folder. Probably due to namespace mangling on OS X
// the system will NOT crash the app when the plugin gets loaded twice.
// Thus, we query the enabled plugins for the defined signatures
// and DO NOT activate should the other plugin already be plugged in
XPLM_API XPLMPluginID other_copy_id = XPLMFindPluginBySignature(pluginSignature);
<?xml version="1.0"?>
<!--
To override or add "named" joystick drivers list them in
<js-named> entries with paths relative to the directory where
the joysticks.xml file resides (first example). Such "named"
drivers are only picked up if one of their <name>s matches
the joystick hardware (see output of the js_demo application).
These drivers have precedence over already existing drivers
with the same <name>. (You can also add a <name>default</name>
entry to the driver to make it the default choice.)
var axisHandlerPerIndex = func(pre, post) {
func(idx = 0) {
var val = cmdarg().getNode("setting").getValue();
setprop(pre ~ idx ~ post, (1 - val) / 2);
}
}
var throttleAxisPerEngine = axisHandlerPerIndex("/controls/engines/engine[", "]/throttle");
<js n="0" include="Input/Joysticks/CH/pro-yoke-usb.xml"/>
<js n="1" include="Input/Joysticks/Saitek/Pro-Flight-Quadrant-Left.xml"/>
<js n="2" include="Input/Joysticks/Saitek/Pro-Flight-Quadrant-Right.xml"/>
<js n="3" include="Input/Joysticks/CH/pro-pedals-usb.xml"/>
<axis n="0">
<desc>Prop Pitch</desc>
<binding>
<command>nasal</command>
<script>controls.propellerAxis()</script>
</binding>
</axis>
<axis n="1">
<desc>Throttle 1</desc>
<binding>
<axis n="0">
<desc>Throttle 3</desc>
<binding>
<command>nasal</command>
<script>controls.throttleAxisPerEngine(2)</script>
</binding>
</axis>
<axis n="1">
<desc>Prop Pitch</desc>
var throttleAxisForEngine = axisHandlerPerIndex("/controls/engines/engine[", "]/throttle");
var axisHandlerPerIndex = func(pre, post) {
func(idx = 0) {
var val = cmdarg().getNode("setting").getValue();
setprop(pre ~ idx ~ post, (1 - val) / 2);
}
}
var throttleAxisForEngine = axisHandlerPerIndex("/controls/engines/engine[", "]/throttle");