This file contains hidden or 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 Heap: | |
| """Heap implementation""" | |
| def __init__(self, arr): | |
| self.arr = arr | |
| def parent(self, child_index): | |
| return self.arr[child_index // 2] | |
| def left(self, parent_index): |
This file contains hidden or 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
| """ | |
| Columns for reference: | |
| cols = ('_split', 'Date', '_payee', 'Income', 'Expense', 'Category', | |
| 'Subcategory', 'Notes', '_method', '_status', '_refnum', '_unknown') | |
| """ | |
| import csv | |
| from datetime import datetime | |
| import matplotlib.pyplot as plt | |
| import os |
This file contains hidden or 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
| unbind C-b | |
| set -g prefix C-a | |
| setw -g monitor-activity on | |
| set -g visual-activity on |
This file contains hidden or 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 rtp+=~/.vim/bundle/Vundle.vim | |
| call vundle#begin() | |
| " let Vundle manage Vundle | |
| " required! | |
| Plugin 'gmarik/Vundle.vim' | |
| " git helper |
This file contains hidden or 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
| { | |
| "bold_folder_labels": true, | |
| "color_scheme": "Packages/User/SublimeLinter/base16-ocean.dark (SL).tmTheme", | |
| "dictionary": "Packages/Language - English/en_GB.dic", | |
| "draw_centered": true, | |
| "fade_fold_buttons": false, | |
| "font_face": "Monaco", | |
| "font_size": 16, | |
| "highlight_line": true, | |
| "ignored_packages": |
This file contains hidden or 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 MyAdmin(admin.ModelAdmin): | |
| def response_add(self, request, obj, post_url_continue=None): | |
| # If object is added in popup, treat as continue | |
| if '_popup' in request.POST: | |
| opts = obj._meta | |
| pk_value = obj._get_pk_val() | |
| preserved_filters = self.get_preserved_filters(request) | |
| msg_dict = {'name': force_text(opts.verbose_name), 'obj': force_text(obj)} | |
| msg = _('The %(name)s "%(obj)s" was added successfully. You may edit it again below.') % msg_dict | |
| self.message_user(request, msg, messages.SUCCESS) |
This file contains hidden or 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 math | |
| import matplotlib.pyplot as plt | |
| %matplotlib inline | |
| a = range(1,100) | |
| b = map(lambda x:x*math.log(x,2), a) | |
| c = map(lambda x:x*x, a) | |
| d = map(lambda x:2**x, a) | |
| p = plt.figure() |
This file contains hidden or 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
| (function(){ | |
| 'use strict'; | |
| var randomArray = function(size) { | |
| var arr = []; | |
| for(var i=0;i<size;i++) { | |
| arr.push(Math.round(Math.random() * size * 10)); | |
| } | |
| return arr; | |
| }; |
This file contains hidden or 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 itertools import izip_longest | |
| from string import lowercase | |
| def chunk(s, size): | |
| ''' | |
| Separates sequence into chunks of given size. | |
| >>> chunk('helloworld', 3) | |
| ['hel', 'low', 'orl', 'd'] |