Skip to content

Instantly share code, notes, and snippets.

View baralong's full-sized avatar

Doug Paice baralong

View GitHub Profile
@baralong
baralong / !react-native-snippets.md
Last active May 28, 2021 03:14
react-native snippets

react-native-snippets

Just some things I found useful in my react-native development.

  • LockToPortrait.ts uses the react-native-orientation plugin and the event in react-navigation-stack
  • TextToFit.tsx a bit of a kludge, reduces font size by a 0.25 until it fits the required size. Uses opacity to hide until it's rendered
@baralong
baralong / bits.zshrc
Created May 12, 2021 03:38
zsh config
ZSH_THEME="kphoen-doug"
(?<=[ .])xx(?=['";]$)
@baralong
baralong / fix mouse scrolling.ps1
Last active May 15, 2020 00:45
Update registry in windows to make the scroll wheel work the way I like it to. Has to be done every time I plug in a new mouse, or an old one into a different port. Then unplug and replug the mouse or log off and on again
Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Enum\HID\*\*\Device` Parameters FlipFlopWheel -EA 0 | ForEach-Object { Set-ItemProperty $_.PSPath FlipFlopWheel 1 }
@baralong
baralong / LinkChildToParent.cs
Created May 16, 2019 07:28
For a DAL POCO with int IDs link a child to a parent
public static class Extensions
{
public static void Link<TParent, TChild>(this TParent parent, TChild child, Expression<Func<TChild, int>> link)
where TParent : HasId
{
if (parent == null || child == null) return;
if (!(link.Body is MemberExpression member)) return;
var propertyInfo = (PropertyInfo)member.Member;
propertyInfo.SetValue(child, parent.Id);
}
@baralong
baralong / aa_init.ps1
Last active July 20, 2023 08:03
Sysinit
Set-ExecutionPolicy Unrestricted -force
# fix Mouse scrolling
Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Enum\HID\*\*\Device` Parameters FlipFlopWheel -EA 0 | ForEach-Object { Set-ItemProperty $_.PSPath FlipFlopWheel 1 }
# Choco install
iex ((new-object net.webclient).DownloadString('https://community.chocolatey.org/install.ps1'))
choco feature enable -n=allowGlobalConfirmation
choco install FiraCode
choco install GoogleChrome
choco install vscode
@baralong
baralong / Index.cshtml
Created October 4, 2013 08:27
A repo for an issue when trying to join a group using SignalR.RabbitMq
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<input type="text" id="msg" />
<a id="broadcast" href="#">Send message</a>
<a id="joingroup" href="#">Join group</a>
@baralong
baralong / Zipping_in_psake.ps1
Created November 21, 2012 04:02
The zip step of my psake build script
task Zip {
Add-Type -Path "$build_dir\ICSharpCode.SharpZipLib.dll"
$fastZip = New-Object icSharpCode.sharpZipLib.zip.FastZip
$fastZip.CreateZip("$build_dir\..\RailOutput.zip", $build_artifacts_dir, $true, $null)
}
@baralong
baralong / NewVersion.cs
Created April 12, 2012 01:58
2 Alternatives for getting an Observable from a Stream
IObservable<string> ObserveStringStream(Stream inputStream)
{
var streamReader = new StreamReader(inputStream);
return ReadLoop(streamReader).ToObservable(Scheduler.ThreadPool);
}
private IEnumerable<string> ReadLoop(StreamReader reader)
{
while (true)
{