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
| autocmd BufWritePre *.py call Format("black --quiet -") | |
| autocmd BufWritePre *.json call Format("jq") | |
| autocmd BufWritePre *.py call Format("sed 's/ *$//'") | |
| function! Format(command) | |
| let view = winsaveview() | |
| keepjumps silent exec "%!" . a:command | |
| if v:shell_error > 0 | |
| silent undo | |
| endif |
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 itertools | |
| class World: | |
| def __init__(self, interactions): | |
| self.objects = [] | |
| self.interactions = interactions | |
| def add(self, item): | |
| self.objects.append(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
| from unittest.mock import Mock | |
| import unittest.mock | |
| import doctest | |
| class Calculator: | |
| """ | |
| >>> mock_display = Mock(Display) | |
| >>> calculator = Calculator(mock_display) | |
| >>> calculator.add(3) |
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 cairo | |
| import pygame | |
| import sys | |
| SIZE = (400, 400) | |
| def draw_frame(cairo_context, position): | |
| cairo_context.set_source_rgb(1, 0, 0) | |
| cairo_context.rectangle(position, position, 10, 10) | |
| cairo_context.fill() |
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 <wx/wxprec.h> | |
| #ifndef WX_PRECOMP | |
| #include <wx/wx.h> | |
| #endif | |
| class MyApp: public wxApp | |
| { | |
| public: | |
| virtual bool OnInit(); |
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/python | |
| import sys | |
| def read_content(path): | |
| f = open(path, "r") | |
| res = f.read() | |
| f.close() | |
| return res |
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 wxversion | |
| wxversion.ensureMinimal('2.8') | |
| import wx | |
| app = wx.App(False) | |
| main_frame = wx.Frame(None) | |
| main_frame.Show() |
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 re | |
| import requests | |
| import sys | |
| import urlparse | |
| TIMEOUT_IN_SECONDS = 10.0 | |
| def check(base_url): | |
| print("Checking %s" % base_url) | |
| base_response = requests.get(base_url, timeout=TIMEOUT_IN_SECONDS) |
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 Data.List | |
| import Test.QuickCheck | |
| mySort :: [Int] -> [Int] | |
| mySort list = | |
| let swapped = swap list in | |
| if swapped == list | |
| then list | |
| else mySort swapped | |
| where |
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 Test.Hspec | |
| score :: [Int] -> Int | |
| score rolls = score' 10 rolls | |
| where | |
| score' 0 rolls = 0 | |
| score' framesLeft rolls = | |
| let (frameScore, restRolls) = popFrame rolls | |
| in frameScore + score' (framesLeft - 1) restRolls |
NewerOlder