- Upgrading redis-server is failed with
apt upgrade. apt purge redis-serveris failed
The reason for the failure of both apt command above is something is timeout.
| 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 |
| 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 |
| # Detects whether the x/y coordinates of points in VTK are all different. | |
| # | |
| # @params {string} vtk path to VTK file | |
| # @return {boolean} | |
| def all_coords_uniq?(vtk) | |
| File.open(vtk, "r") do |f| | |
| points_count = 0 | |
| while line = f.gets.chomp | |
| if line =~ /^POINTS/ | |
| points_count = line.split[1].to_i |
| module RuboCop | |
| module Formatter | |
| class EmacsStyleFormatter < BaseFormatter | |
| def file_finished_with_relative_path(file, offenses) | |
| path = Pathname(file).relative_path_from(Pathname.pwd).to_s | |
| file_finished_without_relative_path(path, offenses) | |
| end | |
| alias file_finished_without_relative_path file_finished |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Prototping with React</title> | |
| </head> | |
| <body> | |
| <div id="app"></div> | |
| <script crossorigin src="https://unpkg.com/react/umd/react.development.js"></script> |
| # https://codingbat.com/python/List-1 | |
| # https://codingbat.com/python/Logic-1 | |
| # https://codingbat.com/python/Logic-2 | |
| # https://codingbat.com/python/String-2 | |
| # https://codingbat.com/python/List-2 | |
| def cigar_party(cigars, is_weekend): | |
| if is_weekend: | |
| return cigars >= 40 | |
| else: |
| class String | |
| # number of characters where the multi-byte string is counted by 2 | |
| def mbsize | |
| chars.sum{|str| str.bytesize == 1 ? 1 : 2 } | |
| end | |
| def mbljust(num, char=" ") | |
| return self if mbsize > num | |
| self + char * (num - mbsize) |
| # == ping プログラムの(?)仕様についての確認スクリプト | |
| # | |
| # $ ping 2915182161 | |
| # | |
| # を実行すると, | |
| # | |
| # $ ping 173.194.38.81 | |
| # | |
| # を実行したのと同じように扱われる. これは ping が引数をドット(`.`)を桁区切りとする 256 進数と同値であるため. | |
| # 以下は, 2915182161 (10進数) が 173.194.38.81 (256進数) と同値であることを示すスクリプト. |
| "method" | |
| "a" | |
| "local-variable" | |
| nil |