This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Port | |
interface NotificationService { | |
// rejects to errored state | |
sendEmail(to: string, body: IEmailBody): Promise<IEmailSuccess> | |
sendPush(deviceToken: string, body: IPushBody): Promise<IPushSuccess> | |
} | |
// Adapter | |
class TwilioService { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::collections::HashMap; | |
use std::io::{self, Read, Write}; | |
use std::net::SocketAddr; | |
use mio::net::{TcpListener, TcpStream}; | |
use mio::{Events, Interest, Poll, Token}; | |
use crossbeam_channel::{unbounded, Sender, Receiver}; | |
use std::thread; | |
use std::time::Duration; | |
const SERVER: Token = Token(0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::collections::HashMap; | |
use std::io; | |
use std::io::{Read, Write}; | |
use std::net::{SocketAddr}; | |
use mio::{Events, Interest, Poll, Token}; | |
use mio::event::Source; | |
use mio::net::{TcpListener, TcpStream}; | |
/* | |
Checks for /r/n/r/n in a window of 4 bytes in the request header |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How to use: | |
// 1. In VS Code, perform a search. | |
// 2. Click "Open in editor" to open the search results in a `.code-search` file | |
// 3. Save the file | |
// 4. In terminal, run `node export-vscode-search-to-csv.js path/to/results.code-search path/to/exported.csv` | |
const fs = require("fs"); | |
const path = require("path"); | |
const readline = require("readline"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module({ | |
imports: [ | |
GraphQLModule.forRootAsync<ApolloGatewayDriverConfig>({ | |
driver: ApolloGatewayDriver, | |
useFactory: async () => ({ | |
server: { | |
path: '/graphql', | |
cors: true | |
}, | |
gateway: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh | |
chmod +x ~/Downloads/Miniforge3-MacOSX-arm64.sh | |
sh ~/Downloads/Miniforge3-MacOSX-arm64.sh | |
source ~/miniforge3/bin/activate | |
conda install -c apple tensorflow-deps | |
python -m pip install tensorflow-macos | |
python -m pip install tensorflow-metal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
start := time.Now() | |
var t *time.Timer | |
t = time.AfterFunc(randomDuration(), func() { | |
fmt.Println(time.Now().Sub(start)) | |
t.Reset(randomDuration()) | |
}) | |
time.Sleep(5 * time.Second) | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
// we need a webserver to get the pprof webserver | |
go func() { | |
log.Println(http.ListenAndServe("localhost:6060", nil)) | |
}() | |
fmt.Println("hello world") | |
var wg sync.WaitGroup | |
wg.Add(1) | |
go leakyFunction(wg) | |
wg.Wait() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package demo | |
import "testing" | |
func TestConvertCelciusToF(t *testing.T) { | |
type args struct { | |
c float64 | |
} | |
tests := []struct { | |
name string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package router | |
import ( | |
"fmt" | |
"time" | |
) | |
func UpdateDatabaseAndElasticSearch(ctx context.Context, doc *Doctor) error { | |
// make channel for communication from Go routines | |
channel := make(chan error, 2) |
NewerOlder