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
| levenshtein = (a, b) -> | |
| # Handle degenerate cases | |
| if a == b | |
| return 0 | |
| unless a.length > 0 and b.length > 0 | |
| return a.length or b.length | |
| # Normalize order for cache | |
| if b.length < a.length |
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[ | |
| #ifndef ${TM_FILEPATH/(([A-Za-z]+)\/src\/)|./\U(?1:$2_)\E/g}${TM_FILENAME/(([A-Z])([A-Z][a-z]))|(([a-z])([A-Z]))|([a-z])|(\.)/\U(?1:$2_$3)(?4:$5_$6)$7(?8:_)\E/g} | |
| #define ${TM_FILEPATH/(([A-Za-z]+)\/src\/)|./\U(?1:$2_)\E/g}${TM_FILENAME/(([A-Z])([A-Z][a-z]))|(([a-z])([A-Z]))|([a-z])|(\.)/\U(?1:$2_$3)(?4:$5_$6)$7(?8:_)\E/g} | |
| $0 | |
| #endif | |
| ]]></content> | |
| <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> |
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
| with open("tyc_main.dat", mode="rt") as tycho_database: | |
| num_close = 0 | |
| for line in tycho_database: | |
| plx = line[79:86].strip() | |
| if line[267] != 'P' and plx and float(plx) > 200 and line[349] != 'K' and int(line[260]) <= 4: | |
| num_close += 1 | |
| print(num_close) |
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
| """A high-level simulation of Achron's economy.""" | |
| from __future__ import division | |
| # Simulation time parameters | |
| ticks_per_second = 18 | |
| simulation_length = 5 * 60 | |
| t = simulation_length * ticks_per_second | |
| # RP constants |
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 subprocess | |
| import contextlib | |
| import os | |
| import sys | |
| import fnmatch | |
| from collections import defaultdict, Counter | |
| @contextlib.contextmanager | |
| def chdir(dirname=None): | |
| curdir = os.getcwd() |
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 struct | |
| header = struct.Struct("<5s58s256s256s6s") | |
| playerinfo1 = struct.Struct("<64sH") | |
| playerinfo2 = struct.Struct("<256s4I48s") | |
| def modify_scn(filename, changes): | |
| with open(filename, "rb+") as scn: | |
| data = scn.read() |
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 __future__ import division | |
| import csv | |
| from collections import namedtuple | |
| from math import ceil, sqrt | |
| import sys | |
| # General constants | |
| TICKS_PER_SECOND = 18 | |
| RP_COST = 80 |
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 xml.etree.cElementTree as ET | |
| import operator | |
| from pprint import pprint, pformat | |
| # def etree_to_dict(t): | |
| # d = {t.tag : list(map(etree_to_dict, iter(t)))} | |
| # d.update(('@' + k, v) for k, v in t.attrib.items()) | |
| # d['text'] = t.text | |
| # return 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
| import struct | |
| header = struct.Struct("<4s5sB") | |
| unclear_chunk1 = struct.Struct("<12s1B") | |
| unclear_chunk2 = struct.Struct("<12s1B") | |
| unclear_chunk3 = struct.Struct("<12s1B") | |
| unclear_chunk4 = struct.Struct("<12s1B") | |
| unclear_chunk5 = struct.Struct("<12s1B") | |
| def modify_tsc(filename, changes): |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>JSNetworkX images as nodes demo</title> | |
| <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> | |
| <script type="text/javascript" src="jsnetworkx.js"></script> | |
| </head> | |
| <body> | |
| <div id="canvas"></div> | |
| <script type="text/javascript"> |
OlderNewer