Skip to content

Instantly share code, notes, and snippets.

MATSUMOTO Eiji mattsan

Block or report user

Report or block mattsan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mattsan
mattsan / ads7846.ex
Created Jul 27, 2019
ADS7846 Touchscreen 用 Scenic.ViewPort.Driver の実装
View ads7846.ex
defmodule ADS7846 do
use Scenic.ViewPort.Driver
alias Scenic.ViewPort
require Logger
defguard is_pos(x, y) when is_number(x) and is_number(y)
@init_retry_ms 400
@device "ADS7846 Touchscreen"
@mattsan
mattsan / serverless.yml
Created Jul 24, 2019
Serverless で layers に gems を配置する
View serverless.yml
service: emattsan
provider:
name: aws
runtime: ruby2.5
stage: ${opt:stage, 'development'}
region: ap-northeast-1
package:
exclude:
@mattsan
mattsan / Gemfile
Created Jul 6, 2019
A sample of Sinatra + Slim
View Gemfile
# frozen_string_literal: true
source 'https://rubygems.org'
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem 'sinatra'
gem 'sinatra-contrib'
gem 'slim'
@mattsan
mattsan / bits.exs
Created Jun 9, 2019
Elixir の Stream.unfold/2 を使って整数をビット列に分解する例
View bits.exs
defmodule Bits do
require Integer
import Integer
import Bitwise
@doc """
A integer value to a bit list.
## example
@mattsan
mattsan / cli.ex
Last active May 25, 2019
[練習] wc (の機能の一部)を C++ で実装してみた
View cli.ex
defmodule ExCount.CLI do
@opts [
strict: [only_line: :boolean],
aliases: [l: :only_line]
]
def main(args) do
args
|> OptionParser.parse(@opts)
|> show_counts()
@mattsan
mattsan / README.md
Created May 19, 2019
Serverless を使った Ruby の AWS Lambda のプロジェクト例
View README.md

Serverless を使った Ruby の AWS Lambda のプロジェクト例

ディレクトリ構成

.
├── handler.rb
├── layers/
│   ├── Gemfile
│   └── Gemfile.lock
@mattsan
mattsan / application.js
Created May 10, 2019
Action Cable + Stimulus
View application.js
require('@rails/ujs').start()
require('turbolinks').start()
import { Controller, Application } from 'stimulus'
import HomeChannel from './home_channel'
class HomeController extends Controller {
static targets = [
'message'
]
@mattsan
mattsan / app.js
Created May 6, 2019
Uikit を使った modal と sortable (Drap & Drop) のスパイク
View app.js
import css from "../css/app.css"
import "phoenix_html"
import UIkit from 'uikit'
document.addEventListener('DOMContentLoaded', function() {
// Uikit のイベントのハンドリング
// Sortable の要素の移動をハンドリング
UIkit.util.on('#chapters', 'moved', (event) => {
console.log(event.detail)
});
@mattsan
mattsan / app.css
Created May 6, 2019
クリックした場所にDOMが移動する (Phoenix + Stimulusjs)
View app.css
.field {
background-color: #eee;
height: 90vh;
width: 100%;
}
.marker {
position: relative;
left: 10px;
height: 10px;
@mattsan
mattsan / greeter.ex
Last active May 5, 2019
Stimulusjs と Channel と Faker を使って 5 秒ごとに挨拶をするサンプル。
View greeter.ex
defmodule StimulusPhxSampleWeb.Greeter do
use GenServer
def start_link(_) do
GenServer.start_link(__MODULE__, %{})
end
def init(state) do
schedule_greeting()
{:ok, state}
You can’t perform that action at this time.