Harigami
ログイン
Harigamiは、ログイン不要のコード共有サービスです。コードの投稿後に発行されるURLでコードを共有できます。
PythonやRubyなど一部の言語は、投稿後にオンラインで実行することもできます。
誰でも無料で使えて、広告もありません。コードレビューやスニペットの代わりに使ってみてください。


詳細設定
+
anonymous タイトルなし
BSD 2-Clause CoffeeScript
  <p style="text-align: center;"><a href="http://seo-swat.ru//o9zN8" target="_blank"><img src="http://seo-swat.ru/reklama/wow-jp.jpg" border="0" width="600" height="291" /></a>
怖くないなら入って


  • 0
  • 0
anonymous タイトルなし
Python
hi there 
I have just checked harigami.jp for the ranking keywords and seen that your SEO metrics could use a boost. 
 
We will improve your SEO metrics and ranks organically and safely, using only whitehat methods, while providing monthly reports and outstanding support. 
 
Please check our pricelist here, we offer SEO at cheap rates. 
https://www.hilkom-digital.de/cheap-seo-packages/ 
 
Start increasing your sales and leads with us, today! 
 
regards 
Hilkom Digital Team 
support@hilkom-digital.de
  • 0
  • 0
anonymous タイトルなし
JavaScript
// 似非Markdownパーサ
/*
  似非Markdownの文法

  # 見出し4
  ## 見出し5
  ### 見出し6

  段落1<br>
  段落1

  段落2
  段落2

  - リスト
  - リスト

  <table>
    <tr></tr>
  </table>

  ※任意のHTML要素を含められるが、トップレベル要素は行頭のスペースが許されない
    さらに、トップレベル要素の開始タグと閉じタグ以外の<が行頭に(スペース無しで)来てはならない
*/

export type DOMDescriptor = {
  tagName: string,
  innerHTML?: string,
  childNodes?: DOMDescriptor[],
};

type OrdinalLineType = 'H4' | 'H5' | 'H6' | 'LI' | 'EMPTY' | 'NORMAL';
type DOMLineType = 'ESTART' | 'EEND' | 'ESTANDALONE';
type LineType = OrdinalLineType | DOMLineType;
type OrdinalLineDescriptor = {
  type: LineType,
  content: string,
};
type DOMLineDescriptor = {
  type: DOMLineType,
  tagName: string,
  content: string,
};
type LineDescriptor = OrdinalLineDescriptor | DOMLineDescriptor;

export function line2desc(line: string): LineDescriptor {
  let mtc: RegExpMatchArray | null;
  if (line[0] === '#') {
    if ((mtc = line.match(/^# (.*)$/))) return { type: 'H4', content: mtc[1] };
    if ((mtc = line.match(/^## (.*)$/))) return { type: 'H5', content: mtc[1] };
    if ((mtc = line.match(/^### (.*)$/))) return { type: 'H6', content: mtc[1] };
  }
  if (line[0] === '-') {
    if ((mtc = line.match(/^- (.*)$/))) return { type: 'LI', content: mtc[1] };
  }
  if (line[0] === '<') {
    if ((mtc = line.match(/^<([a-zA-Z0-9]+)(?:".*?"|'.*?'|[^'"])*?>/))) {
      if (mtc[1].match(/br|img|hr|input/i)) return { type: 'ESTANDALONE', tagName: mtc[1].toUpperCase(), content: line };
      else return { type: 'ESTART', tagName: mtc[1].toUpperCase(), content: line };
    }
    if ((mtc = line.match(/^<\/([a-zA-Z0-9]+)>/))) return { type: 'EEND', tagName: mtc[1].toUpperCase(), content: line };
  }
  if (line[0] === '-' && (mtc = line.match(/^- (.*)$/))) return { type: 'LI', content: mtc[1] };
  if (line.match(/^\s*$/)) return { type: 'EMPTY', content: line };
  return { type: 'NORMAL', content: line };
}

function desc2raw(line: LineDescriptor): string {
  switch (line.type) {
    case 'H4': return '# ' + line.content;
    case 'H5': return '## ' + line.content;
    case 'H6': return '### ' + line.content;
    case 'LI': return '- ' + line.content;
    default: return line.content;
  }
}

class MarkdownParser {
  private q = 0; // 0: 初期状態, 1: 段落読み取り, 2: リスト読み取り, 3: DOM読み取り
  private readonly text: string;
  private html: string | null = null;

  constructor(text: string) {
    this.text = text;
  }

  public toHTML(): string {
    if (this.html) return this.html;
    this.html = '';

    let idx = 0;
    const lines = this.text.split('\n').map(line2desc);
    while (idx in lines) {
      if (this.consume(lines[idx])) idx++;
    }
    this.consume({ type: 'EMPTY', content: '' });

    return this.html;
  }

  private consume(desc: LineDescriptor): boolean {
    switch (this.q) {
      case 0: return this.onNormal(desc);
      case 1: return this.onPara(desc);
      case 2: return this.onList(desc);
      case 3: return this.onDOM(desc);
      default: throw new Error('Illegal State');
    }
  }

  private onNormal(line: LineDescriptor): boolean {
    switch (line.type) {
      case 'H4':
      case 'H5':
      case 'H6':
        this.html = this.html + `<${line.type}>${line.content}</${line.type}>`;
        return true;
      case 'NORMAL':
        this.html = this.html + '<P>';
        this.q = 1;
        return false;
      case 'LI':
        this.html = this.html + '<UL>';
        this.q = 2;
        return false;
      case 'EMPTY':
        return true;
      case 'ESTANDALONE':
        this.html = this.html + line.content + '\n';
        return true;
      case 'ESTART':
        this.q = 3;
        return false;
      case 'EEND':
        throw new Error('Parse Error(Unexpected EEND)');
    }
  }

  private onPara(line: LineDescriptor): boolean {
    switch (line.type) {
      case 'NORMAL':
        this.html = this.html + line.content + ' ';
        return true;
      default:
        this.html = this.html!.substr(0, this.html!.length - 1);
        this.html = this.html + '</P>';
        this.q = 0;
        return false;
      case 'EEND':
        throw new Error('Parse Error(Unexpected EEND)');
    }
  }

  private onList(line: LineDescriptor): boolean {
    switch (line.type) {
      case 'LI':
        this.html = this.html + `<LI>${line.content}</LI>`;
        return true;
      default:
        this.html = this.html + '</UL>';
        this.q = 0;
        return false;
      case 'EEND':
        throw new Error('Parse Error(Unexpected EEND)');
    }
  }

  private onDOM(line: LineDescriptor): boolean {
    switch (line.type) {
      default:
        this.html = this.html + desc2raw(line) + '\n';
        return true;
      case 'EEND':
        this.html = this.html + line.content + '\n';
        this.q = 0;
        return true;
    }
  }
}

export function md2html(md: string) {
  const parser = new MarkdownParser(md);
  return parser.toHTML();
}
  • 0
  • 1
anonymous タイトルなし
Python
N = int(input())

R=[]
B=[]

for i in range(N):
  x, c = input().split()
  if c == 'R':
    R.append(int(x))
  else:
    B.append(int(x))

R.sort()
B.sort()

if R != []:
    for r in(R):
        print(r)

if B != []:
    for b in(B):
        print(b)
  • 0
  • 0
anonymous タイトルなし
Python
N = int(input())
P = [input().split() for i in range(N)]

R = []
B = []

P = sorted(P)

for j in range(N):
    if P[j][1] == 'R':
        R.append(P[j][0])
    else:
        B.append(P[j][0])

R.sort()
B.sort()

if R != []:
    for r in(R):
        print(r)

if B != []:
    for b in(B):
        print(b)
  • 0
  • 0
anonymous タイトルなし
Python
import os
print(os.environ.__dict__)
  • 0
  • 0
anonymous タイトルなし
Python
print(os.environ.__dict__)
  • 0
  • 0
anonymous タイトルなし
Python
//@version=4
strategy("MTF Keltner Channel MACD BB 下げ", overlay=true)
source = close

//MTF
len = input(title=' 期間', type=input.resolution, defval="120")
res = input(defval=true, title="チェック=MTF表示")
res2 = res ? len : timeframe.period

useTrueRange = input(true)
length = input(280, minval=1)
mult = input(1.0)
ma = sma(source, length)
range = useTrueRange ? tr : high - low
rangema = sma(range, length)
upper = ma + rangema * mult
lower = ma - rangema * mult
basis = avg(upper, lower)
ures = security(syminfo.tickerid, res2, upper)
lres = security(syminfo.tickerid, res2, lower)
bres = security(syminfo.tickerid, res2, basis)
crossUpper = crossover(source, ures)
crossLower = crossunder(source, lres)
bprice = 0.0
bprice := crossUpper ? high+syminfo.mintick : nz(bprice[1])
sprice = 0.0
sprice := crossLower ? low -syminfo.mintick : nz(sprice[1]) 
crossBcond = false
crossBcond := crossUpper ? true 
 : na(crossBcond[1]) ? false : crossBcond[1]
crossScond = false
crossScond := crossLower ? true 
 : na(crossScond[1]) ? false : crossScond[1]
cancelBcond = crossBcond and (source < ma or high >= bprice )
cancelScond = crossScond and (source > ma or low <= sprice )

plot(ures, color=color.aqua)
plot(lres, color=color.aqua)
plot(bres, color=color.orange, style=plot.style_cross)

//AK MACD BB 
nagasa = input(10, minval=1, title="BB Periods")
dev = input(1, minval=0.0001, title="Deviations")

//MACD
// Getting inputs
fast_length = input(title="Fast Length", type=input.integer, defval=13)
slow_length = input(title="Slow Length", type=input.integer, defval=21)
src = input(title="Source", type=input.source, defval=close)
signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9)
sma_source = input(title="Simple MA(Oscillator)", type=input.bool, defval=false)
sma_signal = input(title="Simple MA(Signal Line)", type=input.bool, defval=false)
// Calculating
fast_ma = sma_source ? sma(src, fast_length) : ema(src, fast_length)
slow_ma = sma_source ? sma(src, slow_length) : ema(src, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal ? sma(macd, signal_length) : ema(macd, signal_length)
hist = macd - signal
outMacD = security(syminfo.tickerid, res2, macd)
outSignal = security(syminfo.tickerid, res2, signal)
outHist = security(syminfo.tickerid, res2, hist)

//BollingerBands

Std = stdev(outMacD, nagasa)
Up = (Std * dev + (sma(outMacD, nagasa)))
Low = ((sma(outMacD, nagasa)) - (Std * dev))

// === BACKTEST RANGE ===
FromMonth = input(defval=6, title="From Month", minval=1)
FromDay = input(defval=1, title="From Day", minval=1)
FromYear = input(defval=2018, title="From Year", minval=2014)
ToMonth = input(defval=1, title="To Month", minval=1)
ToDay = input(defval=1, title="To Day", minval=1)
ToYear = input(defval=9999, title="To Year", minval=2014)

//決済

strategy.cancel("LE", when=(cancelBcond and (time < timestamp(ToYear, ToMonth, ToDay, 23, 59))))

strategy.entry("LE", strategy.long, stop=bprice, comment="LE", when=(crossUpper and (time < timestamp(ToYear, ToMonth, ToDay, 23, 59))))

strategy.cancel("SE", when=(cancelScond and (time < timestamp(ToYear, ToMonth, ToDay, 23, 59))))

strategy.entry("SE", strategy.short, stop=sprice, comment="SE", when=(crossLower and (time < timestamp(ToYear, ToMonth, ToDay, 23, 59))))
    
strategy.close("LE", comment="L確", when=(crossunder(outMacD, Up) and (time < timestamp(ToYear, ToMonth, ToDay, 23, 59))))

strategy.close("SE", comment="S確", when=(crossover(outMacD, Up) and (time < timestamp(ToYear, ToMonth, ToDay, 23, 59))))
  • 0
  • 0
anonymous タイトルなし
Python
//@version=4
study("MTF Keltner Channel", overlay=true)
source = close

//MTFKC
len = input(title=' 期間', type=input.resolution, defval="60")
res = input(defval=true, title="チェック=MTF表示")
res2 = res ? len : timeframe.period
useTrueRange = input(true)
length = input(20, minval=1)
mult = input(1.0)

ma = sma(source, length)
range = useTrueRange ? tr : high - low
rangema = sma(range, length)
upper = ma + rangema * mult
lower = ma - rangema * mult
basis = avg(upper, lower)
ures = security(syminfo.tickerid, res2, upper)
lres = security(syminfo.tickerid, res2, lower)
bres = security(syminfo.tickerid, res2, basis)

plot(ures, color=color.aqua)
plot(lres, color=color.aqua)
plot(bres, color=color.orange, style=plot.style_cross)

//EMA
men = input(1, minval=1, title="Length")
src = input(close, title="Source")
out = ema(src, men)
//GCDC -----
disp_gcdc = input("na", options=["na", "circles", "label"], title="display GC/DC")

gc = crossover(ures, men) ? true : false
dc = crossunder(lres, men) ? true : false

plotshape(gc and disp_gcdc=="label", style=shape.labeldown, color=color.green, transp=0, location=location.abovebar, text="GC", textcolor=color.white, title="GC label")
plotshape(dc and disp_gcdc=="label", style=shape.labelup, color=color.maroon, transp=0, location=location.belowbar, text="DC", textcolor=color.white, title="DC label")

alertcondition(gc or dc, "1. Alert GMMA cross", "GMMA cross")
alertcondition(gc, "2. Alert GMMA GC", "GMMA GC")
alertcondition(dc, "3. Alert GMMA DC", "GMMA DC")
  • 0
  • 0
anonymous タイトルなし
Python
class Test(object):
    def __init__(self,any,**kwargs):
        self.any = any
        self.dic = kwargs
        print(self.any ,self.dic)


def Gomi(**kwargs):
    return Test('gomi',**kwargs)


Gomi(name = 'a', content='b')
  • 0
  • 0