Skip to content

Instantly share code, notes, and snippets.

(function (root, ns, factory) {
if (typeof exports === 'object' && typeof module === 'object') {
module.exports = factory(require('vue'));
} else if (typeof define === 'function' && define.amd) {
define(['vue'], factory);
} else if (typeof exports === 'object') {
exports[ns] = factory(require('vue'));
} else {
root[ns] = factory(root.Vue);
}
@sjava
sjava / how-to-fix-tmux-fail.md
Created January 24, 2018 15:10 — forked from sv0/how-to-fix-tmux-fail.md
If tmux fails with an error "terminal open failed: missing or unsuitable terminal: rxvt-unicode-256color"

If tmux fails with an error terminal open failed: missing or unsuitable terminal: rxvt-unicode-256color

log in to your remote host and create .terminfo/r in your home directory:

mkdir .terminfo/r

copy terminal information file to remote machine:

scp /usr/share/terminfo/r/rxvt-unicode* remote.host:.terminfo/r/

@sjava
sjava / 256 colors.md
Created January 30, 2018 01:29 — forked from limingjie/256 colors.md
256 colors in putty, tmux/screen and vim

#256 colors in putty, tmux/screen and vim There is a detailed answer on stackoverflow. If you are looking for a short one, here it is.

  • putty

    Set Connection -> Data -> Terminal-type string to xterm-256color

  • tmux

Add this line to ~/.tmux.conf

@sjava
sjava / check_uwsgi.sh
Created June 21, 2018 07:45 — forked from SuneKjaergaard/check_uwsgi.sh
Small shell script to restart the uWSGI application when https://github.com/unbit/uwsgi/issues/1369 happens. Based on uWSGI server run by upstart
#!/bin/bash
line=$(tail -1 /var/log/myapp/myapp.uwsgi.log)
substr='uWSGI listen queue of socket'
if test "${line#*$substr}" != "$line"
then
#We're using upstart, could be easily adapted to fx systemd
# Adding a log statement to keep track of when this happens. Remember to create the monitor dir
/sbin/initctl restart myapp > /var/log/myapp/monitor/uwsgi-monitor.log 2>&1
echo "$(date) restarted myapp due to listen queue error" >> /var/log/myapp/monitor/uwsgi-monitor.log
//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) })
@sjava
sjava / crypto.ex
Created July 31, 2018 12:05 — forked from ourway/crypto.ex
Md5 in Elixir
defmodule Crypto do
def md5(data) do
Base.encode16(:erlang.md5(data), case: :lower)
end
end
@sjava
sjava / xmerl_demo.ex
Created August 5, 2018 16:01 — forked from sasa1977/xmerl_demo.ex
Simple xmerl usage demo in Elixir
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)
@sjava
sjava / convert_utf8_to_utf8mb4
Created September 25, 2018 16:21 — forked from dschneider/convert_utf8_to_utf8mb4
How to easily convert utf8 tables to utf8mb4 in MySQL 5.5
# 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.)
@sjava
sjava / Dockerfile
Created November 1, 2018 03:17
docker-for-phoenix
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
@sjava
sjava / album.ex
Created March 12, 2019 14:30
scroll happend error
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)