Skip to content

Instantly share code, notes, and snippets.

View otac0n's full-sized avatar

John Gietzen otac0n

View GitHub Profile

Keybase proof

I hereby claim:

  • I am otac0n on github.
  • I am otac0n (https://keybase.io/otac0n) on keybase.
  • I have a public key whose fingerprint is 049F A0C3 7352 DB2C 3FAA 05B2 0246 FA2A C899 8685

To claim this, I am signing this object:

@otac0n
otac0n / SecretStore.cs
Created July 22, 2015 21:08
Quick, secure secret storage for C# scripts.
public class SecretStore
{
private readonly string SecretsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), typeof(SecretStore).FullName);
public bool Exists(Guid key)
{
return File.Exists(GetPath(key));
}
@otac0n
otac0n / program.cs
Created July 12, 2011 00:38
Generated IE9 Test Fixture
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace NegativeTests
{
class Program
@otac0n
otac0n / FindConflictingReferences.cs
Created January 25, 2012 01:13 — forked from brianlow/FindConflictingReferences.cs
Find conflicting assembly references
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
namespace MyProject
{
[TestFixture]
<!DOCTYPE HTML>
<html>
<head>
<title>WebTurtle/Parser tests</title>
<meta charset="utf-8">
<script language="javascript" SRC="js/peg-0.7.0.js"></script>
<script language="peg" id="grammar">
start = wt program wt
program = front / back
front = 'μπροστά' wt integer
#!/bin/sh
git filter-branch --env-filter '
an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"
if [ "$GIT_COMMITTER_EMAIL" = "your@email.to.match" ]
@otac0n
otac0n / regexes.txt
Last active September 2, 2016 19:33
Cleaning Regexes
Remove trailing whitespace:
Pattern: [ \t]+(?=[\r\n])
Replace: ""
Replace tabs with spaces:
Pattern: (?<=^([^\t\r\n]{4})*)\t
Replace: " "
Pattern: (?<=^([^\t\r\n]{4})*[^\t\r\n]{1})\t
Replace: " "
Pattern: (?<=^([^\t\r\n]{4})*[^\t\r\n]{2})\t
@otac0n
otac0n / app.js
Last active March 12, 2017 10:42
Bootstrap Modal for EmberJS
App = Ember.Application.create();
App.BootstrapModalView = Ember.View.extend({
classNames: ['modal', 'fade'],
layout: Ember.Handlebars.compile('<div class="modal-dialog"><div class="modal-content">{{yield}}</div></div>'),
didInsertElement: function () {
this._super();
Ember.run.scheduleOnce('afterRender', this, this.afterRenderEvent);
},
afterRenderEvent: function () {
// Copyright (c) 2013, 2014 Masato Hagiwara
// https://github.com/mhagiwara/camxes.js
// Copyright (c) 2018 John Gietzen
// This source is subject to the MIT license. Please see license.md for more information.
// Originally from http://users.digitalkingdom.org/~rlpowell/hobbies/lojban/grammar/index.html
@using System.Linq;
@members
{
private static string _join(IEnumerable<object> items)
{
void Main()
{
GetPassFailRateWithConfidence(10, 2, 0.95).ToString().Dump();
GetPassFailRateWithConfidence(100, 20, 0.95).ToString().Dump();
GetPassFailRateWithConfidence(1000, 200, 0.95).ToString().Dump();
GetPassFailRateWithConfidence(10000, 2000, 0.95).ToString().Dump();
}
public ErrorRate GetPassFailRateWithConfidence(long passes, long fails, double confidence)
{