sudo apt-get install gdb
pip install pyrasite
pyrasite-shell {pid}
import sys, traceback
for tid, frame in sys._current_frames().items():
print("Stack for thread {}".format(tid))
sudo apt-get install gdb
pip install pyrasite
pyrasite-shell {pid}
import sys, traceback
for tid, frame in sys._current_frames().items():
print("Stack for thread {}".format(tid))
inp | |
|> String.split("\n", trim: true) | |
|> Enum.map(&String.split(&1, "\t")) | |
|> Enum.map(fn a -> a |> Enum.map(&String.to_integer/1) end) | |
|> Enum.map(fn a -> [Enum.max(a), Enum.min(a)] end) | |
|> Enum.map(fn [a, b] -> a - b end) | |
|> Enum.sum() | |
|> IO.inspect() | |
defmodule Helper do |
digits = inp | |
|> String.codepoints() | |
|> (fn [hd | tl] -> [hd | tl] ++ [hd] end).() | |
|> Enum.map(&String.to_integer/1) | |
|> Enum.chunk_every(2, 1, :discard) | |
|> Enum.filter(fn [a, b] -> a == b end) | |
|> Enum.map(&List.first/1) | |
|> Enum.sum | |
|> IO.inspect() |
def reindex(self, entities): | |
# Note - for some period of time, this doubles the memory usage of your ES cluster | |
# If this is a problem, the ES reindex function can take source/destination cluster so you can | |
# throw away the entire old cluster after everything is migrated. | |
# This assumes you use an alias (shown as `self.index` in this example) for your API calls | |
# 1. Create a new index with a unique name | |
# Set all of the index settings on the new index | |
# Set all of the doctype mappings on it | |
# 2. Use the Elasticsearch reindex helper to copy all documents over to new index |
{- | |
Very basic single-file binary file uploading via Elm port. | |
One area for improvement is in error handling. Since I only care if a file | |
uploads successfully, that's all I'm passing in the callback port. | |
One known issue is since we execute the port on "change", uploading | |
the same file multiple times in a row will not have any affect since | |
the DOM element doesn't "change" if the same file gets selected. |
package main | |
import ( | |
"os" | |
"bufio" | |
"fmt" | |
"strings" | |
) | |
type Stack struct { |
class Integer | |
def palindrome? | |
return self.to_s == self.to_s.reverse | |
end | |
end |