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
| # coding=utf-8 | |
| import unicodedata | |
| def strip_accents(s): | |
| return ''.join(c for c in unicodedata.normalize('NFD', s) if unicodedata.category(c) != 'Mn') | |
| str1 = u"ÃÄÅÈÉÊËÌÍÎÏ" | |
| str2 = u"ÙÚÛÜÝàáâãäåèéêëìíîïñòóôõöùúûüýÿ" |
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
| #include <string> | |
| #include <sstream> | |
| #include <vector> | |
| using namespace std; | |
| void split(const string &s, char delim, vector<string> &elems) { | |
| stringstream ss; | |
| ss.str(s); | |
| string item; |
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 ExtendedCombo( QtGui.QComboBox ): | |
| def __init__( self, parent = None): | |
| super( ExtendedCombo, self ).__init__( parent ) | |
| self.setFocusPolicy( QtCore.Qt.StrongFocus ) | |
| self.setEditable( True ) | |
| self.completer = QtGui.QCompleter( self ) | |
| # always show all completions | |
| self.completer.setCompletionMode( QtGui.QCompleter.UnfilteredPopupCompletion ) |
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
| :: Creates a link | |
| subst T: D:/path/to/dir | |
| :: Removes link | |
| subst T: /D |
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
| def get_directory_structure(rootdir): | |
| """ | |
| Creates a nested dictionary that represents the folder structure of rootdir | |
| """ | |
| dir = {} | |
| rootdir = rootdir.rstrip(os.sep) | |
| start = rootdir.rfind(os.sep) + 1 | |
| for path, dirs, files in os.walk(rootdir): | |
| folders = path[start:].split(os.sep) | |
| subdir = dict.fromkeys(files) |
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
| <snippet> | |
| <content><![CDATA[""" | |
| Description | |
| :param $1: | |
| :type $1: | |
| :rtype: | |
| """ | |
| ]]></content> |
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 sqlite3 | |
| conn = sqlite3.connect('example.db') | |
| c = conn.cursor() | |
| def drop_table(): | |
| c.execute('''DROP TABLE IF EXISTS courses''') | |
| # Save (commit) the changes | |
| conn.commit() |
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
| <snippet> | |
| <content><![CDATA[def get_$1(self): | |
| return self._$1 | |
| def set_$1(self, $1): | |
| self._$1 = $1; | |
| ]]></content> | |
| <!-- Optional: Tab trigger to activate the snippet --> | |
| <tabTrigger>getset</tabTrigger> | |
| <!-- Optional: Scope the tab trigger will be active in --> |
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
| def dict_depth(d, depth=0): | |
| if not isinstance(d, dict) or not d: | |
| return depth | |
| return max(dict_depth(v, depth+1) for k, v in d.iteritems()) |
NewerOlder