Skip to content

Instantly share code, notes, and snippets.

View simplyvikram's full-sized avatar

vikram singh simplyvikram

View GitHub Profile
#!/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'
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
good_ones = [
[],
[
{
'id': 1,
'links': [2, 4]
},
{
'id': 2,
/**
* 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
<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
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
@simplyvikram
simplyvikram / chat_server.go
Last active June 28, 2020 16:01
Playing around with a simple chat server, where clients connect via telnet and send messages to server
package main
import (
"bufio"
"fmt"
"io"
"net"
"os"
"regexp"
"strings"
from math import sqrt
class Point(object):
def __init__(self, x, y):
self.x = x
self.y = y
def __str__(self):
package main
import "fmt"
type Asset interface {
AssetType() string
GetBase() Base
SetBase(b Base)
}
type Base struct {
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: