Skip to content

Instantly share code, notes, and snippets.

View tcortega's full-sized avatar

Tarcisio tcortega

  • Brazil
  • 02:13 (UTC -03:00)
View GitHub Profile
@tcortega
tcortega / http.go
Created March 5, 2024 06:42
manually create conn with an http proxy in go
func (p *Proxy) GetHttpImapConnection(imapServer string) (net.Conn, error) {
proxyAddr := p.IpAddress + ":" + strconv.Itoa(p.Port)
conn, err := net.Dial("tcp", proxyAddr)
if err != nil {
return nil, err
}
request := "CONNECT " + imapServer + " HTTP/1.1\r\nHost: " + imapServer + "\r\n"
if p.HasCredentials() {
credentials := p.GetEncodedCredentials()
%{
const symbols = {};
let currentScope = 0;
let nextScope = 1;
let lastType = null;
function enterScope() {
currentScope = nextScope;
nextScope++;
}
%{
const symbols = {};
let currentScope = 0;
let nextScope = 1;
let lastType = null;
function enterScope() {
currentScope = nextScope;
nextScope++;
}
var input = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 21, 22, 23 };
var list = new List<int>(input);
foreach (var n in input)
{
var actualIndex = list.IndexOf(n);
var foundIndex = FindAt(input, n, 0, input.Length - 1);
Console.WriteLine($"[{n}] Expected: {actualIndex} | Found: {foundIndex}");
}
@tcortega
tcortega / CheckedOverflowChecks.cs
Last active October 31, 2023 01:07
TimeSpan overflow checks
public sealed class CheckedOverflowChecks : TimeSpanOverflowChecksContext
{
public static TimeSpan Interval(int days = 0, int hours = 0, long minutes = 0, long seconds = 0,
long milliseconds = 0, long microseconds = 0)
{
try
{
long ticks = checked((long)days * TicksPerDay
+ (long)hours * TicksPerDay
+ minutes * TicksPerMinute
[RegisterSingleton]
public class LabelEngine
{
private readonly ILogger _logger;
private readonly Timer _timer;
private readonly AsyncReaderWriterLock _lock = new();
private IBrowser _browser = null!;
private readonly string _browserPath;
public LabelEngine(ILogger logger, IOptions<LabelEngineOptions> options)
@tcortega
tcortega / cidades.json
Created September 18, 2023 16:28
Algumas cidades do ES, suas posições, vizinhos e distâncias
[
{
"nome": "Afonso Cláudio",
"latitude": -20.0778,
"longitude": -41.1261,
"vizinhos": [
{
"nome": "Itarana",
"distancia": 34.54
},
@tcortega
tcortega / cssbuy-fixes.js
Created June 4, 2023 22:17
correções pro cssbuy
// ==UserScript==
// @name CSSBuy Fixes
// @namespace https://tcortega.com/
// @version 0.1
// @description Melhora o carregamento de imagens do CSSBuy
// @author tcortega
// @match https://www.cssbuy.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=cssbuy.com
// @grant none
// ==/UserScript==
@tcortega
tcortega / geoguessr-aio.user.js
Last active December 19, 2022 19:03
Geoguessr AIO Cheat (Greasemonkey / Tampermonkey)
// ==UserScript==
// @name Geoguessr AIO Cheat
// @namespace https://github.com/tcortega
// @version 1.0.1
// @description Press SHIFT + ALT + G and the location of your current geoguessr game will open in a new tab
// @author tcortega
// @homepage https://github.com/tcortega
// @downloadURL https://gist.github.com/tcortega/7378d20dcfa7d15df780032ca2b78b3d/raw/geoguessr-aio.user.js
// @updateURL https://gist.github.com/tcortega/7378d20dcfa7d15df780032ca2b78b3d/raw/geoguessr-aio.user.js
// @match http*://*/*