Skip to content

Instantly share code, notes, and snippets.

View write_into_file.go
file, err := os.Create("output.txt")
if err != nil {
log.Fatalf("Failed to create file: %s", err)
}
defer file.Close()
for key, value := range files {
line := fmt.Sprintf("%s: %s\n", key, value)
_, err := file.WriteString(line)
if err != nil {
@kirillshevch
kirillshevch / telegram_animated_sticker_ffmpeg.md
Last active April 29, 2023 11:40
How to convert video into Telegram Animated Sticker with FFmpeg (WEBM)
View telegram_animated_sticker_ffmpeg.md
View alex.js
(() => {
// config:
const likea = true // like all (skip next two if true)
const tsize = 128 // minimal amount of letters in bio
const regex = /no fwb/i // dislike if found
const likes = 1000 // maximal likes per run
const speed = 1 // timeout to let it be preloaded
const timeo = 51 // timeout to let bio be loaded
const msgtm = 200 // timeout on match
// ^
View state_pattern.rb
# State interface
class TrafficLightState
def change_state(_traffic_light)
raise 'This method should be implemented in a subclass'
end
def display_color
raise 'This method should be implemented in a subclass'
end
end
View review.pb.go
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v3.19.4
// source: review.proto
package storage
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
View main.go
package main
import (
"context"
"fmt"
"protobuftest/storage"
"github.com/go-redis/redis/v8"
"google.golang.org/protobuf/proto"
)
View main.go
package main
import (
"context"
"fmt"
"github.com/go-redis/redis/v8"
)
func main() {
View signal_trap.rb
class App
attr_reader :queue
def initialize
@queue = []
end
def call
puts "App PID: #{Process.pid}"
publish
View signal_exception.rb
class App
attr_reader :queue
def initialize
@queue = []
end
def call
puts "App PID: #{Process.pid}"
publish
View retry.rb
class SomeClass
# ...
def execute
api_client.get(id)
rescue StandardError => e
@retries = @retries + 1
retries > RETRY_LIMIT ? raise(e) : retry
end