Skip to content

Instantly share code, notes, and snippets.

View spinute's full-sized avatar
๐Ÿ“

Pin spinute

๐Ÿ“
View GitHub Profile
* [ ] BBใ‚ฏใƒชใƒผใƒ 
* <img src='https://cdn.lipscosme.com/image/11a0ea2112bcf726187b88f3-1566360335.png' height=100 width=100></img>
* <img src='https://cdn.lipscosme.com/product/be00332422413a7976f39e80-1561423887.png' height=100 width=100></img>
* <img src='https://cdn.lipscosme.com/product/55c8497f47bacb3c5e142a86-1558342639.png' height=100 width=100></img>
* <img src='https://cdn.lipscosme.com/product/f034e4e28cb7cf0cdc848ee3-1561231278.png' height=100 width=100></img>
* <img src='https://cdn.lipscosme.com/product/822b50a4900b65fe32bfae95-1555073559.png' height=100 width=100></img>
* <img src='https://cdn.lipscosme.com/product/b69b638f0148c573f53c38cd-1561431244.png' height=100 width=100></img>
* <img src='https://cdn.lipscosme.com/image/image2017-12-02-238-561-910.png' height=100 width=100></img>
* <img src='https://cdn.lipscosme.com/product/250259049a1064b6c0219480-1560906967.png' height=100 width=100></img>
* <img src='https://cdn.lipscosme.com/product/0b0be4798fbb467ca04865cd-1561424270.png
package myio
import (
"bufio"
"fmt"
"os"
"strconv"
)
func wordScanner() *bufio.Scanner {

Compatibility is essential in Ruby. So, we need strong evidence when we break it.

I do not think the current behavior is weird.

<something>.abs returns positive value, consistently.

A programmer who knows -i.abs is evaluated as -(i.abs) can get an expected result. As a note, - in -1 is not an operator, so -1.abs == (-1).abs == 1. -i.to_s is also explained in the same way.

I agree that the behavior may be confusing for beginners.

@spinute
spinute / prop_max.erl
Last active November 27, 2018 16:25
prop_max
-module(prop_max).
-include_lib("proper/include/proper.hrl").
% Does not fail
prop_max() ->
?FORALL(L, nonempty_list(term()), begin
lists:last(lists:sort(L)) =:= lists:max(L)
end).
@spinute
spinute / pdf_extract_first_stream.rb
Created October 29, 2017 03:53
pdf_extract_first_stream.rb
require 'origami'
fname = ARGV[0]
puts Origami::PDF.read(fname).pages[0].Contents.data
@spinute
spinute / ida.c
Created August 10, 2017 10:34
search
#include <stdbool.h>
#include <stdio.h>
typedef unsigned char uchar;
typedef uchar Direction;
#define dir_reverse(dir) ((Direction)(3 - (dir)))
#define DIR_N 4
#define DIR_UP 0
#define DIR_RIGHT 1

ใ‚คใƒกใƒผใ‚ธ

ๅ•้กŒใฎๅˆถ็ด„ใ‹ใ‚‰ใ€10ๅ€‹ใฎ้€ฃ็ถšใ™ใ‚‹่ซ–็†ๅค‰ๆ•ฐใฎ็œŸๅฝๅ€คใ ใ‘ใ‚’ไฟๆŒใ—ใฆใŠใ‘ใฐใ€้–ข้€ฃใ™ใ‚‹็ฏ€ใฎๅ……่ถณใ‚’ๅˆคๅฎšใ™ใ‚‹ใ“ใจใŒใงใใ‚‹ใ€‚ ใ“ใฎใ‚ˆใ†ใช10ๆกใฎใ‚ฆใ‚ฃใƒณใƒ‰ใ‚ฆใ‚’ใ‚นใƒฉใ‚คใƒ‰ใ•ใ›ใชใŒใ‚‰ใ€ใ‚ฆใ‚ฃใƒณใƒ‰ใ‚ฆใซๅซใพใ‚Œใ‚‹็ฏ€ใ‚’ๅ……่ถณใ—ใชใ„ใ‚‚ใฎใ‚’ๆฝฐใ—ใฆใ„ใใ€‚

ใƒ–ใƒผใƒซ่ซ–็†ๅผใŒๅ……่ถณๅฏ่ƒฝใงใ‚ใ‚‹ใฎใฏใ€็œŸๅฝๅ€คๅ‰ฒๅฝ“ใฆใฎๅ ดๅˆๅˆ†ใ‘ใฎไบŒๅˆ†ๆœจใ‚’ๆ›ธใ„ใŸใจใใ€ๅฎŒๅ…จใชๅ‰ฒๅฝ“ใฆใงใ‚ใฃใฆ่ซ–็†ๅผใ‚’ๅ……่ถณใ—ใฆใ„ใ‚‹็Šถๆ…‹ใซๅฏพๅฟœใ™ใ‚‹่‘‰ใŒๅญ˜ๅœจใ™ใ‚‹ใจใใงใ‚ใ‚‹ใ€‚ ใ‚ฆใ‚ฃใƒณใƒ‰ใ‚ฆใฎใ‚นใƒฉใ‚คใƒ‰ใฏใ€ไบŒๅˆ†ๆœจใฎๆŽข็ดขใงใ„ใ†ใจใ€ๆŽข็ดขใฎๆทฑใ•ใ‚’1ใคๆทฑใใ—ใฆใ€ๆ นใ‹ใ‚‰่ฆ‹ใŸๅณใฎ้ƒจๅˆ†ๆœจใจๅทฆใฎ้ƒจๅˆ†ๆœจใ‚’ใ€่‘‰ใฎorใ‚’ๅ–ใฃใฆ้‡ใญๅˆใ‚ใ›ใ‚‹ใ“ใจใซๅฏพๅฟœใ™ใ‚‹ใ€‚ ใ“ใ†ใ™ใ‚‹ใจใ€ๆœจใ‚’ๅœง็ธฎใ—ใชใŒใ‚‰ๅ…จๆŽข็ดขใ‚’่กŒใˆใ‚‹ใŸใ‚ใ€็ทšๅฝขๆ™‚้–“ใงๅ‡ฆ็†ใ‚’็ต‚ใˆใ‚‰ใ‚Œใ‚‹ใ€‚

ๆง‹้€ 

Aใฏใ€ใ‚ใ‚‹็œŸๅฝๅ€คๅ‰ฒใ‚Šๅฝ“ใฆใซใ‚ˆใฃใฆใ€ใใ‚Œใพใงใซๅˆคๅฎšใ—ใŸ่ซ–็†ๅผใ‚’ๅ……่ถณใ™ใ‚‹ใ“ใจใŒใงใใ‚‹ใ‹ใฉใ†ใ‹ใ‚’่กจ็พใ—ใฆใ„ใ‚‹ใ€‚

require 'pp'
require 'benchmark'
def merge(a, b)
ai = bi = 0
ret = []
until a[ai].nil? || b[bi].nil?
if a[ai] < b[bi]
ret << a[ai]
@spinute
spinute / temp_fifo.cc
Created November 29, 2015 07:24
why samurai_coding_2015 software doesn't work in OSX
#include <fstream>
#include <iostream>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
using namespace std;
string
get_cd(void)
@spinute
spinute / main.rb
Created October 31, 2015 14:49
code runner qual B
require 'net/http'
require 'uri'
require 'json'
$enter = "http://game.coderunner.jp/enter?token=#{token}"
$info = "http://game.coderunner.jp/infoJson?token=#{token}"
def check()
uri = URI.parse($info)
json = Net::HTTP.get(uri)