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
# 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: |
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
# 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 |
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 random | |
import string | |
alphabet = string.ascii_letters + '0123456789' | |
class Codec: | |
def __init__(self): | |
self.urls = defaultdict(str) |
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 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 |
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
$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. |
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
# 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 = [] |
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
node.force_override['java']['jdk_version'] = '7' | |
include_recipe "java" | |
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
# 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 |
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
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 |