Skip to content

Instantly share code, notes, and snippets.

View Ddedalus's full-sized avatar

Hubert Bereś Ddedalus

View GitHub Profile
@Ddedalus
Ddedalus / PowerShell.ps1
Created December 29, 2018 12:10
List recent changes to file in git
git log -n 100 -p path_to_file | Select-String "quoted"
// -n for n last changes
// -p for actual diff
@Ddedalus
Ddedalus / not_main.py
Created September 20, 2018 19:52
Python execute block only if file called directly
if __name__ == "__main__":
pass
@Ddedalus
Ddedalus / Any.py
Created August 9, 2018 10:49
Shell from Python with Popen
import subprocess
command = "dir \n ls"
p = subprocess.Popen(command, stdout = subprocess.PIPE, stderr = None, shell = True)
print p.communicate()
@Ddedalus
Ddedalus / printing.h
Created July 11, 2018 23:44
Print vector with cout in C++
template <class T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v)
{
os << "[";
for (const T &p : v)
os << p << ", ";
os << "]";
return os;
}
@Ddedalus
Ddedalus / tRecords.cpp
Created July 3, 2018 09:08
Reasonable read/write in c++
fstream csvk;
csvk.open("../output/stub_run.csv", fstream::ate | fstream::in | fstream::out);
// consult: https://en.cppreference.com/w/cpp/io/basic_filebuf/open
csvk << "Can write there!; blah blah\n"; csvk.flush();
@Ddedalus
Ddedalus / shell
Created June 28, 2018 10:46
discard unstaged git changes
git checkout filename
git checkout -- filename # if it happend to clash with branch name
@Ddedalus
Ddedalus / bash
Created June 27, 2018 11:52
Release build in CMake
cd release
cmake -DCMAKE_BUILD_TYPE=Debug ..
@Ddedalus
Ddedalus / main.cpp
Created June 27, 2018 11:35
Size of adjacency list
uint64_t size = 0;
for(auto n : neighbours){
size += n.size() * sizeof(uint32_t);
}
cout<< "Loaded large graph. Size of adj. list is: " << size << endl;
@Ddedalus
Ddedalus / runOnSizes.R
Created June 19, 2018 10:19
Attributes in R
attr(obj, 'name') <- value
attributes(obj)
@Ddedalus
Ddedalus / POETS_Input_Analysis.Rmd
Created June 18, 2018 12:20
Label points on a plot
plot(sapply(nets, gorder), sapply(nets, gsize),
xlab="vertices", ylab="edges")
text(sapply(nets, gorder), sapply(nets, gsize), labels = netNames, pos = c(3, 4, 4, 4, 4, 2, 3, 2, 3))
######### pos: vector of label locations: 1-below, 2-left, 3-above, 4-right; may be just a single number
######### the same ploting series must be passed to the plot and text. May use with(df, ...) for convenience