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
| using System; | |
| using System.ComponentModel.Composition; | |
| using System.ComponentModel.Composition.Hosting; | |
| namespace MefGenericExportImports | |
| { | |
| [Export] | |
| public class Program | |
| { | |
| [Import] |
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
| using System; | |
| namespace ParameterDefaultsGuard | |
| { | |
| // The goal is to make it hard to accidentally call the wrong | |
| // overload when wanting to provide multiple overloads and still | |
| // allow overriding defaults through named parameters. To | |
| // accomplish this, we create an empty struct type. This guards | |
| // against passing in null to various positional parameters and | |
| // that being mistakenly passed as the guard. The only way to |
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 ReverseProxy(object): | |
| def process_request(self, request): | |
| unsafe = True | |
| try: | |
| forwarded_for_split = [x.strip() for x in request.META['HTTP_X_FORWARDED_FOR'].split(',')] | |
| # Client connecting to heroku’s stuff is the last listed one. | |
| # http://stackoverflow.com/q/18264304/429091 | |
| request.META['REMOTE_ADDR'] = forwarded_for_split.pop() | |
| unsafe = False | |
| except KeyError: |
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
| using System; | |
| using System.Threading.Tasks; | |
| class Program | |
| { | |
| static void Main() => new Program().Run().Wait(); | |
| async Task Run() | |
| { | |
| Console.WriteLine("Before Using"); | |
| await Async.Using(new Test(), t => |
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
| ohnobinki@gibby ~ $ python3 | |
| Python 3.3.5 (default, May 19 2015, 14:05:03) | |
| [GCC 4.9.2] on linux | |
| Type "help", "copyright", "credits" or "license" for more information. | |
| >>> import sqlite3 | |
| >>> logger_connection = sqlite3.connect('/home/ohnobinki/log.sql') | |
| >>> logger_connection.exec('CREATE TABLE IF NOT EXISTS submission_log (text TEXT)'); | |
| Traceback (most recent call last): | |
| File "<stdin>", line 1, in <module> | |
| AttributeError: 'sqlite3.Connection' object has no attribute 'exec' |
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
| using System; | |
| using System.Threading.Tasks; | |
| namespace ArgumentListAwait | |
| { | |
| class Program | |
| { | |
| // Too bad to call a function with multiple task results you have to | |
| // store the intermediate tasks in locals because of the order of | |
| // evaluation of argument lists. |
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
| #!/usr/bin/env python | |
| import random | |
| def intro(): | |
| print('Welcome to Rock, Paper, Scissors!') | |
| def user(): | |
| user_move = '' | |
| while user_move != 'r' and user_move != 'p' and user_move != 's': | |
| user_move = input('What is your move? (r,p,s) ') |
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
| ohnob@DESKTOP-A4G2C0J ~/OneDrive/repos/Main | |
| $ diff -u .better.sql.orig .better.sql.new | |
| --- .better.sql.orig 2016-04-29 12:37:32.586963400 -0400 | |
| +++ .better.sql.new 2016-04-29 12:37:43.936262800 -0400 | |
| @@ -1,3 +1,2 @@ | |
| WHERE 1=1 | |
| -AND Squirrels=1 | |
| AND Humans=1 |
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
| ohnob@DESKTOP-A4G2C0J ~/repos/MainContainer4 | |
| $ 7z a test.7z testdir | |
| 7-Zip [64] 15.14 : Copyright (c) 1999-2015 Igor Pavlov : 2015-12-31 | |
| Scanning the drive: | |
| 1 folder, 1 file, 0 bytes | |
| Creating archive: test.7z |
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 callCallback(cb): | |
| ... cb() | |
| ... | |
| >>> class MyClass(object): | |
| ... def __init__(self, x): | |
| ... self.x = x | |
| ... def f(self): | |
| ... print('x = %s' % (self.x, )) | |
| ... | |
| >>> myObject = MyClass(3) |