Skip to content

Instantly share code, notes, and snippets.

View ZwodahS's full-sized avatar

Eric ZwodahS

View GitHub Profile
@ZwodahS
ZwodahS / string_format.cpp
Last active August 29, 2015 14:06
C++ simple string formating
/*
* DO WHAT THE F*** YOU WANT TO PUBLIC LICENSE
* Version 2, December 2004
*
* Copyright (C) 2013- ZwodahS(ericnjf@gmail.com)
* zwodahs.github.io
*
* Everyone is permitted to copy and distribute verbatim or modified
* copies of this license document, and changing it is allowed as long
* as the name is changed.
def generate_maze(x, y, config={}):
structure = []
for i in range(x):
l = []
for j in range(y):
l.append(6)
structure.append(l)
maze = {
"x" : x,
@ZwodahS
ZwodahS / Curse cheatsheet
Created June 12, 2014 17:26
Curse cheatsheet (ncurses, pdcurses etc)
//// General stuffs ////
initscr(); // "start curses"
endwin() ; // "end curses"
//// Windowing ////
WINDOW* window = newwin(height, width, startY, startX)
//// Draw ///
refresh()
wrefresh(window)
@ZwodahS
ZwodahS / replaceString
Created May 29, 2014 09:14
A simple find and replace for C++
std::string& replaceString(std::string& newString, const std::string& searchString, const std::string& replaceString, const bool& multipleReplace)
{
size_t index = newString.find(searchString);
if(multipleReplace)
{
while(index != std::string::npos)
{
// replace
newString.replace(index, searchString.size(), replaceString);
// start searching from the end of the replaceString, such that the replaceString will never be part of the search
@ZwodahS
ZwodahS / gist:6638137
Created September 20, 2013 14:09
git branch display and coloring of path in terminal
c_cyan=`tput setaf 6`
c_red=`tput setaf 1`
c_green=`tput setaf 2`
c_sgr0=`tput sgr0`
parse_git_branch ()
{
if git rev-parse --git-dir >/dev/null 2>&1
then
gitver=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
" DO WHAT THE **** YOU WANT TO PUBLIC LICENSE
" Version 2, December 2004
"
" Copyright (C) 2013 ZwodahS(ericnjf@gmail.com)
" zwodahs.wordpress.com
"
" Everyone is permitted to copy and distribute verbatim or modified
" copies of this license document, and changing it is allowed as long
" as the name is changed.
"