Skip to content

Instantly share code, notes, and snippets.

@mariano
mariano / RedisQueue.cs
Created March 12, 2021 18:32
RedisQueue.cs
using Microsoft.Extensions.Logging;
using StackExchange.Redis;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
@mariano
mariano / windows_terminal_disable_mouse_wheel_zoom.diff
Last active July 23, 2020 18:23
Add profile setting `disableMouseWheelZoom` to disable zooming while hitting CTRL and using mouse wheel, performing a normal scroll if setting enabled
diff --git a/src/cascadia/TerminalApp/Profile.cpp b/src/cascadia/TerminalApp/Profile.cpp
index 7cd80a65..0c815b29 100644
--- a/src/cascadia/TerminalApp/Profile.cpp
+++ b/src/cascadia/TerminalApp/Profile.cpp
@@ -53,6 +53,8 @@ static constexpr std::string_view BackgroundImageAlignmentKey{ "backgroundImageA
static constexpr std::string_view RetroTerminalEffectKey{ "experimental.retroTerminalEffect" };
static constexpr std::string_view AntialiasingModeKey{ "antialiasingMode" };
+static constexpr std::string_view DisableMouseWheelZoomKey{ "disableMouseWheelZoom" };
+
@mariano
mariano / bytecodes.js
Last active October 15, 2019 21:26
Seppo's bytecodes
function work_map(arr) {
return arr.map((item, index, array) => [item, array[index + 1]]);
}
function work_nat_mem(arr) {
var res = new Array(arr.length - 1);
for (i=0, j=0; i < arr.length; i++) {
res[i] = [arr[i], arr[i+1]];
}
return res;
}
$inputFile = Mockery::mock(SplFileObject::class, ["php://memory"]);
$inputFile->shouldReceive("setMaxLineLen")
->with(Csv::MAXIMUM_LINE_LENGTH)
->once()
->shouldReceive("eof")
->with()
->andReturn(false)
->once()
->shouldReceive("fgets")
->with()
@mariano
mariano / yielder.php
Last active August 29, 2015 14:15
Is this the only way to extend a method that yields? Yielding each element provided by the parent?
<?php
/**
* Obviously this is not real code. Otherwise one could
* just simply override $multiplier. It is meant to ask
* if the only way to extend the logic of a generator
* is re-yielding the yielded elements.
**/
class Yielder
{
protected $multiplier = 1;

Keybase proof

I hereby claim:

  • I am mariano on github.
  • I am mgiglesias (https://keybase.io/mgiglesias) on keybase.
  • I have a public key whose fingerprint is FEEF 2DDD 15B1 2943 188F 0C4B 74AE DDA1 7CB7 9CCD

To claim this, I am signing this object:

@mariano
mariano / export_countries_time_zones.php
Created February 28, 2012 16:16
Export ISO 3166-1 country codes and PHP time zones per countries
<?php
$contents = trim(file_get_contents('http://www.iso.org/iso/list-en1-semic-3.txt'));
if (empty($contents)) {
throw new \Exception('Could not get list of ISO country codes from iso.org');
}
$countries = array();
$timeZones = array();
foreach(explode(PHP_EOL, $contents) as $line) {
if (preg_match('/^(.+?);([A-Za-z]{2})$/', trim($line), $matches)) {
$code = $matches[2];