Skip to content

Instantly share code, notes, and snippets.

View genya0407's full-sized avatar

Yusuke Sangenya genya0407

View GitHub Profile
#
# Ubuntu 20.04 requires at least `gcc-mingw-w64-x86-64` package as a
# cross compiler.
#
MRuby::CrossBuild.new("cross-mingw") do |conf|
conf.toolchain :gcc
conf.host_target = "x86_64-w64-mingw32"
conf.cc.command = "#{conf.host_target}-gcc-posix"
conf.linker.command = conf.cc.command
@ftpmorph
ftpmorph / Details and config tips.txt
Last active April 22, 2024 19:47
Amazon AWS S3 IAM permissions required for Mastodon
When setting up a Mastodon instance I had a very hard time working out the required S3 permissions.
Wasted a day on it. None of the tutorials or even the official documentation gave me this information.
In the end I gave up and just gave it blanket access to all permissions for the Mastodon bucket (S3Administrator).
But this didn't set well with me - I don't like granting unnecessary permissions, especially not when S3 has about 100 of them.
If the server were to become compromised or the keys were to otherwise fall into the wrong hands I'd want a potentially malicious actor to have as limited permissions as possible.
Anyway I finally worked out the permissions required to for Mastodon to function with an S3 bucket as its media storage.
See below for the IAM policy.
@pocke
pocke / steep.rake
Created February 23, 2020 10:59
Steepで解析できる型定義ファイルを生成する 2020-02-23版
namespace :steep do
task gen: %i[base copy ar2rbs path_helper]
task :base do
require 'ruby/signature'
sig_base_path = Rails.root.join('sig/base.rbs')
files = Dir.glob(['app/**/*.rb', 'lib/**/*.rb']).sort
sh 'bundle', 'exec', 'rbs', 'prototype', 'rb', *files, :out => sig_base_path.to_s
@npearce
npearce / install-docker.md
Last active April 19, 2024 12:35
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
@rafaels88
rafaels88 / factory_girl_helper.rb
Last active March 3, 2019 21:21
Factory Girl helper to work with Hanami Framework
# USAGE
# 1. Add 'factory_girl' in Gemfile as a dependency. But here, be careful. Factory Girl adds Active Support
# as its dependency, so it is up to you add it in :development and :test group or add it for all envs.
# For more details, read the comment from @cllns below.
# 2. Save this file in '/spec';
# 3. Load this file in 'spec_helper.rb' as the last require in the file, using:
# require_relative './factory_girl_helper'
@0frasure
0frasure / cdn.html
Created October 8, 2015 21:16
Material Design Icons CDN
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
@kjunichi
kjunichi / mruby_block.md
Last active December 5, 2022 14:29
mrubyでC言語でブロックを扱うには

C言語側でブロックを定義するには

関数をmrubyのブロックとして扱える。

mrb_value myfunc(mrb_state *mrb, mrb_value obj) {
  printf("myfunc: start\n");
  
  printf("myfunc: end\n");
@chibicode
chibicode / Sublime Textの検索窓に日本語を入力する方法.md
Created July 26, 2014 03:27
Sublime Textの検索窓に日本語を入力する方法

Sublime Textの検索窓に日本語を入力するとEnterを押すなり文字が消えてしまうのですが、無理やり解決する方法を見つけました。ググってもこちらのバグレポートしか見つからなかったので報告です。

わたしの環境はMac OS XのSublime Text 3 (Build 3059)ですが、この解決方法はSublime Text 2 (Build 2220)にも対応しています。Windowsの場合は不明です。

ステップ1: Sublime Text 3の場合のみ: Default (OSX).sublime-keymapを編集可能にする

このステップはSublime Text 3の場合のみ必要です。Sublime Text 2の場合はステップ2に行って下さい。

@dvliman
dvliman / gist:10402435
Created April 10, 2014 17:02
ruby $ global variable
$: (Dollar Colon) is basically a shorthand version of $LOAD_PATH. $: contains an array of paths that your script will search through when using require.
$0 (Dollar Zero) contains the name of the ruby program being run. This is typically the script name.
$* (Dollar Splat) is basically shorthand for ARGV. $* contains the command line arguments that were passed to the script.
$? (Dollar Question Mark) returns the exit status of the last child process to finish.
$$ (Dollar Dollar) returns the process number of the program currently being ran.
$~ (Dollar Tilde) contains the MatchData from the previous successful pattern match.
$1, $2, $3, $4 etc represent the content of the previous successful pattern match.
$& (Dollar Ampersand) contains the matched string from the previous successful pattern match.
$+ (Dollar Plus) contains the last match from the previous successful pattern match.
$` (Dollar Backtick) contains the string before the actual matched string of the previous successful pattern match.
@cobyism
cobyism / gh-pages-deploy.md
Last active May 3, 2024 19:07
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).