Skip to content

Instantly share code, notes, and snippets.

View RedRoserade's full-sized avatar

André Carvalho RedRoserade

  • Portugal
View GitHub Profile
@RedRoserade
RedRoserade / pt.json
Created August 29, 2011 20:09 — forked from cramforce/de.json
lang.json
{
"locale": "pt",
"text": {
"#authors": [
{
"name": "André Esteves",
"screen-name": "RedRoserade"
}
],
"tweet": {
@RedRoserade
RedRoserade / Todo.cs
Created March 16, 2015 22:17
ASP.NET MVC ModelState validation and Flux. Based heavily off http://fluxxor.com/guides/quick-start.html.
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
namespace ReactFluxModelState.Models
{
public class Todo
{
@RedRoserade
RedRoserade / EnumerableDifference.cs
Created March 24, 2015 21:44
IEnumerable<T> Differ
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace SoftInsa.Link.Web.Extensions
{
public static class IEnumerableExtensions
{
/// <summary>
@RedRoserade
RedRoserade / distict-by.js
Created July 30, 2015 13:48
[ES6] Return distinct items in an iterable by using a specific key selector for equality checking. Only the first item of each key is returned.
function* distinctBy(iterable, keySelector) {
const keys = new Set();
for (const item of iterable) {
const key = keySelector(item);
if (!keys.has(key)) {
keys.add(key);
yield item;
}
@RedRoserade
RedRoserade / ObservableModel.cs
Last active August 29, 2015 14:27
A class that offers a method that will merge the properties of the current object using a dictionary and raise propertychanged events for each item.
public abstract class ObservableModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged = delegate { };
public void Merge(IDictionary<string, object> updates)
{
var selfType = GetType();
foreach (var prop in updates)
{
@RedRoserade
RedRoserade / json-to-swiftyjson.js
Last active October 16, 2016 22:29
JSON to SwiftyJSON-enabled classes
'use strict';
const indentStr = ' ';
const swiftTypeToSwiftyJsonProp = {
'String': 'string',
'Boolean': 'boolean',
'Double': 'double'
}
@RedRoserade
RedRoserade / docker-fedora-33-dns.md
Last active February 15, 2024 14:54
Working around Docker DNS issues on Fedora 33. Adapted from https://stackoverflow.com/a/60113249

Problem

Docker on Fedora 33 has issues with systemd-resolved. This causes DNS issues when, for example, connecting VPNs, because it'll use the wrong DNS server, especially if you have several configured. The one from systemd-resolved is ignored since it's a 127.0.0.X address.

This causes containers to not be able to resolve addresses on the private network (VPN).

Solution

Use dnsmasq to listen on docker0 and forward DNS requests to systemd-resolved running on 127.0.0.53.

@RedRoserade
RedRoserade / README.md
Created January 4, 2022 09:21
Slack on Wayland on Flatpak

As of this post, Slack runs on XWayland by default. This poses an issue on HiDPI displays, where there are noticeable slowdowns.

Running on Wayland is a solution, but there are a couple of things that need addressing:

This should make it boot.

@RedRoserade
RedRoserade / download-results.js
Last active December 10, 2023 13:01
User Script for downloading results from Dirt Rally 2.0 events as CSV
// ==UserScript==
// @name Get Results - dirtgame.com
// @namespace https://github.com/redroserade
// @match https://dirtrally2.dirtgame.com/clubs/club/*
// @grant none
// @version 1.0
// @author https://github.com/redroserade
// @downloadURL https://gist.githubusercontent.com/RedRoserade/5df1b82d0030b91195737ca8fae86a55/raw/37f43f77d25d5b375483edc4cd2a00290d14ba8c/download-results.js
// @description Download results from Dirt Rally 2.0 events as a CSV file
// ==/UserScript==