Skip to content

Instantly share code, notes, and snippets.

@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
@factormystic
factormystic / profile.ps1
Created May 19, 2016 01:29
my custom powershell prompt
# open your profile.ps1 and paste this in
# easiest way:
# > youreditorprogram.exe $profile
function Prompt {
$path = $(Get-Location).Path
if ($path.StartsWith($HOME, "CurrentCultureIgnoreCase")) {
$path = "~"+ $path.Substring($HOME.Length)
}
@factormystic
factormystic / output.txt
Created January 22, 2014 00:55
Listening on http in c# without a uac prompt
c:\>curl http://localhost:65432/wat/
Hiya mister curl/7.26.0
c:\>
using System;
using System.Collections.Generic;
namespace FMUtils.FlexTreeView.Extensions
{
public static class IEnumerableExtensions
{
public static IEnumerable<T> Realize<T>(this IEnumerable<T> source, Action<T> action)
{
foreach (T el in source)
@echo off
REM Usage: `up <n>`
REM Will run `cd ..` n times
REM Put this file (`up.bat`) somewhere in your PATH
set many=1
if not "%1"=="" set many=%1
for /l %%x in (1, 1, %many%) do cd ..
var size = {
width: 650,
padding: 60,
radius: 250,
};
// scale from unit positions to pixel positions
var scale = {
pixel: d3.scale.linear()
.domain([-1, 0, 1])
@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 / form.cs
Last active October 31, 2015 00:50 — forked from Ell/form.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
@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...'
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);