Skip to content

Instantly share code, notes, and snippets.

@factormystic
factormystic / slat_test.rb
Last active December 16, 2015 14:59
SLAT test via WMI
require 'win32ole'
wmi = WIN32OLE.connect('winmgmts://')
result = wmi.ExecQuery('select SecondLevelAddressTranslationExtensions from Win32_Processor').to_enum.first
if result && result.SecondLevelAddressTranslationExtensions
puts 'SLAT Available'
else
puts 'SLAT Not Available'
end
@factormystic
factormystic / net-ssh-forwarding-test.rb
Created November 16, 2012 22:15
Net::SSH agent forwarding test
require 'net/ssh'
# Start Pageant and load your github & server identity keys
# :verbose => Logger::DEBUG
Net::SSH.start("your ssh server.com", "your username", { :forward_agent => true }) do |ssh|
result = ssh.exec!("ls -la ~")
puts result
# puts 'waiting on open channel...'
@factormystic
factormystic / osiris.cs
Created June 3, 2012 21:47
Using speech recognition, speech synthesis, and the Wolfram Alpha API to make a simple Siri clone
var WA_API_KEY = @"";
var VoiceOut = new System.Speech.Synthesis.SpeechSynthesizer();
VoiceOut.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult, 0, CultureInfo.CurrentCulture);
VoiceOut.SetOutputToDefaultAudioDevice();
var WA = new WAClient(WA_API_KEY);
WA.OnResultReceived += (WAResult, input) =>
{
try
Observable.FromEvent<SensorReadingEventArgs<CompassReading>>(compass, "CurrentValueChanged")
.BufferWithTime(TimeSpan.FromSeconds(2))
.Select(headings => headings.Select(e => e.EventArgs.SensorReading.TrueHeading).Sum() / headings.Count())
.ObserveOnDispatcher()
.Subscribe(heading => this.ArrowRotation.Angle = 360 - heading);
<Image Stretch="None" Source="compass.arrow.dark.png" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<RotateTransform x:Name="ArrowRotation" CenterX="0.5" CenterY="0.5" />
</Image.RenderTransform>
</Image>
using System;
using System.Diagnostics;
using System.Linq;
using Microsoft.Devices.Sensors;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Reactive;
namespace Rx_Compass_Smoothing
{
public partial class MainPage : PhoneApplicationPage
Observable.FromEvent<SensorReadingEventArgs<CompassReading>>(compass, "CurrentValueChanged")
.BufferWithTime(TimeSpan.FromSeconds(2))
.Select(headings => headings.Select(e => e.EventArgs.SensorReading.TrueHeading).Sum() / headings.Count())
.Subscribe(heading => Debug.WriteLine(string.Format("Averaged: {0}", heading)));
Observable.FromEvent<SensorReadingEventArgs<CompassReading>>(compass, "CurrentValueChanged")
.BufferWithTime(TimeSpan.FromSeconds(2))
.SelectMany(events => events.Select(e => e.EventArgs.SensorReading.TrueHeading))
using System;
using System.Diagnostics;
using System.Linq;
using Microsoft.Devices.Sensors;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Reactive;
namespace Rx_Compass_Smoothing
{
public partial class MainPage : PhoneApplicationPage
using System.Diagnostics;
using Microsoft.Devices.Sensors;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Reactive;
namespace Rx_Compass_Smoothing
{
public partial class MainPage : PhoneApplicationPage
{
Compass compass = new Compass();