This file contains 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
;; 1 | |
(defn factorial [n] | |
(loop [ret 1 x n] | |
(if (zero? x) | |
ret | |
(recur (* ret x) (dec x))))) | |
;; 2 | |
(defn factorial2 [n] | |
(reduce * (range 1 (+ n 1)))) |
This file contains 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 yaml,re | |
import logging | |
import logging.handlers | |
import traceback | |
import random | |
import datetime | |
import time | |
try: |
This file contains 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
import sys | |
import mysql.connector | |
def exec_sql(fn): | |
def wrapper(*args, **kw): | |
_self = args[0] | |
_self.con = mysql.connector.connect(**_self.rds_config) | |
ret = None | |
try: | |
ret = fn(*args, **kw) |
This file contains 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
//条件分岐 | |
var direction = "right"; | |
// 初期化してはじめて、型をnumberとして認識する | |
var x = 0, y = 0; | |
switch (direction) { | |
case "right": | |
x = x + 10; | |
break; | |
case "left": |
This file contains 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
(function(){ | |
console.log("start!!"); | |
// この時点ではまだ未定義(undefined) | |
// typeof() で変数の型を確認することができます | |
var x; | |
console.log("variable x is " + typeof(x)); | |
console.log("x = " + x); | |
This file contains 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
// アロー構文 | |
var add = (a, b) => { | |
return a + b | |
} | |
add(1 ,9); |
This file contains 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
(function(){ | |
function calc() { | |
var num = 0; | |
for (var i=1; i<=10; i++) { | |
// 動きを追うにはconsole.logを色々な所で打ち込んでみよう! | |
console.log(num); | |
num += i; | |
} | |
return num; | |
} |
This file contains 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
$givenValue = 10 | |
function testIfSupportingClosure(){ | |
$givenValue = 4 | |
{ | |
$script:givenValue = $givenValue + 1 | |
echo "The givenValue is ${givenValue}." | |
}.GetNewClosure() | |
} | |
This file contains 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
# depends on jquery | |
setDetailPageAction = -> | |
require modules, ($) -> | |
$elem = $('div#record-gaia').find('.target-element') | |
# Set default-focus | |
setTimeout () -> | |
$elem.focus(); | |
, 200 |
This file contains 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
require "rubygems" | |
require "test/unit" | |
require "mocha/test_unit" | |
require "pry" | |
class Person | |
attr_accessor :name | |
def initialize(name) | |
self.name = name | |
end |
OlderNewer