Skip to content

Instantly share code, notes, and snippets.

View Deathspike's full-sized avatar

Deathspike

View GitHub Profile
# AdAway Firebase blocklist based on
# https://firebase.google.com/docs/cloud-messaging/concept-options#messaging-ports-and-your-firewall
# For development and testing purposes. Not recommended for actual use.
127.0.0.1 mtalk.google.com
127.0.0.1 mtalk4.google.com
127.0.0.1 mtalk-staging.google.com
127.0.0.1 mtalk-dev.google.com
127.0.0.1 alt1-mtalk.google.com
127.0.0.1 alt2-mtalk.google.com
@Deathspike
Deathspike / AutoScalePanel.cs
Created January 6, 2024 20:14
Avalonia panel that automatically scales content based on MinWidth & MinHeight
using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.Media.Immutable;
namespace Vinodyss
{
public class AutoScalePanel : Panel
{
#region Methods
@Deathspike
Deathspike / Controller.ts
Last active March 28, 2023 08:06
nestjs response validation example (using express)
import * as app from '.';
import * as api from '@nestjs/common';
@api.Controller()
export class TestController {
@api.Get()
@app.ResponseValidator(app.TestDto)
get() {
return new app.TestDto();
}
@Deathspike
Deathspike / deepObserve.ts
Created October 30, 2017 10:14
mobx deep observe
import * as mobx from 'mobx';
export function deepObserve(onChange: () => void, value: any) {
if (value && typeof value === 'object') {
mobx.observe(value, (change: any) => {
onChange();
if (change.added) {
change.added.forEach(deepObserve.bind(null, onChange));
} else if (change.newValue) {
deepObserve(onChange, change.newValue);
public class HomeController : DataController
{
#region Actions
[HttpGet]
public ActionResult Index()
{
return View(Context.Accounts // Using context.
.With(x => x.Identities) // Using includes.
.Where(x => x.AccountType >= AccountType.Administrator)); // Using filters.
@Deathspike
Deathspike / ContextDecorator.cs
Created January 20, 2016 09:09
EF6+ UoW Decorator
public abstract class ContextDecorator : IContext
{
private readonly IContext _context;
#region Constructor
protected ContextDecorator(IContext context)
{
_context = context;
}
@Deathspike
Deathspike / Context.cs
Created January 20, 2016 09:07
EF6+ UoW
public class Context : IContext
{
private readonly Entities _entities; // EF6+ DbContext
#region Constructor
static Context()
{
var ensureReference = SqlProviderServices.Instance;
}
/**
* Extracts the property name from a property expression function.
* @param fn The function.
* @return The property name.
*/
function nameof(fn: Function): string {
var body = fn ? fn.toString() : null;
var lambdaExpression = body ? body.match(/(?:=>|return)\s*(.+?)\s*(?:;|}|$)/) : null;
var propertyExpression = lambdaExpression ? lambdaExpression[1].match(/\.\s*(.+?)\s*$/) : null;
if (propertyExpression != null) {
@Deathspike
Deathspike / Bindable.cs
Created August 24, 2015 08:30
Example of a Bindable in .NET 4.5
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Rs.Os
{
internal abstract class Bindable : IBindable
{
#region Abstract
@Deathspike
Deathspike / Program.cs
Created August 7, 2015 12:43
Super simple and super naive threaded socket server with async/await
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading.Tasks;
namespace Test {
internal class Program {
public static void Main() {
var client = Task.Run(() => Client());