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
defmodule Hello.Repo do | |
use Ecto.Repo, | |
otp_app: :hello, | |
adapter: Ecto.Adapters.Postgres | |
@doc """ | |
Reverse a preload. | |
## Example |
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 datetime import datetime | |
import binascii | |
import logging | |
import io | |
def _parse_fields(raw): | |
"""Return a iterators of (id, value).""" | |
raw = io.BytesIO(raw) | |
while True: |
NetworkManager supports WiFi powersaving but the function is rather undocumented.
From the source code: wifi.powersave can have the following value:
- NM_SETTING_WIRELESS_POWERSAVE_DEFAULT (0): use the default value
- NM_SETTING_WIRELESS_POWERSAVE_IGNORE (1): don't touch existing setting
- NM_SETTING_WIRELESS_POWERSAVE_DISABLE (2): disable powersave
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
defmodule MyappWeb.AlbumController do | |
use MyappWeb, :controller | |
use Filterable.Phoenix.Controller | |
import ShorterMaps | |
alias Myapp.Accounts | |
alias Myapp.Accounts.Album | |
action_fallback(MyappWeb.FallbackController) | |
filterable(Myapp.AlbumFilters) |
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 elixir:1.6.5 | |
ENV NODE_VERSION 8.x | |
ENV NPM_VERSION 6.1.0 | |
ENV PHOENIX_VERSION 1.3.2 | |
RUN curl -sL https://deb.nodesource.com/setup_${NODE_VERSION} | bash \ | |
&& apt-get install -y nodejs | |
RUN npm install npm@${NPM_VERSION} -g |
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
# For each database: | |
ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci; | |
# For each table: | |
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | |
# For each column: | |
ALTER TABLE table_name CHANGE column_name column_name VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | |
# (Don’t blindly copy-paste this! The exact statement depends on the column type, maximum length, and other properties. The above line is just an example for a `VARCHAR` column.) |
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
defmodule XmlNode do | |
require Record | |
Record.defrecord :xmlAttribute, Record.extract(:xmlAttribute, from_lib: "xmerl/include/xmerl.hrl") | |
Record.defrecord :xmlText, Record.extract(:xmlText, from_lib: "xmerl/include/xmerl.hrl") | |
def from_string(xml_string, options \\ [quiet: true]) do | |
{doc, []} = | |
xml_string | |
|> :binary.bin_to_list | |
|> :xmerl_scan.string(options) |
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
defmodule Crypto do | |
def md5(data) do | |
Base.encode16(:erlang.md5(data), case: :lower) | |
end | |
end |
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
//This is a WeChat miniprogram client transport for phoenix.js | |
// so that you can use easily use Phoenix Channel as a WebSocket server. | |
// Written by @chrismccord | |
// example usage: | |
// ``` | |
// let socket = new Socket("ws://localhost:4000/socket", { transport: WxSocket }) | |
// socket.connect() | |
// let channel = socket.channel("room:lobby", {}) | |
// channel.join() | |
// .receive("ok", resp => { console.log("Joined successfully", resp) }) |
NewerOlder