This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file has been auto-generated by i3-config-wizard(1). | |
# It will not be overwritten, so edit it as you like. | |
# | |
# Should you change your keyboard layout somewhen, delete | |
# this file and re-run i3-config-wizard(1). | |
# | |
# i3 config file (v4) | |
# | |
# Please see http://i3wm.org/docs/userguide.html for a complete reference! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bindsym $mod+o exec i3-msg '[id='$(i3-msg -t get_tree | jq -r 'recurse(.nodes[]) | select(.window) | (.window | tostring) + ":" + .name' | ~/.config/bin/dmenu_map -i)'] focus' | |
bindsym $mod+Mod1+o exec i3-msg '[id='$(i3-msg -t get_tree | jq -r 'recurse(.nodes[]) | select(.window and .urgent) | (.window | tostring) + ":" + .name' | ~/.config/bin/dmenu_map -i)'] focus' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Changes to directory passed in $1 and runs the command specified | |
# by the remaining arguments. | |
function cdo() { | |
at=${1} | |
shift | |
( # enter a subshell to perform the action | |
cd "${at}" | |
"$@" | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
template <typename T> | |
void blah(T) {} | |
template <typename T> | |
std::vector<T> blorp(T) { | |
std::vector<T> x; | |
return x; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PS1_LASTEXIT='$(LE=$?; if [ ${LE} -ne 0 ]; then LED=$(perl -le "\$!+=${LE};print \$!"); echo "\[\e[31;1m\]^${LE}:${LED}\[\e[32;1m\]> "; fi)' | |
PS1_USERNAME="\[\e[37;1m\]\u\[\e[32;1m\]> " | |
PS1_JOBS='$(JB=$(jobs -l | wc -l); if [ ${JB} -gt 0 ]; then echo "\[\e[37;1m\]&\j\[\e[32;1m\]> "; fi)' | |
PS1_GIT='$(GPS=$(__git_ps1 %s); if [ -n "${GPS}" ]; then STAT=$(git status --porcelain | cut -c1-2 | sed -E "s/ /-/" | sort | uniq | xargs echo | cut --delimiter=" " -f1- --output-delimiter=","); echo "\[\e[37;1m\]git:${GPS}:\[\e[35;1m\]${STAT}\[\e[32;1m\]> "; fi)' | |
PS1_WD="\[\e[37;1m\]\w\[\e[32;1m\]> " | |
PS1_PROMPTNUM="\[\e[37;1m\]!\!\[\e[32;1m\]" | |
# \! in PS2 actually prints the next command number because the command so far has already been appended to the history. | |
# Instead, get it from fc, which can tell you the last command number. | |
PS2_PROMPTNUM="\[\e[37;1m\]!\$(fc -l -1 | head -1 | awk '{print \$1}')\[\e[32;1m\]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef int AA; | |
void foo() | |
{ | |
AA AA; /* OK - define variable AA of type AA */ | |
int BB = AA * 2; /* OK - AA is just a variable name here */ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Python object model in a nutshell (with deliberate errors for simplicity): | |
- A class is a dict | |
- The dict contains methods (not in python syntax): | |
cls = { 'a': function(self, blah) {...}, 'b': function(self, blorp) {...} } | |
- An object is also a dict that contains an __class__ member that points to the class: | |
obj = { '__class__': cls } | |
- When you fetch a method from obj: | |
obj.a | |
it looks on __class__ for 'a', and finding it wraps it in a functor that adds the self parameter: | |
function(blah) { obj['__class__']['a'](obj, blah) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <cstdio> | |
using namespace std; | |
class X | |
{ | |
public: | |
string str; | |
X(const string &s) : str(s) { printf("Constructor %s 0x%p\n", str.c_str(), this); } | |
~X() { printf("Destructor %s 0x%p\n", str.c_str(), this); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ugly poorly aligned if | |
if a == b | |
elsif b == c | |
elsif z == d | |
else | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int my_atoi(const char *str) | |
{ | |
int neg = 1; | |
int x = 0; | |
if (*str == '-') | |
{ | |
neg = -1; | |
*str++; |
NewerOlder