Look at LSB init scripts for more information.
Copy to /etc/init.d
:
# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
# For 0000 0001 0100 0000 1000 1000 | |
# The result is 0b1 + 0b100_0000 + 0b1000 = 73 | |
defmodule BinaryParseFast do | |
def parse(bin) do | |
parse(bin, 0) | |
end | |
# def parse(<<0::1, x::7, _::bits>>, acc), do: acc + x | |
# def parse(<<1::1, x::7, rest::bits>>, acc) do | |
# parse(rest, acc + x) |
defmodule Foo do | |
Enum.each(1..100, fn i -> | |
def field(unquote(:"foo#{i}")) do | |
"field #{unquote(i)}" | |
end | |
def unquote(:"field_foo#{i}")() do | |
"field #{unquote(i)}" | |
end | |
end) |
var protobuf = require('protobufjs'); | |
protobuf.load("test.proto", function (err, root) { | |
if (err) | |
throw err; | |
var Message = root.lookupType("test.Message"); | |
var payload = { foo1: 123.0, foo2: 123.5 }; | |
var errMsg = Message.verify(payload); |
defmodule Sentry.Fingerprinter do | |
def custom_fingerprints(metadata, _msg) do | |
file = Keyword.get(metadata, :file) | |
line = Keyword.get(metadata, :line) | |
if file && line do | |
%{ | |
application: Keyword.get(metadata, :application), | |
module: Keyword.get(metadata, :module), | |
function: Keyword.get(metadata, :function), |
export PS1="\\u@\\h:\\w:\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)\$ " | |
#set-option -g mouse on | |
setw -g mode-keys vi | |
bind-key -Tcopy-mode-vi 'v' send -X begin-selection | |
bind-key -Tcopy-mode-vi 'y' send -X copy-selection | |
# set -g terminal-overrides 'xterm*:smcup@:rmcup@' | |
## Debian apt |
defmodule Foo do | |
def foo1(bin, arg \\ 0) do | |
case do_foo1(bin) do | |
{:end, bin} = r -> | |
{r, arg} | |
{a, rest} -> | |
foo1(rest, arg + 1) | |
end | |
end |
package main | |
import ( | |
"log" | |
"os" | |
"sync" | |
"time" | |
"golang.org/x/net/context" | |
"google.golang.org/grpc" |
require 'google/protobuf/timestamp_pb' | |
# Use official Message.new() instead | |
class Pb | |
class << self | |
def message_to_pb(message, msg_klass) | |
unless msg_klass.ancestors.include?(Google::Protobuf::MessageExts) | |
raise ArgumentError, "message class should be a pb message" | |
end | |
if msg_klass == Google::Protobuf::Timestamp && message.is_a?(::Time) |
Look at LSB init scripts for more information.
Copy to /etc/init.d
:
# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
# https://github.com/ipaddress-gem/ipaddress | |
require 'ipaddress' | |
class Calculator | |
def self.run(top, parts: nil, prefixes: nil) | |
top = IPAddress(top) | |
subnets = by_parts(top, parts) if parts | |
subnets = by_prefixes(top, prefixes) if prefixes | |
subnets | |
end |