Skip to content

Instantly share code, notes, and snippets.

View bingoabs's full-sized avatar

Joe Zhou bingoabs

  • China
  • 12:31 (UTC -12:00)
View GitHub Profile
@HauptJ
HauptJ / openresty.service
Created June 21, 2018 18:02
OpenResty Systemd service file
# Stop dance for OpenResty
# A modification of the Nginx systemd script
# Source: https://www.digitalocean.com/community/tutorials/how-to-use-the-openresty-web-framework-for-nginx-on-ubuntu-16-04
# =======================
#
# ExecStop sends SIGSTOP (graceful stop) to the Nginx process.
# If, after 5s (--retry QUIT/5) OpenResty is still running, systemd takes control
# and sends SIGTERM (fast shutdown) to the main process.
# After another 5s (TimeoutStopSec=5), and if OpenResty is alive, systemd sends
# SIGKILL to all the remaining processes in the process group (KillMode=mixed).
@chrismccord
chrismccord / upgrade.md
Last active April 7, 2023 12:03
Phoenix 1.2.x to 1.3.0 Upgrade Instructions

If you want a run-down of the 1.3 changes and the design decisions behidn those changes, check out the LonestarElixir Phoenix 1.3 keynote: https://www.youtube.com/watch?v=tMO28ar0lW8

To use the new phx.new project generator, you can install the archive with the following command:

$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez

Bump your phoenix dep

Phoenix v1.3.0 is a backwards compatible release with v1.2.x. To upgrade your existing 1.2.x project, simply bump your phoenix dependency in mix.exs:

@lau
lau / simple_time_zone_list.ex
Last active April 15, 2021 07:41
Simple city to time zone mapping from Rails. As an Elixir map.
# Could be used for instance like this in Phoenix: <%= select f, :time_zone, SimpleTimeZoneList.mapping %>
defmodule SimpleTimeZoneList do
@mapping %{
"International Date Line West" => "Pacific/Midway",
"Midway Island" => "Pacific/Midway",
"American Samoa" => "Pacific/Pago_Pago",
"Hawaii" => "Pacific/Honolulu",
"Alaska" => "America/Juneau",
"Pacific Time (US & Canada)" => "America/Los_Angeles",
"Tijuana" => "America/Tijuana",
@blogscot
blogscot / xml_parsing.ex
Last active December 1, 2018 17:49
A first look at XML parsing using Elixir
defmodule XmlParsing do
import Record, only: [defrecord: 2, extract: 2]
defrecord :xmlElement, extract(:xmlElement, from_lib: "xmerl/include/xmerl.hrl")
defrecord :xmlText, extract(:xmlText, from_lib: "xmerl/include/xmerl.hrl")
def xml do
"""
<html>
<head>
@bingoabs
bingoabs / py.py
Created March 4, 2016 05:48
python interview questions
# encoding: utf8
# 什么是lambda函数?它有什么好处?另外python在函数式编程方面提供了些什么函数和语法?
# - lambda 就是匿名函数
# - 好处: 可以动态生成一个函数对象,不用给这个对象命名,污染名字空间
# - 函数:map()/filter()
# - 语法:可以函数内部定义函数,闭包支持
# 详细说说tuple、list、dict的用法,它们的特点;
# - tuple 固定长度的子项不可变的顺序型容器,一般用来做常量(策划配表)或者表示少量属性的对象(比如pos)表示
@karpathy
karpathy / min-char-rnn.py
Last active May 22, 2024 08:28
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)