Skip to content

Instantly share code, notes, and snippets.

View ktnyt's full-sized avatar
🐱

ktnyt ktnyt

🐱
View GitHub Profile
@ktnyt
ktnyt / easy-prime.c
Created April 22, 2014 02:53
かんたんな素数列挙
#include <stdio.h>
int isPrime(int n) {
int i;
for(i = 2; i * i <= n; ++i) {
if(n % i == 0) {
return 0;
}
}
@ktnyt
ktnyt / nyancat.c
Last active August 29, 2015 14:01
Let's nyan
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXLINE 256
int main() {
char str1[MAXLINE];
char str2[MAXLINE];
char str3[MAXLINE];
@ktnyt
ktnyt / stapgolf.pl
Last active August 21, 2021 14:16
はやったやつ
while("STAP"ne$s){print$s=join("",map{qw(S T A P)[4*rand]}0..3),"\n"}print"陽性かくにん! よかった☆\n"
@ktnyt
ktnyt / srl.c
Last active August 29, 2015 14:02
Self referencing list
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// struct listじゃなくてlistで定義できるおまじない
typedef struct _list {
char* name;
struct _list* next;
} list;
@ktnyt
ktnyt / picture.pde
Created July 7, 2014 07:49
Press enter to take a picture
import processing.video.*;
Capture camera;
PImage picture = null;
void setup() {
size(640, 480);
camera = new Capture(this, 640, 480, 30);
camera.start();
@ktnyt
ktnyt / rgbcondition.pde
Created July 7, 2014 11:14
RGB condition
import processing.video.*;
Capture camera;
PImage picture = null;
void setup() {
size(640, 480);
camera = new Capture(this, 640, 480, 30);
camera.start();
@ktnyt
ktnyt / rgbcondition-global.pde
Last active August 29, 2015 14:03
Global RGB condition
import processing.video.*;
Capture camera;
PImage picture = null;
void setup() {
size(640, 480);
camera = new Capture(this, 640, 480, 30);
camera.start();
@ktnyt
ktnyt / kadai3.sh
Last active August 29, 2015 14:03
perl -lane '$.-1?$h{$_}=$F[7]:print"(answer1)\n$_"}{print join"\n",sort{$h{$b}<=>$h{$a}}keys%h' datas
perl -F'\t' -lane '$.-1?$F[4]?push@{$h{$F[0]}},[$F[4],$F[2],$F[5]]:"":print"(answer2)"}{map{print"[$_]"and map{print join":",@$_ if@$_}(sort{$b->[0]<=>$a->[0]}sort{$a->[1]<=>$b->[1]}@{$h{$_}})[0..4]}sort{$a cmp$b}keys%h' datas
perl -lane '$.-1?sub{$h{$1}++while/https?:\/\/(.+?)\//g}->():print"(answer3)"}{print join"\n",(map{join":",@$_}sort{$b->[0]<=>$a->[0]}map{[$h{$_},$_]}sort{$a cmp$b}keys%h)[0..4]' datas;
@ktnyt
ktnyt / gist:8a60c064519c04ba8e96
Created August 11, 2014 22:18
神クエリ for 7yan
SELECT DISTINCT *
WHERE {
?person rdf:type <http://dbpedia.org/ontology/Person> .
?person prop-ja:バスト ?b .
?person prop-ja:ウエスト ?w.
?person prop-ja:ヒップ ?h.
?person <http://ja.dbpedia.org/property/生年> ?birthYear .
?person rdfs:label ?label .
?person dbpedia-owl:wikiPageWikiLink dbpedia-ja:日本 .
?person dbpedia-owl:wikiPageWikiLink dbpedia-ja:ジュニアアイドル
@ktnyt
ktnyt / bcht.pl
Last active August 29, 2015 14:05
Best codon hashtable
use strict;
use warnings;
use G;
my $gb = load("ecoli", "no msg");
my $w_val = w_tai($gb, -output=>"f", -filename=>"/dev/null");
my $table;