Skip to content

Instantly share code, notes, and snippets.

View JIghtuse's full-sized avatar

Boris Egorov JIghtuse

View GitHub Profile
@JIghtuse
JIghtuse / echo_server.cxx
Last active July 23, 2023 09:06
echo server (select, C++)
#include <array>
#include <cassert>
#include <iostream>
#include <set>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
@JIghtuse
JIghtuse / main.dart
Created March 14, 2023 09:39
Dart void?
void main() {
int? x = 42;
print(x);
void? v; // compile error
}
@JIghtuse
JIghtuse / stepic-mail-system-main.java
Created October 6, 2016 17:36
Mail System main method
package com.company;
import java.util.logging.*;
public class Main {
public static void main(String[] args) {
Logger logger = Logger.getLogger("main");
@JIghtuse
JIghtuse / insertion_sort.h
Last active April 4, 2022 09:14
Some sort algorithms in modern C++
#pragma once
#include <algorithm>
#include <functional>
template<typename ForwardIt, typename Compare = std::less<>>
void insertion_sort(ForwardIt begin, ForwardIt end, Compare comp = Compare{})
{
if (std::distance(begin, end) < 2) {
return;
}

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@JIghtuse
JIghtuse / swap.cpp
Created September 30, 2015 07:26
traps
// Example from Bjarne Stroustrup's Programming
#include <iostream>
using namespace std;
void swap_v(int a, int b)
{ int temp; temp = a, a = b; b = temp; }
void swap_r(int& a, int& b)
{ int temp; temp = a, a = b; b = temp; }
@JIghtuse
JIghtuse / eval.py
Last active May 11, 2019 12:19
eval
#!/usr/bin/python3
import operator
import re
number_re = re.compile('^\d+')
operator_or_paren = re.compile('^[()+*-/]')
OPERATORS = {'+': (1, operator.add), '-': (1, operator.sub),
'*': (2, operator.mul), '/': (2, operator.truediv)}
@JIghtuse
JIghtuse / model.rs
Last active August 7, 2018 20:35
Rust' Path usage example
use std::path::{Path, PathBuf};
struct Model {
u: f32,
}
fn texture_fname(path: &Path) -> PathBuf {
let fullname = format!("{}{}", path.file_stem().unwrap().to_str().unwrap(), "_diffuse");
let mut buf = PathBuf::from(path);
@JIghtuse
JIghtuse / install_algs4.sh
Last active July 3, 2018 03:58
Installing the Programming Environment for Sedgewick's "Algorithms" on Linux
#!/bin/bash
# Based on http://algs4.cs.princeton.edu/linux/
declare -r ALGS4_DIRECTORY=~/.local/algs4
get_drjava() {
wget http://algs4.cs.princeton.edu/linux/drjava.jar
wget http://algs4.cs.princeton.edu/linux/drjava
chmod 700 drjava
@JIghtuse
JIghtuse / log_parser.cpp
Created July 13, 2017 06:12
HTTP log parser
#include <cctype>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <string>
#include <unordered_map>
#include <queue>
const int kDefaultNumberOfResults = 100;