This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE DATABASE IF NOT EXISTS test_db; | |
USE test_db; | |
CREATE TABLE IF NOT EXISTS unya | |
( | |
id INT(11), | |
message TEXT | |
); | |
DROP PROCEDURE IF EXISTS find_treasure; | |
DELIMITER // | |
CREATE PROCEDURE find_treasure() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.main | |
object Fizzbuzz { | |
def main(args:Array[String]){ | |
this.run(15).zipWithIndex foreach { | |
case(x,i) => println( (i+1) + " : " + x) | |
} | |
} | |
def run(max:Int):Seq[String] = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (fib n) | |
(if (> n 0) | |
(+ (fib (- n 1)) (fib (- n 2))) | |
1 | |
)) | |
(print (fib 5) ) | |
(print (fib 1) ) | |
(print (fib 2) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var count = 0; | |
http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('Hello World\n' + count++); | |
}).listen(8080, '127.0.0.1'); | |
console.log('Server running at http://127.0.0.1:8080/'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CouponMaster | |
{ | |
const COUPON_TYPE_RATE = 'rate'; | |
const COUPON_TYPE_FIXED = 'fixed'; | |
private $coupons = [ | |
'10%' => [ | |
'type' => self::COUPON_TYPE_RATE, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (selectOptimalCoupons amount myCouponList) | |
(consume amount (sort myCouponList >) (list)) | |
) | |
(define (consume amount coupons usedCoupons) | |
(if (null? coupons) | |
usedCoupons | |
(if (>= amount (car coupons)) | |
(consume (- amount (car coupons)) (cdr coupons) (append usedCoupons (list (car coupons)))) | |
(consume amount (cdr coupons) usedCoupons)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"io/ioutil" | |
"net/http" | |
) | |
func main() { | |
response, _ := http.Get("http://google.com") | |
body, _ := ioutil.ReadAll(response.Body) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
yum install -y gcc git mercurial ncurses-devel lua lua-devel | |
cd /usr/local/src | |
hg clone https://vim.googlecode.com/hg/ vim | |
cd /usr/local/src/vim | |
./configure --enable-multibyte \ | |
--with-features=huge \ | |
--disable-selinux \ | |
--prefix=/usr/local \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* クーポン自体が独立しているから順次処理していく感じにした | |
* @param array $amount | |
* @param array $myCouponList | |
* @return array | |
*/ | |
function selectOptimalCoupons($amount, $myCouponList){ | |
$hydrate = function($coupons){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 入力を{ 割引額 => 枚数 }の形に変える | |
* 枚数制限に引っかかる分を取り除く | |
* 同時利用可能でないクーポンリストを分ける(複数のクーポンリストにする) | |
* 複数のクーポンリストから割引額が多いものを返す。 | |
* @param $amount | |
* @param $myCouponList | |
* @return array |
OlderNewer