Skip to content

Instantly share code, notes, and snippets.

Avatar
👺
hmmmmmm

Kouji OKAMOTO motchang

👺
hmmmmmm
View GitHub Profile
View main.java
public class Main implements HtwMessageReceiver {
private static HuntTheWumpusgame;
private static inthitPoints=10;
private static final List<String> caverns = new ArrayList<>();
private static final String[] environments = new String[] {
"bright",
"humid",
"dry",
"creepy",
"ugly",
View main.rs
use std::{time, thread};
fn main() {
let n1 = 1200;
let n2 = 1000;
// spawn で子スレッドを立ち上げ、子スレッドで重い処理を実行する
// 変数 child がスレッドへのハンドルに束縛される
// let child = thread::spawn(move || {
// // 重い処理を実行する
@motchang
motchang / E0277.ja.md
Last active May 27, 2020
機械翻訳
View E0277.ja.md

You tried to use a type which doesn't implement some trait in a place which expected that trait.

何らかの trait を実装していない型を、その trait を期待していた場所で使おうとしました

Erroneous code example:

// here we declare the Foo trait with a bar method
// ここで Foo trait を bar メソッドと共に宣言しています
@motchang
motchang / bm.rb
Last active Jun 20, 2019
big set
View bm.rb
require 'set'
require 'benchmark'
Benchmark.bm 10 do |r|
limit = 65535*1000
r.report "to_a" do
(1..limit).to_a
end
r.report "to_set" do
(1..limit).to_set
@motchang
motchang / personal_motchang.json
Created Sep 14, 2018
左 Option を単体で押した時に英数キーにする
View personal_motchang.json
{
"title": "Personal rules @motchang",
"rules": [
{
"description": "左 Option を単体で押した時に英数キーにする",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "left_option",
View helm.el
;;; package --- Summary
;;; Commentary:
;;; Code:
(when (require 'helm-config nil t)
(helm-mode 1)
(global-set-key (kbd "M-x") #'helm-M-x)
(global-set-key (kbd "C-x r b") #'helm-filtered-bookmarks)
(global-set-key (kbd "C-x C-f") #'helm-find-files)
(global-set-key (kbd "C-x b") #'helm-mini)
View micropost.rb
class Micropost < ApplicationRecord
belongs_to :user
before_save { self.in_reply_to = reply_user }
default_scope -> { order(created_at: :desc) }
mount_uploader :picture, PictureUploader
validates :user_id, presence: true
validates :content, presence: true, length: { maximum: 140 }
validate :picture_size
scope :including_replies, ->(user) { where("user_id = ? OR (user_id IN (SELECT followed_id FROM relationships WHERE follower_id = ?) AND (in_reply_to = ? OR in_reply_to LIKE ?))", user.id, user.id, "", "%@#{user.id}\-#{user.name.sub(/\s/,'-').downcase}%" ) }
View deep_cache.rb
#
# USAGE1:
# User.find(1).deepcache.friends.count.fetch
#
# 上記のような呼び出しをすると以下のキーで Redis に問い合わせてなければキャッシュします。
# get deepcache:User:1:friends.count
#
# USAGE2:
# Category.deepcache.co_cats.where(slug: URI.encode(request_manager.params['slug'] || '')).limit(1).to_a.fetch
#
View crontab
5 9 * * * root /sbin/swapoff -a && /root/bin/mkswap.sh
@motchang
motchang / xvfb.sh
Last active Jun 17, 2016
/etc/init.d/xvfb
View xvfb.sh
#!/bin/bash
#
# Xvfb
#
# chkconfig: - 90 30
# description: Xvfb
# Source function library.
. /etc/init.d/functions
lockfile="/var/lock/subsys/xvfb"
You can’t perform that action at this time.