Skip to content

Instantly share code, notes, and snippets.

@schmohlio
schmohlio / sse.go
Last active August 21, 2024 05:00 — forked from ismasan/sse.go
Example SSE server in Golang
// v2 of the great example of SSE in go by @ismasan.
// includes fixes:
// * infinite loop ending in panic
// * closing a client twice
// * potentially blocked listen() from closing a connection during multiplex step.
package main
import (
"fmt"
"log"
@arebee
arebee / Search-FileIndex.ps1
Last active September 13, 2024 07:17
Use Windows Search from PowerShell
function Search-FileIndex {
<#
.PARAMETER Path
Absoloute or relative path. Has to be in the Search Index for results to be presented.
.PARAMETER Pattern
File name or pattern to search for. Defaults to no values. Aliased to Filter to ergonomically match Get-ChildItem.
.PARAMETER Text
Free text to search for in the files defined by the pattern.
.PARAMETER Recurse
Add the parameter to perform a recursive search. Default is false.
@squiidz
squiidz / btree.c
Last active January 31, 2023 15:22
Btree implementation in C
#include "stdio.h"
#include "stdlib.h"
#define M 3
typedef struct _node {
int n; /* n < M No. of keys in node will always less than order of B tree */
int keys[M - 1]; /*array of keys*/
struct _node *p[M]; /* (n+1 pointers will be in use) */
} node;
@ximik777
ximik777 / print_tree.c
Last active October 10, 2024 07:50
Printing Binary Trees in Ascii
/*
Copy from: http://web.archive.org/web/20090617110918/http://www.openasthra.com/c-tidbits/printing-binary-trees-in-ascii/
Source: http://web.archive.org/web/20071224095835/http://www.openasthra.com:80/wp-content/uploads/2007/12/binary_trees1.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@debnath
debnath / gist:e11de2e10ec36055eda9e446b536874e
Last active June 4, 2024 18:42
Example usage of sync.Map: Store(), Load() and Range()
package main
import (
"fmt"
"sync"
)
func main() {
var wg sync.WaitGroup
var m sync.Map
@miguelmota
miguelmota / pubsub.go
Created October 6, 2018 21:12
Golang redis pub/sub example
package pubsub
import (
"github.com/garyburd/redigo/redis"
log "github.com/sirupsen/logrus"
)
// Service service
type Service struct {
pool *redis.Pool
@thiagozs
thiagozs / gomock.md
Last active May 11, 2025 14:44
Tutorial gomock

08/16/17 by  Sergey Grebenshchikov

No Comments

This is a quick tutorial on how to test code using the GoMock mocking library and the standard library testing package testing.

GoMock is a mock framework for Go. It enjoys a somewhat official status as part of the github.com/golang organization, integrates well with the built-in testing package, and provides a flexible expectation API.

@kassane
kassane / Event_Loop.md
Created April 6, 2019 14:26
Explain Event Loop

Event Loop

In computer science, the event loop, message dispatcher, message loop, message pump, or run loop is a programming construct that waits for and dispatches events or messages in a program.

It works by making a request to some internal or external "event provider" (that generally blocks the request until an event has arrived), and then it calls the relevant event handler ("dispatches the event").

The event-loop may be used in conjunction with a reactor, if the event provider follows the file interface, which can be selected or 'polled' (the Unix system call, not actual polling).

The event loop almost always operates asynchronously with the message originator.

@musteresel
musteresel / Coop-Scheduler README
Last active December 19, 2024 04:08
Cooperative multitasking / green threads in C; MIT licence and let me know with a comment if you're using this
How to build on an x86-64 linux system:
nasm -f elf64 hal.s
gcc -Wall -Wextra -c coop-sched.c
gcc -o tryit *.o
./tryit
There's still one bug, more in the comments of the source file(s)!
//
// main.cpp
// NeuralNetwork
//
// Created by Santiago Becerra on 9/15/19.
// Copyright © 2019 Santiago Becerra. All rights reserved.
//
//
#include <iostream>