Skip to content

Instantly share code, notes, and snippets.

View shelomentsevd's full-sized avatar
🧶
<- my code

Dmitrii Shelomentsev shelomentsevd

🧶
<- my code
View GitHub Profile
var arr = [
{
'name': 'Paul',
'salary': '5 000$'
},
{
'name': 'Jessica',
'salary': '6 000$'
},
{
@shelomentsevd
shelomentsevd / sieve_of_eratosthenes.py
Created December 1, 2016 14:45
Python implementation of Sieve of Eratosthenes algorithm
# Python implementation of Sieve of Erathosthenes algorithm for prime number search
# Description here: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
N = 10000
p = 2
numbers = range(p, N + 1)
pIndex = 0
while p*p < N:
i = p
while i*p < N + 1:
n_i = i*p
@shelomentsevd
shelomentsevd / exceptions.cpp
Last active February 11, 2017 19:59
Short note about exceptions in C++
// C++ exceptions short-note
// Example
#include <exception>
class MyException: public std::exception
{
virtual const char * what() const throw()
{
return "Exception's description";
}
};
@shelomentsevd
shelomentsevd / noexcept.cpp
Created February 12, 2017 16:21
Пытаюсь разобраться что делает noexcept
// g++ main.cpp -o main -std=c++11
#include <iostream>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <ctime>
const size_t cKeyLength = 100;
// expecting exceptions
#include<iostream>
#include<list>
#include<vector>
#include<random>
#include<chrono>
#include<algorithm>
using namespace std;
int main()
import os
from os import listdir
from os.path import dirname, realpath, isfile, isdir, isabs, join
def get_filenames(path):
if isabs(path):
dir_path = path
else:
dir_path = join( dirname(realpath(__file__)), path )
package main
import (
"os"
"os/signal"
"syscall"
"fmt"
"time"
"reflect"
"mtproto"
type Store struct {
mutex sync.RWMutex
data map[string]int
}
func (s * Store) Read(key string) int, error {
// ...
defer s.mutex.RUnlock()
s.mutex.RLock()
// ...
package main
import (
"sync/atomic"
"fmt"
)
type Increment struct {
count uint32
}
@shelomentsevd
shelomentsevd / file.go
Created November 28, 2017 15:47
Go Fuckup #1 appending to slice
package main
import "fmt"
type Box struct {
ID string
}
type BoxContainter struct {
box Box