Skip to content

Instantly share code, notes, and snippets.

View mylons's full-sized avatar

Mike Lyons mylons

  • Incline Village, NV
View GitHub Profile
# https://leetcode.com/problems/merge-k-sorted-lists/
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
def list_to_stack(l):
s = []
node = l
from collections import defaultdict
import random
import string
alphabet = string.ascii_letters + '0123456789'
class Codec:
def __init__(self):
self.urls = defaultdict(str)
@mylons
mylons / get_coin.py
Created December 13, 2017 15:34
handsome code for a handsome man
from concurrent import futures
import requests
URLS = {'BTC': 'https://api.gdax.com/products/BTC-USD/ticker',
'ETH': 'https://api.gdax.com/products/ETH-USD/ticker',
'LTC': 'https://api.gdax.com/products/LTC-USD/ticker'}
def get_quote(toople):
coin, url = toople
package main
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/rds"
"fmt"
)
@mylons
mylons / site.pp
Created February 19, 2016 18:45
puppet is the bomb
$go_file = "go1.5.3.linux-amd64.tar.gz"
$stupid_path = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/vagrant_ruby/bin'
$dot_profile = '
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
@mylons
mylons / blah.py
Created September 14, 2015 18:10
run time interview questions
# assume inputs are lists
def merge1(words, more):
sentence = ""
for w in words: sentence += w
for w in more: sentence += w
return sentence
def merge2(words, more):
sentence = []
node.force_override['java']['jdk_version'] = '7'
include_recipe "java"
@mylons
mylons / default.rb
Created August 26, 2013 22:01
This java cookbook, https://github.com/opscode-cookbooks/java , isn't working as intended. Perhaps it's something sinister inside the chef internals itself dealing with, or not dealing with, composite attributes.
# showing java cookbook fail
node.default[:java][:jdk_version] = '7'
include_recipe 'java'
=begin
doesn't override this line:
https://github.com/opscode-cookbooks/java/blob/master/attributes/default.rb#L46
I output some custom logging from the java cookbook at:
https://github.com/opscode-cookbooks/java/blob/master/recipes/openjdk.rb#L47
[2013-08-26T21:57:17+00:00] INFO: java version 7
class Person(val name: String, val age: Int)
//sort sequentially
val persons: Array[Person]
val (minors, adults) = people partition (_.age < 18)
//sort in parallel
val (minors, adults) = people.par partition (_.age < 18)
//distributed sort