This file contains 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
#!/bin/bash | |
# https://cloud.google.com/compute/docs/faq#ipranges | |
#nslookup -q=TXT _cloud-netblocks.googleusercontent.com 8.8.8.8 | |
for LINE in `dig txt _cloud-netblocks.googleusercontent.com +short | tr " " "\n" | grep include | cut -f 2 -d :` | |
do | |
dig txt $LINE +short | |
done | tr " " "\n" | grep ip4 | cut -f 2 -d : | sort -n | tr '\n' ',' | sed 's/,$//g' |
This file contains 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 functools import cmp_to_key | |
class SurgeryEvent(object): | |
TYPE_START = 'surger_start' | |
TYPE_END = 'surgery_end' | |
def __init__(self, time, type): | |
self.time = time | |
self.type = type |
This file contains 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
good_ones = [ | |
[], | |
[ | |
{ | |
'id': 1, | |
'links': [2, 4] | |
}, | |
{ | |
'id': 2, |
This file contains 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 priority queue stores a list of items but each can have a numeric priority value. | |
* Items with a higher priority are dequeued before items with a lower priority. | |
* Implemented as a hash of arrays where the hash keys are priority values. | |
*/ | |
function PriorityQueue(size) { | |
this.store = {}; // keys are priorities, values are arrays of elements | |
this.count = 0; | |
// adds an item |
This file contains 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
<html><body><img src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAuQAAAIwCAYAAADOC35cAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAPYQAAD2EBqD%2BnaQAAIABJREFUeJzs3Xl8VPd97//3jEYLSEIaCYlFArMYCZAwm4QkwE7qGIzs2JbNL14S0tw2TZ3%2BHr%2B4y6/3pvm1N0nb2/px20dvl7S9vc3WNI0Tk2LHsR0biLFNQEisQggksUmAAYEkEEK7Zvn9IXSsQduMmJnvSPN6/jVn5pwz33M0mnnPdz7n%2B7V5vV6vAAAAABhhN90AAAAAIJoRyAEAAACDCOQAAACAQQRyAAAAwCACOQAAAGAQgRwAAAAwiEAOAAAAGEQgBwAAAAwikAMAAAAGEcgBAAAAgwjkAAAAgEEEcgAAAMAgAjkAAABgEIEcAAAAMIhADgAAABhEIAcAAAAMIpADAAAABhHIAQAAAIMI5AAAAIBBDtMNACbK7fGq2%2BUN63NOc9gUY7eF9TkBBI73BwCTCYEck9Khph7tON1h5AN3a06SCmcnhPV5AfiP9wcAkw0lK5h03B6vkQ9bSep2DTy32xP%2B5wYwPt4fAExGBHJMOt2u8P8UHUnPD2B0pv8/TT8/gMmJQA4AAAAYRA05AGBK%2B1qRU0mxoel/6uj36OXKmyHZN4DoQSAHAExpSbF2JcXxgzCAyMU7FAAAAGAQPeRAhGhvv62amhqdPFWrpqZram9vl8vlUprTqbT0NC1bmqvCwkIlJycFvO/qEzX69re/ay1v3vSInnjicb%2B2PXPmrP7hW/8kSSotfVSPlW4J%2BPkrKg7qR6/82FpeuGCB/uAPfjfg/fzN//o7NTZesJa3fe4FFRWt83v7occyUUXrCrVt22et5R/%2Bxys6ePCQJOlPv/l1paU5fdYf%2BrgU2Lkf1NXVrT/%2Bk6/L5XJZ9/nzXP5KSEjQX//VywFvh/Bxu |
This file contains 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 collections import defaultdict | |
import sys | |
class Transaction(object): | |
def __init__(self, level, parent_transaction): | |
self.level = level | |
self.parent_transaction = parent_transaction | |
self.child_transaction = None |
This file contains 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
package main | |
import ( | |
"bufio" | |
"fmt" | |
"io" | |
"net" | |
"os" | |
"regexp" | |
"strings" |
This file contains 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 math import sqrt | |
class Point(object): | |
def __init__(self, x, y): | |
self.x = x | |
self.y = y | |
def __str__(self): |
This file contains 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
package main | |
import "fmt" | |
type Asset interface { | |
AssetType() string | |
GetBase() Base | |
SetBase(b Base) | |
} | |
type Base struct { |
This file contains 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 lzw_encode(text): | |
"""Compress a string to a list of output symbols.""" | |
# Build the dictionary. | |
dict_size = 256 | |
dictionary = dict((chr(i), i) for i in xrange(dict_size)) | |
w = "" | |
result = [] | |
for c in text: |
NewerOlder