Skip to content

Instantly share code, notes, and snippets.

View Code-Hex's full-sized avatar

Kei Kamikawa Code-Hex

View GitHub Profile
@Code-Hex
Code-Hex / hash.pl
Last active August 29, 2015 14:05
ハッシュと向き合った
#! /usr/bin/perl
use strict;
use warnings;
use 5.010;
my $n = "\n";
my %hash = ("foo", 35, "bar", 12.4, 2.5, "hello");
say $_ foreach (%hash);
print $n;
@Code-Hex
Code-Hex / YAML.pl
Created August 22, 2014 02:18
YAML 上書き保存方法
use strict;
use YAML::XS;
my %h = ("12" => 4);
$h{foo} = "bar";
my @array = qw/apple banana orange/;
## YAMLドキュメントの読み込み
my $filename = YAML::XS::Load("example.yaml");
open F, '>>', $filename or die("cannot open file.");
@Code-Hex
Code-Hex / cabocha.pl
Last active May 12, 2016 06:56
cabocha で書いた perl用の様々なメソッド
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
use utf8;
use Encode qw/encode_utf8 decode_utf8/;
use CaboCha;
use Data::Dumper;
@Code-Hex
Code-Hex / doublemap.pl
Created November 11, 2014 14:05
二重mapの動きを知るためのコード
#!/usr/bin/perl
use strict;
use warnings;
my $num = 0;
map{$num += $_} map{$num += $_} 1..2;
print $num;
@Code-Hex
Code-Hex / sort.py
Last active August 29, 2015 14:09
pythonでソート
#!/usr/bin/python
# coding: UTF-8
import random
a = range(10)
for i in range(10):
a[i] = random.randint(0,10)
print "a"
@Code-Hex
Code-Hex / oninto.pm
Created November 14, 2014 03:58
perl でライブラリを作ってみた。(多分随時更新)
use strict;
use warnings;
sub into(\@$$);
sub onto(\@$$);
sub into(\@$$){
my $i = 0;
my @new_array; # 新しい配列
my @before_array = @{$_[0]}; # 参照渡しされた配列を代入
@Code-Hex
Code-Hex / test.pl
Last active August 29, 2015 14:10
Mojolicious::Lite の勉強(基礎から)
#!/usr/bin/env perl
use Mojolicious::Lite;
# Documentation browser under "/perldoc"
plugin 'PODRenderer';
get '/' => sub {
my $c = shift;
$c->stash->{message} = "Hello Mojo!";
$c->stash->{test} = "Test Mojo...";
@Code-Hex
Code-Hex / HelloWorld.c
Last active August 29, 2015 14:11
mac上のgccで動きます
#define _____________ main
#define ____________ int
#define ___________ char
#define __________ while
#define _________ printf
#define ________ "%s\n"
#define _______ 115
#define ______ _==108?__[4]=___:_==111?__[5]=___:_==114?__[6]=___
_____________(){ ____________ _;___________ __[7];___________ *___;
@Code-Hex
Code-Hex / 4-2.c
Created December 17, 2014 03:04
4-2(4-1はやらない)
#include <stdio.h>
int main(){
for (int i = 1; i <= 7; ++i)
{
printf("*");
if (i % 3 == 1)
for (int i = 0; i < 4; ++i) printf("*");
printf("\n");
}
@Code-Hex
Code-Hex / 4-3.c
Last active August 29, 2015 14:11
4-3
#include <stdio.h>
int main(){
float vertically, horizontally;
float inch = 2.54;
float ans;
printf("まずは横の入力\n");
scanf("%f",&vertically);