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
fn update_state<'a>(s :&'a str, tokens :&mut Vec<String>, match_point : &Captures<'a>) -> &'a str { | |
let new_s = &s[match_point.get(1).unwrap().end()..]; | |
tokens.push(match_point.get(1).unwrap().as_str().to_string()); | |
new_s | |
} | |
pub fn tokenizer(s_in: &str) -> Reader { | |
let mut s = &s_in[0..]; | |
let brackets = regex!(r###"^[\s,]*([\(\)\{\}\[\]])[\s,]*"###); |
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
from __future__ import absolute_import, division, print_function | |
import random | |
import copy | |
EMPTY = '_' | |
def winner(spaces): | |
winning_tile = filter(lambda a:a, [_is_row_winner(row) for row in spaces]) |
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
from __future__ import absolute_import, division, print_function | |
class Node(object): | |
def __init__(self, value, parent, left=None, right=None): | |
self.right = right | |
self.left = left | |
self.parent = parent | |
self.value = value |
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
set nocompatible " be iMproved, required | |
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" let Vundle manage Vundle, required :PluginInstall | |
Plugin 'VundleVim/Vundle.vim' "This package manager | |
Plugin 'tpope/vim-fugitive' |
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 task is meant to simulate tiling a wall. | |
# It uses Turtle also known as Logo. | |
# Turtle instructions | |
# https://docs.python.org/2/library/turtle.html | |
# Sample code: | |
import turtle |
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
# Path to your oh-my-zsh installation. | |
export ZSH="/home/andy/.oh-my-zsh" | |
alias python=python3 | |
# time that oh-my-zsh is loaded. | |
ZSH_THEME="tjkirch" | |
# Plugins zsh-syntax-highlightin is downloaded separately | |
plugins=(git python zsh-syntax-highlighting) |
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
# colors | |
export CLICOLOR=1 | |
export TERM=xterm-color | |
export LSCOLORS=gxgxcxdxbxegedabagacad # cyan directories | |
#Giant history | |
export HISTSIZE=99999 | |
# set - same as _ | |
set completion-map-case on |
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
Simple: | |
2 people get married - adjust names, also double barrelled names | |
Replace word X with word Y | |
Normal: | |
Reverse String | |
Reverse words in String |
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
import os | |
from jinja2 import Environment, FileSystemLoader | |
from line_profiler import LineProfiler | |
@profile | |
def render_template(template_filename, context): | |
return TEMPLATE_ENVIRONMENT.get_template(template_filename).render(context) | |
PATH = os.path.dirname(os.path.abspath(__file__)) |
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
class RemoveWWW(object): | |
def process_request( self, request ): | |
try: | |
if request.META['HTTP_HOST'].lower().find('www.') == 0: | |
from django.http import HttpResponsePermanentRedirect | |
return HttpResponsePermanentRedirect( request.build_absolute_uri().replace('//www.', '//') ) | |
except: | |
pass | |
return None |