Skip to content

Instantly share code, notes, and snippets.

@brunomlopes
brunomlopes / strings-can-be-datetimes-on-ravendb35.cs
Created July 30, 2023 21:07
This test surfaces an issue on RavenDB 3.5 where strings containing datetimes are converted to datetimes and indexes might fail.
using System;
using System.Linq;
using Raven.Client.Embedded;
using Raven.Client.Indexes;
using Raven.Tests.Helpers;
using Xunit;
namespace TestDateTimeOffsetsInRavenDb35
{
public class Entity
using System.Data.Common;
using System.Threading.Tasks;
using ServiceStack.OrmLite;
using StackExchange.Profiling;
using StackExchange.Profiling.Data;
using Xunit;
public class OrmLiteWithConnectionFactory
{
[Fact]
@brunomlopes
brunomlopes / ConvertTests.cs
Last active June 2, 2022 10:17
Test case for ConvertTo
public class TestConvertTo
{
public TestConvertTo()
{
// Adding this converter resolves the stack overflow, but it's not a generic solution
//IDictionary<string, string> Converter(Dictionary<string, string> input)
//{
// if(input == null) return null;
// return input.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
//}
@brunomlopes
brunomlopes / keymap.c
Last active May 5, 2021 18:53
A remix of the REPEAT key from precondition which allows for numeric repeat. Repeat works on key up, and while pressed, any numbers are counted to repeat. So, press T, then REPEAT,1,0 and it should repeat T 10 times. Currently it's failing at the modifiers
// Used to extract the basic tapping keycode from a dual-role key.
// Example: GET_TAP_KC(MT(MOD_RSFT, KC_E)) == KC_E
#define GET_TAP_KC(dual_role_key) dual_role_key & 0xFF
uint16_t repeat_last_keycode = KC_NO;
uint8_t repeat_last_modifier = 0;
uint8_t repeat_count = 0;
// Initialize variables holding the bitfield
// representation of active modifiers.
@brunomlopes
brunomlopes / parse_keymap.py
Created April 7, 2021 08:50
A quick parser for qmk keymap.c files, and via layouts
# %%
import json,math,itertools
input_file_path = r"C:\Users\bruno\OneDrive\Documents\QMK Via Layouts\sofle bl 2.4.json"
with open(input_file_path) as input:
exported_via_configuration = json.load(input)
layers = exported_via_configuration["layers"]
macros = exported_via_configuration["macros"]
@brunomlopes
brunomlopes / c_cpp_properties.json
Created March 17, 2021 00:06
vscode config for qml_firmware
{
"configurations": [
{
"name": "Mac",
"includePath": [
"/usr/local/Cellar/arm-gcc-bin@8/8-2019-q3-update/arm-none-eabi/include/**",
"/usr/local/Cellar/arm-gcc-bin@8/8-2019-q3-update/lib/gcc/arm-none-eabi/8.3.1/include/**",
"/usr/local/Cellar/arm-gcc-bin@8/8-2019-q3-update/lib/gcc/arm-none-eabi/8.3.1/include-fixed/**",
"/usr/local/Cellar/avr-gcc@8/8.4.0/avr/include/**",
"/usr/local/Cellar/avr-gcc@8/8.4.0/lib/avr-gcc/8/gcc/avr/8.4.0/include/**",
@brunomlopes
brunomlopes / set-random-clipboard.ps1
Last active July 30, 2020 14:20
Copy a random selection of words to the clipboard each second. Used to get random text for testing
$words = @("as","I","his","that","he","was","for","on","are","with","they","be","at","one","have","this","from","by","hot","word",
"but","what","some","is","it","you","or","had","the","of","to","and","a","in","we","can","out","other","were","which","do","their",
"time","if","will","how","said","an","each","tell","does","set","three","want","air","well","also","play","small","end","put","home",
"read","hand","port","large","spell","add","even","land","here","must","big","high","such","follow","act","why","ask","men","change","went",
"light","kind","off","need","house","picture","try","us","again","animal","point","mother","world","near","build","self","earth",
"father","any","new","work","part","take","get","place","made","live","where","after","back","little","only","round","man","year",
"came","show","every","good","me","give","our","under","name","very","through","just","form","sentence","great","think","say","help",
"low","line","differ","turn","cause","much","mean","before","move","right","boy","old","too
@brunomlopes
brunomlopes / python-pluck.py
Last active October 15, 2019 15:03
A hacky pluck function for python, used to flatten data
def pluck(obj, *keys):
def i(o, k):
if "." in k:
(sub, rest) = k.split('.', 1)
if not sub in o:
return None
val = o[sub]
if isinstance(val, list):
return (k, list(i(x, rest)[1] for x in val))
(_, val) = i(val, rest)
@brunomlopes
brunomlopes / keybase.md
Created April 20, 2018 17:35
keybase.md

Keybase proof

I hereby claim:

  • I am brunomlopes on github.
  • I am brunomlopes (https://keybase.io/brunomlopes) on keybase.
  • I have a public key ASDlTIWcOr-fqK6LqiNEYPgQZyRe4Ue-JJzU_0adb_O1Ugo

To claim this, I am signing this object:

@brunomlopes
brunomlopes / scriptedindexresults-unintended-change.cs
Created February 26, 2018 15:56
Scripted index results which update statistics document save floats, but when doc is int, it's marked as a change
public class UnitTest : RavenTestBase
{
[Fact]
public void ALoadShouldNotCauseADocumentToChange()
{
var documentStore = NewDocumentStore(activeBundles:"ScriptedIndexResults");
StoreScriptedIndexDefinition(documentStore);
using (var session = documentStore.OpenSession())