Skip to content

Instantly share code, notes, and snippets.

View JIghtuse's full-sized avatar

Boris Egorov JIghtuse

View GitHub Profile
@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 / pre-commit
Last active September 7, 2016 06:13
git-hook-cppcheck-xmllint
#!/bin/sh
# Usage: add this file to your project's .git/hooks directory. Rename it to
# just 'pre-commit' and make it executable.
# Now, when you change some files in repository and try to commit these
# changes, git will run this script right before commit.
#
# This script checks:
# C/C++ files with cppcheck
# XML files with xmllint
@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>
#include <stdio.h>
void f()
{
char s[8] = "";
snprintf(s, sizeof(s), "ip");
}
@JIghtuse
JIghtuse / TIL.md
Last active February 24, 2016 16:48
TIL C++

TIL C++

2015-02-24 Checked STL

Compiling with

-D_GLIBCXX_DEBUG

Helps to detect various bugs with iterators and other horrible stuff.

@JIghtuse
JIghtuse / money.cxx
Created January 28, 2016 11:38
std::get_money
#include <iomanip>
#include <iostream>
#include <locale>
using namespace std;
int main ()
{
istream& work{cin};
cout.imbue(locale("ru_RU.utf8"));
@JIghtuse
JIghtuse / is_pod.cpp
Created January 22, 2016 15:20
Determine if structure is a POD
#include <iostream>
#include <type_traits>
using std::cout;
struct Complex
{
float real;
float imag;
};
@JIghtuse
JIghtuse / cppcheck_syntax.cpp
Created December 28, 2015 16:11
cppcheck syntax error
int a;
void fn1(int = {}) {
for (int i; i < a;)
;
}
@JIghtuse
JIghtuse / modules
Created December 25, 2015 10:26
modules
$ tree
.
├── Cargo.lock
├── Cargo.toml
├── src
│   ├── foo
│   │   └── mod.rs
│   ├── lib.rs
│   └── main.rs
└── tests
@JIghtuse
JIghtuse / cppcheck_crash.log
Last active December 23, 2015 06:52
Cppcheck crash
$ gdb $CPPCHECK
Reading symbols from /home/user/projects/cppcheck/cppcheck...done.
(gdb) r lib/SILGen/ArgumentSource.cpp
Starting program: /home/user/projects/cppcheck/cppcheck lib/SILGen/ArgumentSource.cpp
Checking lib/SILGen/ArgumentSource.cpp...
Program received signal SIGSEGV, Segmentation fault.
0x00000000009f2268 in valueFlowSwitchVariable (tokenlist=0x7fffffffbd10, symboldatabase=0xef6c80, errorLogger=0x7fffffffd010, settings=0x7fffffffd048) at lib/valueflow.cpp:2173
2173 valueFlowForward(tok, vartok->variable()->scope()->classEnd, vartok->variable(), vartok->varId(), values, false, tokenlist, errorLogger, settings);
Missing separate debuginfos, use: dnf debuginfo-install libgcc-5.3.1-2.fc23.x86_64 libstdc++-5.3.1-2.fc23.x86_64