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
| # value_when_true if condition else value_when_false | |
| 'Yes' if fruit == 'Apple' else 'No' |
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
| #� http://stackoverflow.com/questions/11707586/python-pandas-widen-output-display | |
| from pandas.util.terminal import get_terminal_size | |
| get_terminal_size() | |
| from pandas import set_printoptions | |
| set_printoptions(max_rows=200,max_columns=10) |
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
| # http://docs.python.org/release/2.3.5/lib/node304.html | |
| # http://www.blog.pythonlibrary.org/2012/08/02/python-101-an-intro-to-logging/ | |
| import logging | |
| logger = logging.getLogger('myapp') | |
| hdlr = logging.FileHandler('/var/tmp/myapp.log') | |
| formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') | |
| hdlr.setFormatter(formatter) | |
| logger.addHandler(hdlr) | |
| logger.setLevel(logging.WARNING) |
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
| newdata = {} | |
| for k, v in DATA_SOURCE: | |
| newdata.setdefault(k, []).append(v) | |
| print newdata | |
| from collections import defaultdict | |
| newdata = defaultdict(list) | |
| DATA_SOURCE = (('key1', 'value1'), |
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
| UPDATE dbo.customer_comments | |
| SET customer_comment= @comment + 'something here' | |
| WHERE customer_id = @customerId | |
| IF @@ROWCOUNT = 0 | |
| INSERT INTO dbo.customer_comments (customer_id, customer_comment) | |
| VALUES (@customerId, @comment) |
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
| schtasks /end /s <machine name> /tn <task name> /U <Username> /P <Password> | |
| schtasks /? | |
| # http://technet.microsoft.com/en-us/library/cc766266.aspx | |
| # http://stackoverflow.com/questions/290559/how-do-i-stop-start-a-scheduled-task-on-a-remote-computer-programatically |
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
| sudo apt update | |
| sudo apt upgrade | |
| # https://www.digitalocean.com/community/tutorials/how-to-create-a-new-sudo-enabled-user-on-ubuntu-22-04-quickstart | |
| # https://support.atlassian.com/bitbucket-cloud/docs/set-up-personal-ssh-keys-on-linux/ | |
| # https://docs.conda.io/en/main/miniconda.html | |
| # Setting up Ubuntu | |
| # check locale |
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
| # http://stackoverflow.com/questions/1829872/read-datetime-back-from-sqlite-as-a-datetime-in-python | |
| db = sqlite3.connect(':memory:', detect_types=sqlite3.PARSE_DECLTYPES) | |
| c = db.cursor() | |
| c.execute('create table foo (bar integer, baz timestamp)') | |
| c.execute('insert into foo values(?, ?)', (23, datetime.datetime.now())) | |
| c.execute('select * from foo') | |
| c.fetchall() | |
| [(23, datetime.datetime(2009, 12, 1, 19, 31, 1, 40113))] |
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
| # http://zetcode.com/db/sqlitepythontutorial/ | |
| #!/usr/bin/python | |
| # -*- coding: utf-8 -*- | |
| import sqlite3 as lite | |
| import sys | |
| uId = 1 | |
| uPrice = 62300 |
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
| # http://zetcode.com/db/sqlitepythontutorial/ | |
| #!/usr/bin/python | |
| # -*- coding: utf-8 -*- | |
| import sqlite3 as lite | |
| import sys | |
| con = lite.connect('test.db') |