Skip to content

Instantly share code, notes, and snippets.

tyamaguchi tkfm-yamaguchi

Block or report user

Report or block tkfm-yamaguchi

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
@tkfm-yamaguchi
tkfm-yamaguchi / my-combination.rb
Last active Dec 3, 2019
RIoW for Array#combination, but it is a single method.
View my-combination.rb
require "test/unit"
def combination(a, k)
return a.map{|n| [n] } if k == 1
a[0..(a.size - k)].each_with_index.reduce([]) do |c, (n, i)|
c + combination(a[i.succ..-1], k - 1).map{|r| [n, *r]}
end
end
@tkfm-yamaguchi
tkfm-yamaguchi / MyController.php
Last active Nov 26, 2019
the simplest form of Symfony controller
View MyController.php
<?php
namespace AppBundle\Controller;
use Exception;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
@tkfm-yamaguchi
tkfm-yamaguchi / duplicateds.md
Last active Feb 18, 2019
duplicated homebrew formulae
View duplicateds.md

Errors while executing brew update

fatal: could not read Username for 'https://github.com': terminal prompts disabled
fatal: could not read Username for 'https://github.com': terminal prompts disabled
fatal: could not read Username for 'https://github.com': terminal prompts disabled
fatal: could not read Username for 'https://github.com': terminal prompts disabled
Error: Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-boneyard failed!
Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-completions failed!
Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-fuse failed!
View needs-to-fix.md

Needs To Fix

  • vim-jsx-typescript
    • syntax/indent: would be broken when {} to execute JS/TS
    • syntax/indent: would be broken when no value attribute is specified
@tkfm-yamaguchi
tkfm-yamaguchi / open_dir_with_vaffle.vim
Last active Feb 5, 2019
Open dir with vaffle when dir is specified while starting vim
View open_dir_with_vaffle.vim
" Open vaffle when the first buffer is a directory
" (the directory name is specified as a argument in terminal)
function! s:open_dir_with_vaffle()
let l:bufName = bufname('%')
if (isdirectory(l:bufName))
execute "Vaffle " . l:bufName
endif
endfunction
@tkfm-yamaguchi
tkfm-yamaguchi / index.html
Last active Jan 23, 2019
OwlCarousel's bug when {loop: false, autoWidth: true} (reproduction & workaround)
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Workaround for OwlCarousel's autoWidth:true/loop:false bug</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.min.css">
<style>
/* common style */
.carousel-item {
@tkfm-yamaguchi
tkfm-yamaguchi / run_terms.vim
Created Jan 22, 2019
Create tab for terminals within js project
View run_terms.vim
function! RunTerms()
-tabnew
terminal ++close ++curwin yarn start
terminal ++close yarn test
" use `term_start` to set 'cwd' option
vertical call term_start('http-server -p 8000 --cors', {'cwd': 'data', 'term_finish': 'close'})
endfunction
@tkfm-yamaguchi
tkfm-yamaguchi / flatten_with_loop.rb
Last active Dec 28, 2018
flatten with loop (no recursion)
View flatten_with_loop.rb
class Array
# flatten without recursion but loop
def myflatten!
i = 0
while i < self.size
unless self[i].is_a?(Array)
i += 1
next
end
View recover-file-removed.sh
sudo grep -i -a -B 100 -A 100 'string' /dev/sda1 > file.txt
# or
# sudo grep -F -a -C 100 'string' /dev/sda1 > file.txt
# ref:
# https://unix.stackexchange.com/questions/2677/recovering-accidentally-deleted-files
@tkfm-yamaguchi
tkfm-yamaguchi / apt-redis-issue.md
Created Dec 12, 2018
Can't upgrade/purge redis server on Debian/Ubuntu (apt adapting distros)
View apt-redis-issue.md

Situation

  • Upgrading redis-server is failed with apt upgrade.
  • apt purge redis-server is failed

The reason for the failure of both apt command above is something is timeout.

Solution (one of)

You can’t perform that action at this time.