Skip to content

Instantly share code, notes, and snippets.

def pi(num)
sum = 3
(1..num).each do |n|
dn = n*2
puts "(4.0/(#{dn} * #{(dn+1)} * #{(dn+2)}) * (#{(-1)**(n+1)}))"
sum += (4.0/(dn * (dn+1) * (dn+2)) * ((-1)**(n+1)))
end
return sum
end
@tangmae
tangmae / bootstrap.min.css
Last active January 31, 2017 01:32
This is gist including the coverter (converter.rb) which generate the html page (portfolio.html) from the structure file (structure.yml) and portfolio file (portfolio.yml).
/*!
* Bootstrap v4.0.0-alpha.6 (https://getbootstrap.com)
* Copyright 2011-2017 The Bootstrap Authors
* Copyright 2011-2017 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*//*! normalize.css v5.0.0 | MIT License | github.com/necolas/normalize.css */html{font-family:sans-serif;line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,footer,header,nav,section{display:block}h1{font-size:2em;margin:.67em 0}figcaption,figure,main{display:block}figure{margin:1em 40px}hr{-webkit-box-sizing:content-box;box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent;-webkit-text-decoration-skip:objects}a:active,a:hover{outline-width:0}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:inherit}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}dfn{font-style:italic}ma
@tangmae
tangmae / twitterfeature_remover.rb
Last active January 27, 2017 04:29
The extension method from String class for ruby. The objective of the method is for the text analysis preprocessing removing the irrevelevant words (especially Twitter feature).
class String
def remove_reply(remain_username = false)
if remain_username
self.gsub(/[@]{1}/,"")
else
self.gsub(/[@]{1}[\w]{1,}/,"")
end
end
@tangmae
tangmae / twitterfeature_remover.rb
Created January 27, 2017 04:21
The extension method for String class for removing the irrevelevant words from the tweet.
class String
def remove_reply(remain_username = false)
if remain_username
self.gsub(/[@]{1}/,"")
else
self.gsub(/[@]{1}[\w]{1,}/,"")
end
end
class RomanNumerals
@roman = "IVXLCDM"
@numeric = [1,5,10,50,100,500,1000]
def self.to_roman(int)
index = int.to_s.size()
ans = ""
for i in 0..index-1
c = int.to_s[i].to_i
value = 10**(index-1)
if (c == 9 || c == 4) && !(c*value > 1000)
@tangmae
tangmae / gist:3874207
Created October 11, 2012 17:42
Homework#2 Calculator
public class calculator(){
private Keyboard keyboard;
private Screen screen;
private Stack operant;
private Stack operator;
private String showValue;
private State calState;
enum State{
on,
@tangmae
tangmae / moblie1
Created October 9, 2012 07:26
Homework#1
class Moblie{
}
//Global
static void int mode = 1;
static void int timecalling = 0;
public static class Monitor{
String output;
@tangmae
tangmae / mobile.java
Created October 9, 2012 05:44
[Homework#1]Mobile
class Mobile()
{
}
class monitor{
String output;
int mode;
//mode 1 => home || mode 2 => keynum || mode 3 => call