Skip to content

Instantly share code, notes, and snippets.

@cofearabi
cofearabi / getkabu.py
Created May 30, 2012 22:34
(python) get stock price data from stocks.finance.yahoo.co.jp
# -*- coding: utf-8 -*-
#!/usr/bin/env python
import urllib2
import re
def getkabuka(code):
url='http://stocks.finance.yahoo.co.jp/stocks/detail/?code='+str(code)+'.T&d=1y'
f=urllib2.urlopen(url)
txt=f.read()
@cofearabi
cofearabi / getYahoo.py
Created May 30, 2012 22:39
(python) get monthly stock data from yahoo and make csv file.
import jsm
c = jsm.QuotesCsv()
c.save_historical_prices('4689.csv',4689)
@cofearabi
cofearabi / worksheet.py
Created May 30, 2012 22:47
(python) make excel worksheet
from pyExcelerator import *
wb = Workbook()
ws = wb.add_sheet('0')
for row in xrange(100):
for col in xrange(10):
ws.write(row, col, '%d, %d' % (row, col))
wb.save(r'test01.xls')
@cofearabi
cofearabi / sample.py
Created May 30, 2012 23:00
(python)get stock price data ( daily weekly monthly ) and write temp file.
# coding=utf-8
import jsm
if __name__ == "__main__":
import tempfile
q = jsm.Quotes()
c = jsm.QuotesCsv()
for range in (jsm.DAILY, jsm.WEEKLY, jsm.MONTHLY):
print(q.get_historical_prices(4689, range))
c.save_historical_prices(tempfile.mktemp(dir='/tmp/'), 4689, range)
@cofearabi
cofearabi / mysql.php
Created October 3, 2012 05:47
(php) connect mysql database and display all fields and records of table.cgi-program
<html>
<head>
<META HTTP-EQUIV="content-type" CONTENT="text/html;
charset=utf-8">
</head>
<?php
$server = '127.0.0.1';
$username = 'root';
$password = 'root';
@cofearabi
cofearabi / Acce.pl
Created October 4, 2012 10:13
(perl script)connect Access mdb database through ODBC
#!/usr/local/bin/perl
use Win32::ODBC;
print "Content-type: text/html\n\n";
print "<html>";
print "<body>";
$db= new Win32::ODBC("DSN=passwd");
@cofearabi
cofearabi / scra.pl
Created December 11, 2012 06:34
(perl script) get a stock price data from stocks.finance.yahoo.co.jp
#!/usr/bin/perl
use strict;
use warnings;
use Web::Scraper;
use URI;
use Encode;
my $scraper = scraper {
process '//dl[@class="stocksInfo"]/dt[1]','numb' => 'TEXT';
@cofearabi
cofearabi / jikan.c
Created December 13, 2012 14:48
(c language) display the time. if between 11:32~12:28 return 1 else return 0
#include <stdio.h>
#include <time.h>
int main(void)
{
time_t timer;
struct tm *t_st;
/* 現在時刻の取得 */
time(&timer);
@cofearabi
cofearabi / cs_excel
Created December 14, 2012 16:43
(c#) access to the excel sheet and display the value of A1 cell.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;
@cofearabi
cofearabi / cs_excel_write
Created December 15, 2012 00:03
(C#) write excel file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;