Skip to content

Instantly share code, notes, and snippets.

View ir77's full-sized avatar

ucchy 内村 ir77

  • Y
  • Tokyo(sometimes in Osaka)
  • X @uc18uc
View GitHub Profile
const user: {
firstName: string;
lastName: string;
age: number;
favoriteFoods: string[];
hasPE: boolean;
} = {
firstName: "太郎",
lastName: "佐藤",
age: 24,
// interface は拡張できる
// type は拡張できない
type MyType = {
readonly num?: number;
str: string;
nums: number[];
status: "許可" | "不許可";
tup: [string, number, string];
};
var f=(x,r=0.2,m=~~(x/r))=>r*m+r-Math.sqrt(r*r-(r*m-x)**2);export default f;
protocol Foo {
func bar(_ int: Int)
func bar(_ str: String)
}
struct Impl: Foo {
func bar<T>(_ value: T) {
print("hoge", value)
}
}
@ir77
ir77 / caesar.rs
Last active March 13, 2022 13:32
use proconio::input;
use proconio::marker::Chars;
fn main() {
input! {
str: Chars
}
for index in 1..26 {
println!(
@ir77
ir77 / play.sh
Created May 13, 2020 09:20
定期的にチャイム鳴らしたいけどZoom中は鳴らさないでスクリプト。
45 9 * * 1-5 ps ax -o command | sed -ne 's/.*\/Applications\/\([^/]*\)\.app\/.*/\1/p' | sort -u | grep zoom | wc -l | xargs -I{} sh -c 'if [ "{}" == "0" ]; then afplay /Users/workspace/resources/Japanese_School_Bell02-02.mp3; fi'
0 17 * * 1-5 ps ax -o command | sed -ne 's/.*\/Applications\/\([^/]*\)\.app\/.*/\1/p' | sort -u | grep zoom | wc -l | xargs -I{} sh -c 'if [ "{}" == "0" ]; then afplay /Users/workspace/resources/VSQPD_018_yuyakekoyake_piano.mp3; fi'
19 18 * * 1-5 ps ax -o command | sed -ne 's/.*\/Applications\/\([^/]*\)\.app\/.*/\1/p' | sort -u | grep zoom | wc -l | xargs -I{} sh -c 'if [ "{}" == "0" ]; then afplay /Users/workspace/resources/Japanese_School_Bell02-02.mp3; fi'
function toDate(str) {
const arr = (str.substr(0, 4) + '/' + str.substr(4, 2) + '/' + str.substr(6, 2)).split('/');
return new Date(arr[0], arr[1] - 1, arr[2], 0, 0, 0, 0);
}
function toString(date) {
const year = date.getFullYear();
const month = ('0' + (date.getMonth() + 1)).slice(-2);
const day = ('0' + date.getDate()).slice(-2);
return `${year}` + month + day;
@ir77
ir77 / OctokitSample.js
Created April 28, 2019 15:38
Octokitを使ったSample
const Octokit = require('@octokit/rest')
const octokit = new Octokit()
// Compare: https://developer.github.com/v3/repos/#list-organization-repositories
// octokit.repos.listForOrg({
// org: 'octokit',
// type: 'public'
// }).then(({ data, status, headers }) => {
// // handle data
// console.log(data);
@ir77
ir77 / challenge13.js
Created October 3, 2017 16:05
Elevator Saga - the elevator programming game http://play.elevatorsaga.com/#challenge=13
{
init: function(elevators, floors) {
var defaultPosition = [0, 0, 0, 0, 0]
// idle時に待ちが無ければ所定の位置へ、待ちがあればその階へ移動する
elevators.forEach(function(elevator, index, array) {
elevator.on("idle", function() {
elevator.goingUpIndicator(true);
elevator.goingDownIndicator(true);
elevator.goToFloor(defaultPosition[index]);
@ir77
ir77 / challenge11.js
Created October 3, 2017 12:25
Elevator Saga - the elevator programming game http://play.elevatorsaga.com/#challenge=11
{
init: function(elevators, floors) {
var defaultPosition = [0, 2, 4, 6, 8]
var waitingList = []
console.log("start!")
// idle時に待ちが無ければ所定の位置へ、待ちがあればその階へ移動する
elevators.forEach(function(elevator, index, array) {
elevator.on("idle", function() {