Skip to content

Instantly share code, notes, and snippets.

@developerworks
developerworks / last_names.exs
Created March 1, 2016 09:25
Generate last name
require Logger
defmodule LastName do
def main do
last_names = ~w(
赵 钱 孙 李 周 吴 郑 王 冯 陈 褚 卫 蒋 沈 韩 杨 朱 秦 尤 许
何 吕 施 张 孔 曹 严 华 金 魏 陶 姜 戚 谢 邹 喻 柏 水 窦 章
云 苏 潘 葛 奚 范 彭 郎 鲁 韦 昌 马 苗 凤 花 方 俞 任 袁 柳
酆 鲍 史 唐 费 廉 岑 薛 雷 贺 倪 汤 滕 殷 罗 毕 郝 邬 安 常
乐 于 时 傅 皮 卞 齐 康 伍 余 元 卜 顾 孟 平 黄 和 穆 萧 尹
姚 邵 湛 汪 祁 毛 禹 狄 米 贝 明 臧 计 伏 成 戴 谈 宋 茅 庞
@developerworks
developerworks / gist:721aac2670caa64ea4c0
Last active November 4, 2015 07:22
Compute the avg cpu load
defmodule Test do
require Logger
def get_normalized_load do
:application.ensure_all_started(:os_mon)
loads = [:cpu_sup.avg1, :cpu_sup.avg5, :cpu_sup.avg15] |> Enum.map(fn x ->
x / :erlang.system_info(:logical_processors) / 256
end)
Logger.debug "Loads: #{inspect loads}"
loads
end
@developerworks
developerworks / api_bridge.ex
Created November 3, 2015 17:33 — forked from upbit/api_bridge.ex
Module for rpc call remote api@node functions
defmodule ApiBridge do
@moduledoc """
Module for rpc call remote api@node functions.
"""
@defualt_rpc_timeout 3000
@doc """
rpc macro for api call
"""
defmacro rpc(exp, timeout \\ @defualt_rpc_timeout) do
=INFO REPORT==== 1-Nov-2015::00:08:29 ===
application: logger
exited: stopped
type: temporary
** (Mix) Could not start application elixir_distribution_application_exmaple: ElixirDistributionApplicationExmaple.start({:takeover, :"b@192.168.8.104"}, []) returned an error: shutdown: failed to start child: ElixirDistributionApplicationExmaple.Worker
** (EXIT) already started: #PID<2971.167.0>
```
EXCEPTION: Error during instantiation of Token(Promise<ComponentRef>)!.
angular2.dev.js:25219 EXCEPTION: Error during instantiation of Token(Promise<ComponentRef>)!.execute.$__super.logError @ angular2.dev.js:25219execute.$__super.logGroup @ angular2.dev.js:25230execute.ExceptionHandler.call @ angular2.dev.js:20915(anonymous function) @ angular2.dev.js:27344run @ angular2.dev.js:136execute.$__3._createInnerZone.zone.fork.fork.$run @ angular2.dev.js:16593execute.$__3.run @ angular2.dev.js:16556commonBootstrap @ angular2.dev.js:27321(anonymous function) @ show-properties.ts:53(anonymous function) @ show-properties.ts:53__exec @ system.src.js:1384entry.execute @ system.src.js:3502linkDynamicModule @ system.src.js:2905link @ system.src.js:2748Promise.all.then.normalizedDeps.execute @ system.src.js:3076doDynamicExecute @ system.src.js:715link @ system.src.js:916doLink @ system.src.js:569updateLinkSetOnLoad @ system.src.js:617(anonymous function) @ system.src.js:430run @ angular2.dev.js:136zoneBoundFn @ angular
@developerworks
developerworks / landscape_errors
Created July 3, 2015 05:04
Deploy landscape errors output
[DEBUG • 07-03 11:18:51] • cloudinstall.ui.dialog • (dialog.py, _build_widget, 93)]
Num items: 2, items: <ListBox selectable box widget>
[DEBUG • 07-03 11:18:54] • cloudinstall.ui.dialog • (dialog.py, submit, 111)]
Callback on : OrderedDict([('password', <EditInput selectable flow widget>), ('confirm_password', <EditInput selectable flow widget>)])
[DEBUG • 07-03 11:18:56] • cloudinstall.ui • (__init__.py, submit, 214)]
Callback on : OrderedDict([('Landscape OpenStack Autopilot', (<RadioButton selectable flow widget 'Landscape OpenStack Autopilot' state=True>, 'Benefit from best practices in cloud building, and get up and running within minutes, all from an intuitive web UI.')), ('Multi', (<RadioButton selectable flow widget 'Multi' state=False>, 'OpenStack installation utilizing MAAS.')), ('Single', (<RadioButton selectable flow widget 'Single' state=False>, 'Fully containerized OpenStack installation on a single machine.'))])
[INFO • 07-03 11:18:56] • cloudinstall.install • (install.py, do_install
```
def init(args) do
Logger.debug "Starting multicast client with args: #{inspect args}"
case :gen_udp.open(@dvb_client_port, @client_socket_opts) do
{:ok, client_socket} ->
state = %{
client_socket: client_socket,
packets: 0,
last_received_time: nil
}
## Npm install error: Cannot find module
...
...
...
npm http fetch GET https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz
npm http request GET https://registry.npmjs.org/delayed-stream
npm http request GET https://registry.npmjs.org/mime-db
npm http request GET https://registry.npmjs.org/async
/**
* http://blog.nodejitsu.com/npmawesome-9-gulp-plugins/
* http://code.tutsplus.com/tutorials/managing-your-build-tasks-with-gulpjs--net-36910
* http://www.smashingmagazine.com/2014/06/11/building-with-gulp/
* http://blog.jobbole.com/80338/
*
* @type {exports}
*/
var path = require('path');
var gulp = require('gulp');
defmodule UserSystem.Mixfile do
use Mix.Project
def project do
[app: :user_system,
version: "0.0.1",
elixir: "~> 1.0",
elixirc_paths: ["lib", "web"],
compilers: [:phoenix] ++ Mix.compilers,
deps: deps]