Skip to content

Instantly share code, notes, and snippets.

@jbachelor
jbachelor / .bash_profile
Last active March 23, 2021 15:22
bash_profile & zshrc as of 2021.03.23
# Aliases
alias cdt='cd /Users/Shared/src/TubeBuddy'
alias cds='cd /Users/Shared/src'
alias la='ls -la'
alias gs='git status'
alias gp='git pull'
alias gf='git fetch'
alias bb='cd ../..'
alias gc='git checkout'
alias ..='cd ..'
@jbachelor
jbachelor / FixedCapacityStringBuilderAppending.cs
Created January 15, 2021 19:37
Quick method (and test) to add strings to a StringBuilder of a set capacity, removing the oldest characters if necessary.
[Test]
public void BuildAHugeString()
{
// arrange
var repeatedString = "**** Hello there! I am log statement number";
var loops = 20000;
var stringBuilderFixedCapacity = 200000;
int lastLogNumber = -1;
var hugeStringBuilder = new StringBuilder(stringBuilderFixedCapacity, stringBuilderFixedCapacity);
bool testLengthExceededFixedCapacity = false;
@jbachelor
jbachelor / AkavacheWrapper.cs
Last active September 4, 2020 19:07
Fledgling and faulty attempt at unit testing an Akavache call, followed by creating a wrapper class to allow easy unit testing. Yay!
using System;
using Akavache;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reactive.Linq;
using System.Threading.Tasks;
namespace MyCoolApp.Services
{
sudo rm -rf "/Applications/Visual Studio.app"
rm -rf ~/Library/Caches/VisualStudio
rm -rf ~/Library/Preferences/VisualStudio
rm -rf ~/Library/Preferences/Visual\ Studio
rm -rf ~/Library/Logs/VisualStudio
rm -rf ~/Library/VisualStudio
rm -rf ~/Library/Preferences/Xamarin/
rm -rf ~/Library/Application\ Support/VisualStudio
rm -rf ~/Library/Application\ Support/VisualStudio/7.0/LocalInstall/Addins/

Should Xamarin.Android/Resources/Resource.designer.cs be in source control?

All I have to do is open up a Xamarin.Forms solution file and build, and I typically see a huge number of changes to the Xamarin.Android/Resources/Resource.designer.cs file. The same occurs for other developers on my team. If we are each working on a feature branch of our own, this can easily lead to merge conflicts in this Resources/Resource.designer.cs file. As an auto-generated file, should this file even be in source control?

Here are the data points I've gathered so far:

  • An ancient Bugzilla report from 2011 where a user suggests keeping Resources.Resource.designer.cs out of source control... But the bug was closed without any action.
    • Note that the last response (in 2012) mentions that developers can add this to their .gitignore file if they like. Does this indicate there would be no problem in doing so? It sounds like it.
  • I found a [more
@jbachelor
jbachelor / Install_iOS_ipa.sh
Last active July 7, 2020 23:26
Bash script to install an existing iOS ipa file onto an attached iOS device
#! /bin/bash
# PREREQUISITES:
# - You've already built the iOS app using a build configuration called "Debug":
# - https://docs.microsoft.com/en-us/xamarin/ios/deploy-test/app-distribution/ipa-support?tabs=macos
# - You have the libimobiledevice tool installed:
# - https://github.com/libimobiledevice/libimobiledevice
# - https://formulae.brew.sh/formula/ideviceinstaller
# - https://libimobiledevice.org/
@jbachelor
jbachelor / TaskDotRun_ToAwait_OrNot_ToAwait.cs
Last active April 30, 2020 15:37
Quick nunit test demonstrating behavior in `await Task.Run` vs. just `Task.Run`
[Test]
public async Task TaskDotRunTestAsync()
{
var timer = new Stopwatch();
Console.WriteLine($"**** {this.GetType().Name}.{nameof(TaskDotRunTestAsync)}: Beginning test ({timer.ElapsedMilliseconds}ms)");
timer.Start();
try
{
Console.WriteLine($"**** {this.GetType().Name}.{nameof(TaskDotRunTestAsync)}: About to start Task.Run ({timer.ElapsedMilliseconds}ms)");
// Run this test twice... Once with the await on the following line, once without.
@jbachelor
jbachelor / ISettingsAppLauncher.cs
Created April 14, 2020 16:38
Open app settings on iOS/Android using a Dependency Service
namespace MyCoolMobileApp.Services.DependencyServices
{
public interface ISettingsAppLauncher
{
void LaunchSettingsApp(string appBundleId);
}
}
@jbachelor
jbachelor / Android_Using_Xamarin_Essentials.cs
Last active April 22, 2020 15:30
Open app settings on Android and iOS from Xamarin.Forms app, using Xamarin.Essentials
bool didOpenUri = await Xamarin.Essentials.Launcher.TryOpenAsync("?????????????????");