Skip to content

Instantly share code, notes, and snippets.

Avatar
😀

Shozo Hatta hachi8833

😀
View GitHub Profile
@hachi8833
hachi8833 / docker-compose.yml
Last active Jun 30, 2021
RailsGoatのdocker-compose.ymlを変更
View docker-compose.yml
version: '2'
services:
web:
build: .
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
volumes:
- .:/myapp
ports:
- "3000:3000"
depends_on:
@hachi8833
hachi8833 / dip.yml
Last active Jun 30, 2021
RailsGoat向けのdip.yml
View dip.yml
version: '7.0'
environment:
RAILS_ENV: development
compose:
files:
- docker-compose.yml
interaction:
@hachi8833
hachi8833 / sample.rb
Created Apr 28, 2021
Conversion sample
View sample.rb
> emoji_flag("eu")
#=> "🇪🇺"
View invalid.rb
emoji_flag("AA")
#=> "🇦🇦"
@hachi8833
hachi8833 / conversion.rb
Created Apr 28, 2021
Sequence of converting country code to flag
View conversion.rb
"FR".codepoints
#=> [70, 82]
70 + 127397
#=> 127467
127467.chr(Encoding::UTF_8)
#=> "🇫"
82 + 127397
@hachi8833
hachi8833 / intl_flag.rb
Last active Apr 28, 2021
A country flag consists of two RIS
View intl_flag.rb
"🇪🇺".chars
#=> ["🇪", "🇺"]
@hachi8833
hachi8833 / sample3.js
Created Mar 12, 2021
Promise sample code 3
View sample3.js
new Promise(function(resolve, reject) {
setTimeout(() => resolve(1), 2000);
}).then((result) => {
alert(result);
return result + 2;
}).then((result) => {
throw new Error('FAILED HERE');
alert(result);
return result + 2;
@hachi8833
hachi8833 / sample2.js
Created Mar 12, 2021
Promise sample code 2
View sample2.js
new Promise(function(resolve, reject) {
setTimeout(() => resolve(1), 2000);
}).then((result) => {
alert(result);
return result + 2;
}).then((result) => {
alert(result);
return result + 2;
}).then((result) => {
@hachi8833
hachi8833 / sample.js
Created Mar 12, 2021
Promise sample code 1
View sample.js
function delay(t){
return new Promise(function(resolve){
return setTimeout(resolve, t)
});
}
function logHi(){
console.log('hi');
}
delay(2000).then(logHi);
View sample.ts
type Digits = /* 上記参照 */;
type DigitsStr = `${Digits}`;
type Tile<T extends unknown[], N extends Digits | DigitsStr | 10 | '10'> = [
[],
[...T],
[...T, ...T],
[...T, ...T, ...T],
[...T, ...T, ...T, ...T],
[...T, ...T, ...T, ...T, ...T],
[...T, ...T, ...T, ...T, ...T, ...T],