Skip to content

Instantly share code, notes, and snippets.


Doug Ilijev dilijev

View GitHub Profile
dilijev /
Created Sep 13, 2014
Python Batch File Renamer
import re, glob, os
def renamer(files, pattern, replacement):
for pathname in glob.glob(files):
basename= os.path.basename(pathname)
new_filename= re.sub(pattern, replacement, basename)
if new_filename != basename:
os.path.join(os.path.dirname(pathname), new_filename))
dilijev / test.cpp
Created Sep 2, 2012
My solution to Sphere's TEST problem.
View test.cpp
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main() {
string str;
while(cin>>str) {
if(!"42")) break;
dilijev / .bashrc
Created Sep 10, 2012
Snippet from my .bashrc that shows my current colorful prompt.
View .bashrc
source ~/.bash_colors
PS1="${RED}\t ${GREEN}${debian_chroot:+($debian_chroot)}\u@\h${NORMAL}:${BRIGHT_BLUE}\w${NORMAL}\$ "
dilijev / const1.cpp
Created Oct 7, 2012
Snippet from a file, playing with constants.
View const1.cpp
int i1 = 111;
int i2 = 222;
int i3 = 333;
int i4 = 444;
// Neither the data nor the pointer are const
int* a = &i1;
// Constant data, non-constant pointer
const int* b = &i2;
dilijev / interview1.cpp
Created Oct 7, 2012
const ptr and const data
View interview1.cpp
const int* const * ptr;
dilijev / const3.cpp
Created Oct 7, 2012
legal and illegal const expressions with pointers
View const3.cpp
int n = 42;
const int* const a = &n;
int const* const b = a; // same type as a
// const int const * c = b; // "error: duplicate const"
dilijev / interview2.cpp
Created Oct 7, 2012
rephrasing the interview question
View interview2.cpp
int n = 42;
int* p = &n;
const int* const * a = &p; // given (interview question)
int const* const * b = a; // rephrased version
dilijev / const2.cpp
Created Oct 7, 2012
these lines have the same type
View const2.cpp
const int a = 11;
int const b = 22;
dilijev / wrong_answer.cpp
Created Oct 7, 2012
the correct way to write the wrong interview answer
View wrong_answer.cpp
const int** const ptr;
View DimensionException.cpp
class DimensionException : public std::exception {
size_type _rowsA;
size_type _colsA;
size_type _rowsB;
size_type _colsB;
char _what[256];
: exception() {