This file contains hidden or 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
-- clean up. | |
drop table if exists persons; | |
drop function if exists entry_person(text, integer); | |
-- initialize. | |
create table persons ( | |
name text | |
,age integer | |
); |
This file contains hidden or 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 | |
function from_json($filename) { | |
if(!file_exists($filename)) { | |
throw new Exception($filename.' not found.'); | |
} | |
$json_text = file_get_contents($filename); | |
if(!$json_text) { | |
throw new Exception('Failed read '.$filename); | |
} | |
$json = mb_convert_encoding($json_text, 'UTF8', 'ASCII, JIS, UTF-8, EUC-JP,SJIS-WIN'); |
This file contains hidden or 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
#include <stdio.h> | |
int main(void) | |
{ | |
int i = 0; | |
const unsigned char text[] = "test\0"; | |
while(text[i] != '\0') { | |
printf("%02X\n", text[i]); | |
i++; |
This file contains hidden or 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
#include <algorithm> | |
#include <iostream> | |
#include <string> | |
int main() | |
{ | |
std::string text = "abcde"; | |
std::string copy_text = ""; | |
std::copy(text.begin(), text.begin()+3, std::inserter(copy_text, copy_text.begin())); |
This file contains hidden or 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
{ | |
"test_save_ok": { | |
"expected": true, | |
"data": [ | |
] | |
}, | |
"test_save_ng": { | |
"expected": true, | |
"data": [ |
This file contains hidden or 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
def to_2dimentional_list(arr, row_no, col_no): | |
res = [] | |
offset = 0 | |
for row in range(0, row_no): | |
res.append(arr[offset:col_no+offset]) | |
offset = offset + col_no | |
return res | |
a = [1,2,3,4,5,6] |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Practice AJAX</title> | |
<script type="text/javascript"> | |
function do_ajax() { | |
var req = new XMLHttpRequest(); | |
var result = document.getElementById('result'); | |
req.onreadystatechange = function() | |
{ |
This file contains hidden or 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
#include <iostream> | |
int main() | |
{ | |
char c = 0x05; //Binary: 00000101 | |
for(int i = 0; i <= 2; i++) { | |
std::cout << (unsigned int)((c >> i) & 0x01) << std::endl; | |
} | |
return 0; | |
} |
This file contains hidden or 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
#include <iostream> | |
#include <stdexcept> | |
#include <sstream> | |
#include <string> | |
#include <vector> | |
typedef struct { | |
std::string text; | |
char delimiter; | |
} data_t; |
This file contains hidden or 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
# -*-coding: utf-8 -*- | |
import os | |
import json | |
def read_json(filename): | |
if not os.path.isfile(filename): | |
raise FileExistsError("[error] {0} not found.".format(filename)) | |
with open(filename) as f: | |
return json.load(f) |