Skip to content

Instantly share code, notes, and snippets.

@remiq
remiq / Analyzing_erl_crash_dump.md
Created May 20, 2016 01:20
Analyzing erl_crash.dump with WxTool and Elixir console
iex(1)> :crashdump_viewer.start
// pick file
@remiq
remiq / enumex.ex
Created May 15, 2016 13:28
Enum.map with error handling
defmodule EnumEx do
@doc """
Executes `fun` for each `list` element (just like `map`), but if one iter fails,
then aborts everything and returns first error.
`fun` must return {:ok, result} | {:error, error}
"""
def map_or_error(list, fun) do
result = Enum.reduce(list, [], fn
i, acc when is_list(acc) ->
@remiq
remiq / remote.ex
Created November 2, 2015 10:23
Client API for Remote GenServer
def get do
try do
{:ok, GenServer.call(__MODULE__, :get)}
catch
:exit, {reason, _} ->
{:error, reason}
end
end
def get! do
@remiq
remiq / message.js
Created October 31, 2015 15:42
React's Message class for parsing links
class Message extends React.Component {
parseLinks(body) {
body = body.split(/(http[^ ]+)/)
body = body.map(function(url) {
if (url.match(/(http[^ ]+)/)) {
var href = "/r?url=" + encodeURIComponent(url)
var key = Math.random()
return <a key={key} href={href} target="_blank">{url}</a>
} else {
return url
@remiq
remiq / mix.exs
Created October 24, 2015 11:38
Releasing Phoenix with Mix aliases
defmodule PhoenixApp.Mixfile do
use Mix.Project
def project do
[app: :phoenix_app,
# ...
aliases: aliases,
deps: deps]
end
@remiq
remiq / nginx.conf
Created October 22, 2015 16:57
Nginx config for Phoenix Channels
upstream phoenix {
server phoenix:8003;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
@remiq
remiq / TeleportingRadio.sprak
Created September 30, 2015 19:55
Teleporting Radio for Else Heart.Break()
# Else Heart.Break()
# Teleporting radio
# Valid items:
# - standard radio
# Requires:
# - this script: https://gist.github.com/remiq/3e53aaa3e5a80029fe81
# installed on: PoliceOfficeInterior_MinistryOfficeWorkstationComputer_1
var tp = Connect("PoliceOfficeInterior_MinistryOfficeWorkstationComputer_1")
tp.Teleport("PoliceOfficeInterior")
#tp.Teleport("TownHall")
@remiq
remiq / MissingPersonFinderV2.sprak
Last active March 29, 2023 04:49
Alternative MissingPersonFinder for Else Heart.Break()
# Else Heart.Break()
# Alternative MissingPersonFinder
# Valid computers:
# - (PoliceOfficeInterior) PoliceOfficeInterior_MinistryOfficeWorkstationComputer_1
# - (TownHall apartment) Playstation
Menu()
return
bool Menu()
@remiq
remiq / http_get.ex
Created September 11, 2015 22:03
Sending http get request, till it works.
defp get!(url) do
case HTTPoison.get(url) do
{:ok, resp} -> resp
resp ->
IO.inspect {url, resp}
:timer.sleep 5_000
get!(url)
end
end