Skip to content

Instantly share code, notes, and snippets.

@beobab
beobab / combinations.playground
Created August 7, 2017 19:53
Convert an array of characters into all matching triplets
let a: Array<Character> = ["A","B","C","D","E","F"];
let x = allCombos(a: a);
for y in x {
print (y);
}
// Gets all the combinations which start with the first item in the array.
func firstItemCombo(a: Array<Any>) -> Array<Array<Any>> {
var lst: Array<Array<Any>> = [];

Keybase proof

I hereby claim:

  • I am beobab on github.
  • I am toolan (https://keybase.io/toolan) on keybase.
  • I have a public key ASDAL6BNZqQF9Fzh9JKP9jXKPwUh5I5ATq3hXgf6J8mvyQo

To claim this, I am signing this object:

@beobab
beobab / manglePOFile.cs
Created November 23, 2016 14:00
This snippet will mangle a PO file (for translations), replacing the id AbcdefG with the msgstr !AfedcbG! It makes it look vaguely similar, but totally different.
private void button1_Click(object sender, EventArgs e)
{
var fi = new FileInfo(txtFile.Text);
if (!fi.Exists) return;
var sb = new StringBuilder();
var lines = File.ReadAllLines(fi.FullName);
// repeatedly:
string msgid = null;
@beobab
beobab / Command.ToText.cs
Created March 9, 2015 16:27
Convert SQLCommand to text which SQL Management Studio (SSMS) can execute.
public static class DBExtensions
{
public static string ToText(this SqlCommand cmd) { return cmd.ToText(true); }
public static string ToText(this SqlCommand cmd, bool includeParameters)
{
var sb = new StringBuilder();
try
{
if (cmd != null)
{