Skip to content

Instantly share code, notes, and snippets.

@steveevers
steveevers / docker-compose.yml
Created December 10, 2019 06:36
compose file for a self-contained teamcity install that is capable of building dotnet core and angular projects
version: '3.7'
services:
teamcity-server:
container_name: teamcity
image: jetbrains/teamcity-server
restart: unless-stopped
ports:
- "8111:8111"
volumes:
- ./data_dir:/data/teamcity_server/datadir
@steveevers
steveevers / RequestBuilder.cs
Created August 23, 2018 05:42
A class used to construct REST requests.
using System;
using RestSharp;
namespace Application.Services
{
public class RequestBuilder
{
private IRestRequest request;
#region Static Constructors
@steveevers
steveevers / CustomEditText.cs
Last active June 10, 2018 19:35
Android: Catch Back Button on EditText
using System;
using Android.Content;
using Android.Graphics;
using Android.Util;
using Android.Widget;
namespace MyProject.Droid.Controls
{
public class CustomEditText : EditText
{
using System.IO;
using System.IO.MemoryMappedFiles;
public static class FileUtils
{
public static string MapAndRead(string processIdPath) {
using (var f = new FileStream(processIdPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var m = MemoryMappedFile.CreateFromFile(f, null, 0, MemoryMappedFileAccess.Read, null, HandleInheritability.None, true))
using (var s = m.CreateViewStream(0, 0, MemoryMappedFileAccess.Read))
using (var r = new StreamReader(s)) {
@steveevers
steveevers / CustomButton.cs
Created December 28, 2017 00:37
Custom versions of Button, EditText, and TextView for Xamarin.Android that support custom fonts
using System;
using Android.Content;
using Android.Graphics;
using Android.Util;
using Android.Widget;
namespace MyProject.Droid.Controls
{
public class CustomButton : Button
{
@steveevers
steveevers / hash_extensions.rb
Created November 15, 2017 18:59
Depth first recursive versions of Hash::except
class Hash
def except_nested(key)
r = Marshal.load(Marshal.dump(self))
r.except_nested!(key)
end
def except_nested!(key)
self.except!(key)
self.each do |_, v|
v.except_nested!(key) if v.is_a?(Hash)
@steveevers
steveevers / DocumentHelper.cs
Last active November 15, 2017 22:53
From an answer posted here: http://stackoverflow.com/a/20559175 converted to Xamarin.Android
public static class DocumentHelper {
public static string GetPathToFile(Context context, Android.Net.Uri uri) {
bool isKitkat = Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat;
if (isKitkat && DocumentsContract.IsDocumentUri(context, uri)) {
if (uri.IsExternalStorageDocument()) {
var parts = DocumentsContract.GetDocumentId(uri).Split(':');
var type = parts[0];
var name = parts[1];