Skip to content

Instantly share code, notes, and snippets.

@steveevers
steveevers / docker-compose.yml
Created Dec 10, 2019
compose file for a self-contained teamcity install that is capable of building dotnet core and angular projects
View docker-compose.yml
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 Aug 23, 2018
A class used to construct REST requests.
View RequestBuilder.cs
using System;
using RestSharp;
namespace Application.Services
{
public class RequestBuilder
{
private IRestRequest request;
#region Static Constructors
@steveevers
steveevers / CustomEditText.cs
Last active Jun 10, 2018
Android: Catch Back Button on EditText
View CustomEditText.cs
using System;
using Android.Content;
using Android.Graphics;
using Android.Util;
using Android.Widget;
namespace MyProject.Droid.Controls
{
public class CustomEditText : EditText
{
View FileUtils.cs
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 Dec 28, 2017
Custom versions of Button, EditText, and TextView for Xamarin.Android that support custom fonts
View CustomButton.cs
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 Nov 15, 2017
Depth first recursive versions of Hash::except
View hash_extensions.rb
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 Nov 15, 2017
From an answer posted here: http://stackoverflow.com/a/20559175 converted to Xamarin.Android
View DocumentHelper.cs
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];