Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
SVN="svn/trunk"
MASTER="master"
die() { echo "$@" >&2; exit 1; }
ensure_clean()
{
if ! git diff --no-ext-diff --ignore-submodules --quiet --exit-code; then
@canton7
canton7 / SingleAccessTaskScheduler.cs
Created January 19, 2014 12:23
TaskScheduler to allow single-thread access to some resource, while allowing inlining if possible
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace TaskSchedulerTest
{
/// <summary>
@canton7
canton7 / gist:1268587
Last active October 18, 2016 19:40
git merge -s theirs

How to do a git merge -s theirs

One way of many...

This is one way which keeps the history looking like you'd expect.

Command is equivalent to git checkout MINE; git merge -s theirs HERS.

  1. Pootle: Self-hosted. Slightly annoying to get set up, seems to work thereafter. Uses a command-line tool to upload/download translations. Didn't evaluate too much.
  2. Weblate: Self-hosted offshoot of Pootle. Very annoying to set up. Seems to have a nicer interface but wants to integrate directly with your VCS - no command-line tooling. The VCS integration adds a lot of complexity. Didn't evaluate too much.
  3. Zanata: Self-hosted, easy to set up. Poor access controls - geared towards open collaboration. Command-line tool. Nice interface.
  4. POEditor: Paid hosting, with a free tier. No command-line tool as far as I can see.
  5. CrowdIn: Paid hosting, free for open source. Very nice interface, good API and command-line tooling. Good GitHub integration. This is the one we went for.
using System;
using System.Windows.Data;
using System.Windows.Markup;
namespace LocalizationDemo.Localization
{
public class LocExtension : MarkupExtension
{
/// <summary>
/// Gets or sets the key to use to look up the appropriate value to display.
namespace RestEaseSampleApplication
{
// We receive a JSON response, so define a class to deserialize the json into
public class User
{
public string Name { get; set; }
public string Blog { get; set; }
// This is deserialized using Json.NET, so use attributes as necessary
[JsonProperty("created_at")]
/// <summary>
/// Extensions on TreeViews allowing users to bind to the SelectedItem property
/// </summary>
/// <remarks>
/// The trick used to detect when the binding has occurred means that there are some cases it doesn't handle - but I don't
/// recall what.
/// </remarks>
public static class TreeViewExtensions
{
private static readonly object initialBindingTarget = new object();
@canton7
canton7 / AtomicFileStream.cs
Last active February 23, 2018 23:03
An attempt to allowing atomic file writes on windows
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace FilesystemUtils
{
public class AtomicFileStream : FileStream
{
private const int DefaultBufferSize = 4096;
private const string DefaultTempFileSuffix = ".tmp";
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Serialization;
namespace ConfigManager
{
public class ConfigManager : IDisposable
{
public class Foo : IEquatable<Foo>
{
public int Bar { get; set; }
public int Baz { get; set; }
public override bool Equals(object obj)
{
return this.Equals(obj as Foo);
}