Skip to content

Instantly share code, notes, and snippets.

@kazua
kazua / twitter00001a.php
Last active December 19, 2015 17:58
Twitter検索
<?php
//write kazua
header("Content-Type:text/html;charset=UTF-8");
require_once('../lib/twitteroauth.php');
$ck = '***********';//キーは自分で取得したものを設定
$cs = '***********';//キーは自分で取得したものを設定
$at = '***********';//キーは自分で取得したものを設定
$as = '***********';//キーは自分で取得したものを設定
$tw = new TwitterOAuth($ck,$cs,$at,$as);
@kazua
kazua / ArrayCustom.js
Last active December 19, 2015 16:39
Arrayのcontainsとdistinct
//write kazua
if (!Array.prototype.contains) {
Array.prototype.contains = function(value) {
for ( var i = 0; i < this.length; i++)
if (this[i] === value)
return true;
return false;
};
}
@kazua
kazua / twitter2.scala
Last active December 19, 2015 10:19
ScalaでTwitter検索
//write kazua
import twitter4j._
import twitter4j.conf._
import scala.collection.JavaConverters._
import java.awt.Desktop
import java.net._
import javax.swing.JOptionPane
import java.io._
@kazua
kazua / problem71.scala
Created July 2, 2013 10:56
Project Euler Problem 71
//http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2071
//write kazua
object problem71 {
def problem71(mn : Int) = {
problem71Proc(mn)._1
}
def problem71Proc(mn : Int, kn : (Int, Int) = (3, 7), cn : (Int, Int) = (2, 5)) : (Int, Int) = (cn._2 + kn._2) match {
case sn if sn > mn => cn
case sn => problem71Proc(mn, kn, (cn._1 + kn._1, sn))
@kazua
kazua / problem42.scala
Created June 28, 2013 14:08
Project Euler Problem 42
//http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2042
//write kazua
import scala.io.Source
import scala.math._
object problem42 {
def isTriNum(n : Double) = (sqrt(8 * n + 1.0) - 1.0) / 2.0 == ((sqrt(8 * n + 1.0) - 1.0) / 2.0).toInt
def alpindex(c : Char) = "abcdefghijklmnopqrstuvwxyz".indexOf(c.toLower) + 1
def problem42(fp : String) = {
@kazua
kazua / twitter.scala
Last active December 19, 2015 01:29
ScalaでTwitter
//write kazua
import twitter4j._
import twitter4j.conf._
import scala.collection.JavaConverters._
object twitter {
def twitterinfo(sw : String) = {
//認証
val cb = new ConfigurationBuilder
@kazua
kazua / problem44.scala
Last active December 19, 2015 00:09
Project Euler Problem 44
//http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2044
//write kazua
import scala.math._
object problem44 {
def isPenNum(d : Double) = (sqrt(1.0 + 24.0 * d) + 1.0) / 6.0 == ((sqrt(1.0 + 24.0 * d) + 1.0) / 6.0).toInt
def problem44(fn : Int, sn : Int, an : Int) : Int = an match {
case a if a > 0 => a
case _ => {
@kazua
kazua / problem31.scala
Created June 23, 2013 15:01
Project Euler Problem 31
//http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2031
//write kazua
object problem31 {
val coinlist = List(1, 2, 5, 10, 20, 50, 100, 200)
def getCoinComb(cl : List[Int], ta : Int, ac : Int) : Int = cl match {
case h :: t if h + ac > ta => 0
case h :: t if h + ac == ta => 1
case h :: t => getCoinComb(cl, ta, ac + h) + getCoinComb(t, ta, ac)
case nil => 0
@kazua
kazua / randompop.js
Created June 20, 2013 21:06
Arrayのpop()のランダム版
//write kazua
if (!Array.prototype.randompop) {
Array.prototype.randompop = function() {
"use strict";
if (this == null)
throw new TypeError();
var t = Object(this), len = t.length >>> 0;
if (len == 0)
return null;
@kazua
kazua / worldproblem9_1.scala
Created June 17, 2013 12:02
世界で闘うプログラマ本の9-1
//write Kazua
import scala.collection.mutable._
object worldproblem9_1 {
def CntUpStairs(sc : Int) = {
sc + "段の階段の上り方は" + CntUpStairsProc(sc) + "通りあります。"
}
def CntUpStairsProc(sc : Int, ss : Map[Int, Int] = Map.empty) : Int = sc match {
case c if c < 0 => 0