Skip to content

Instantly share code, notes, and snippets.

tomoya ishida tompng

Block or report user

Report or block tompng

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
View codegolf_checker.rb
require 'tempfile'
def codegolf_check file, samples: nil
unless samples
samples = DATA.read.split(/^# ?input\n/).drop(1).map { |s| s.split(/# ?output\n/) }
end
lines = File.read(file).lines
codes = []
lines.each.with_index(1).each do |line, num|
next unless /^# ?code ?(?<name>.*)$/ =~ line
code = ''
View read_line_number.rb
def readA io, line_num
line_num.times{io.gets}
io.gets
end
def readB io, line_num
size=65536
buf=??*size
while true
io.read size, buf
View a.rb
p *$<.map{|l,n=1|l[l.to_i.to_s n+=1]?n:redo}
$<.map{|l,n=1|l[l.to_i.to_s n+=1]||redo;p n}
$<.map{|l,n=1|l[l.to_i.to_s n+=1]?p(n):redo}
p *$<.map{|l|l[l.to_i.to_s n=1+n||=1]?n:redo}
exit
# ruby1.8.7
n=1;$<.map{|l|l[l.to_i.to_s n+=1]?p(n):redo;n=1}
n=1;$<.map{|l|l[l.to_i.to_s n+=1]||redo;p n;n=1}
$<.map{|l|n||=1;!l[l.to_i.to_s n+=1]?redo:p(n)}
View dl.rb
require 'io/console'
require 'net/http'
require 'digest'
class Loader
def initialize(url, download_dir)
@url = url
uri = URI.parse url
@file_name = File.basename(url).gsub(/[^a-zA-Z0-9_.]/, '').gsub(/^\./, 'file.')
@file_path = "#{download_dir}/#{@file_name}"
View haisai.rb
def haisai(x,y)
y2=(y<0?y+2.75:y)
ha=((x+y-0.5)**2+4**(8*x+8*y-4)+(y-14*x-25-2*(x+y-0.5)**2)**2-6)*((6*x+4*y-x*x-1)**4+4*(y-x-2)**2-3)
ii=(16*(x-y2+7/8.0+x*x/8)**2+8*(y2-15/8.0)**4-1)*(49*(x-1)**2+32*(y2-1)**8-1)-1
sa=4/((x+1.25)**8+(16*y+16+(x+1.25)**2/4)**2/(1+(x+1.25)**2))+1/(4*(y+1)**8+(8*x+14)**2)+4/((y+4/3.0)**8+(16*x+12+(y+0.5)**4/2)**2)-1
ha*ii*sa
end
n=48
n.times{|y|
puts (2*n).times.map{|x|
View out.rb
eval(s="tobf=->s{s.chars.map{|c|%([-])+?+*c.ord+?.}.join};a,b=[\"package main;import \\\"fmt\\\";func main(){fmt.Println(\\\"<?php echo(\\\\\\\"print(\\\\\\\\\\\\\\\"console.log(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"#include<stdio.h>\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\nint main(){puts(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\", \"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");}\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\")\\\\\\\\\\\\\\\")\\\\\\\");\\\")}\"];c=%[eval(s=]+s.inspect+?);5.times{c=c.inspect[1...-1]};puts tobf[a+c+b]")
View function_benchmark.js
function gencode(code, n){
code.push(`const a${Math.random()*9999|0}=${Math.random()}`)
if(n==0) {
code.push('console.log(123)')
return
}
const rnd = Math.random()
if(rnd < 0.5){
code.push('for(let i=0;i<10;i++){')
View generator.rb
class Node
attr_reader :to_s
def initialize op, a=nil, b=nil
if a.nil?
@to_s = op
return
end
case op
when :-@
@tompng
tompng / mouse_shape.c
Last active Jul 17, 2019
雑マウス
View mouse_shape.c
#include <stdio.h>
int main(){
int size = 24;
for(int y=0;y<size;printf("\n"),y++){for(int x=0;x<size;x++){
int size = 24;
float a=0.1+(y-1.8*x)/size;
float b=1.2-(x+1.8*y)/size;
float c=b+(a<0?-a:a);
float d=(b+c-1.4);
d=d*d*d*d;d=d*d;
View domdiff.js
function serializeDOM(dom){
return {
tag: dom.tagName,
class: dom.className,
children: [...dom.childNodes].map(a=>serializeDOM(a))
}
}
diffs = []
function diff(oa, ob, path, ac) {
You can’t perform that action at this time.