Skip to content

Instantly share code, notes, and snippets.

@AbdybaevAE
AbdybaevAE / App.java
Created May 2, 2022 16:25
Calendar app
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Random;
import javax.swing.JFrame;
import java.awt.Rectangle;
import javax.swing.JComponent;
import java.awt.Graphics2D;
@AbdybaevAE
AbdybaevAE / ts-error-handler.ts
Created August 2, 2020 05:04
ts error handler without throw
export type Either<L, A> = Error<L, A> | Success<L, A>;
export class Error<L, A> {
readonly value: L;
constructor(value: L) {
this.value = value;
}
@AbdybaevAE
AbdybaevAE / change-timezone.md
Created August 2, 2020 05:01
change timezone.md
sudo dpkg-reconfigure tzdata
sudo /etc/init.d/cron stop
sudo /etc/init.d/cron start
@AbdybaevAE
AbdybaevAE / docker-set-timezone.md
Created August 2, 2020 05:01
docker set timezone

set timezones in docker

RUN apk add --no-cache tzdata
ENV TZ=Asia/Almaty
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
@AbdybaevAE
AbdybaevAE / oplog.txt
Created August 2, 2020 05:00
mongodb oplog meaning
4
QUESTION
4
I've seen this question posed before, but the answers were very vague. I have been doing some research on oplog, and am trying to understand exactly how it works. In particular, I want to have a good understanding of the fields in an oplog document and what data they store.
These are the fields I have found through tests and what I think they mean as well as what I am still unsure of:
ts: timestamp of the write operation / oplog entry
h: a unique identifier for the oplog entry (but why is it sometimes positive and sometimes negative?)

Setup redirect on another server

http {
    upstream newmaltabu {
		server 142.93.106.1:443;
	}
    server {
        listen 80 default_server;
        server_name _;
 return 301 https://$host$request_uri;
@AbdybaevAE
AbdybaevAE / my-mongodb.md
Created August 2, 2020 04:58
my mongodb

setup profiling

db.setProfilingLevel(0)

db.system.profile.drop()

db.createCollection( "system.profile", { capped: true, size:4000000 } )

db.setProfilingLevel(1)

INSTALL TELNET INSIDE CONTAINER

apt-get install telnet
telnet 192.168.80.250 6379

TRUNCATE

truncate -s 0 /var/lib/docker/containers/*/*-json.log;
@AbdybaevAE
AbdybaevAE / my-golang.md
Created August 2, 2020 04:56
my golang

#accept several values also acepts array of inputs

func add(args ...int) int {
    total := 0
    for _, v := range args {
        total += v
    }
    return total
}
func main() {
@AbdybaevAE
AbdybaevAE / k8s.md
Created August 2, 2020 04:55
my k8s

copy files to pod

kubectl cp <some-namespace>/<some-pod>:/tmp/foo /tmp/bar

RESTART pod

kubectl scale deployment algorithm --replicas=0 -n dev
kubectl scale deployment algorithm --replicas=1 -n dev