Skip to content

Instantly share code, notes, and snippets.

View gozeloglu's full-sized avatar
🎯
Focusing

Gökhan Özeloğlu gozeloglu

🎯
Focusing
View GitHub Profile
@sancar
sancar / README.md
Last active April 22, 2024 16:15
An upgradable read write lock for go

And upgradable read write lock for go

UpgradableRWMutex is an enhanced version of the standard sync.RWMutex. It has the all methods sync.RWMutex with exact same semantics. It gives more methods to give upgradable-read feature.

The new semantics for upgradable-read are as follows:

  • Multiple goroutines can get read-lock together with a single upgradable-read-lock.
  • Only one goroutine can have a write-lock and no read-lock/upgradable-read-lock can be acquired in this state.
@prnvbn
prnvbn / background.go
Created August 13, 2021 08:33
A task running periodically in the background in Golang.
ticker := time.NewTicker(70 * time.Second)
quit := make(chan struct{})
go func() {
for {
select {
case <-ticker.C:
// do the task here
case <-quit:
ticker.Stop()
return
@selcukcihan
selcukcihan / aws-certification-cheat-sheet.md
Created June 10, 2020 11:34
Cheat sheet for aws certification exams.

S3

  • By default all new buckets are private
  • You can have bucket policies and ACLs (ACL can go down to individual objects)
  • Read after write consistency for puts of new objects
  • Eventual consistency for overwrite PUTs and DELETEs
  • Storage classes
    • S3 standard (99.99 availability, 11 9s durability) can sustain loss of 2 facilities concurrently
    • S3-IA lower fee than S3 but you are charged a retrieval fee (99.9% availability)
    • S3 One Zone - IA lower cost option if you don't need multi AZ data resilience (99.5% availability)
  • S3 Intelligent Tiering
@003random
003random / cert_info.go
Last active March 20, 2024 15:05
Prints SSL certificate info from a given URL. Including the encoded public key and cert itself
package main
import (
"fmt"
"os"
"bytes"
"encoding/pem"
"crypto/tls"
"crypto/x509"
)
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
" -----------------------------
" IMPORTANT:
" Keep Plugin commands between vundle#begin/end.
#Import needed packages
import torch
import torch.nn as nn
from torchvision.datasets import CIFAR10
from torchvision.transforms import transforms
from torch.utils.data import DataLoader
from torch.optim import Adam
from torch.autograd import Variable
import numpy as np
@cijogeorge
cijogeorge / trie.md
Created November 11, 2017 17:58
Trie Data Structure Implementation in C

Trie Data Structure Implementation in C

Note: This piece of code was written and tested in 2008.

#include<stdio.h>
#include<stdlib.h>
struct trie
{
 struct trie *alpha[26];
@mdonkers
mdonkers / server.py
Last active April 30, 2024 23:26
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
License: MIT License
Copyright (c) 2023 Miel Donkers
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
@laobubu
laobubu / ABOUT.md
Last active March 23, 2024 05:28
A very simple HTTP server in C, for Unix, using fork()

Pico HTTP Server in C

This is a very simple HTTP server for Unix, using fork(). It's very easy to use

How to use

  1. include header httpd.h
  2. write your route method, handling requests.
  3. call serve_forever("12913") to start serving on port 12913
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.