This file contains hidden or 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
| #!/bin/bash | |
| # bamboo-agent Init script for running bamboo agent | |
| # | |
| # chkconfig: 2345 98 02 | |
| # | |
| # description: Starts and stops bamboo agent | |
| # This is just a delegator to the Bamboo agent script. | |
| USER=apps | |
| AGENTS_HOME=/opt/local/bamboo-agents |
This file contains hidden or 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
| class Time( private val _hour: Int, private val _minute: Int ) { | |
| private val time = _hour * 60 + _minute; | |
| def hour = _hour | |
| def minute = _minute | |
| def before( other: Time ) = other.time > time | |
| override def toString(): String = hour + ":" + minute | |
| } |
This file contains hidden or 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
| class Time( private var _hour: Int, private var _minute: Int ) { | |
| if ( _minute > 59 ) { | |
| _hour += ( _minute / 60 ) | |
| _minute = _minute % 60 | |
| } | |
| if ( hour > 23 ) { | |
| _hour = 23 | |
| } |
This file contains hidden or 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
| class Account { | |
| private var balance: Double = 0; | |
| def credit = if ( balance < 0 ) -balance else 0 | |
| def credit_=( value: Int ) { | |
| balance = -value | |
| } | |
| def debit = if ( balance > 0 ) balance else 0 |
This file contains hidden or 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
| class Counter { | |
| private var counter: Int = 0; | |
| def increment(): Int = { | |
| if ( counter == Int.MaxValue ) { | |
| counter = 0 | |
| } else { | |
| counter += 1 | |
| } | |
| counter |
This file contains hidden or 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 frequency = new scala.collection.mutable.HashMap[String, Int] | |
| def process( word: String ): Unit = { | |
| frequency += ( word -> ( frequency.getOrElse( word, 0 ) + 1 ) ) | |
| } | |
| var in = new java.util.Scanner( new java.io.File ( "/Users/andriy/tmp/myfile.txt" ) ) | |
| while ( in.hasNext ) process ( in.next ) |
This file contains hidden or 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
| def pow( x: Double, p: Int ): Double = { | |
| if ( p == 1 ) x | |
| else if ( p == 0 ) 1 | |
| else if ( p < 0 ) 1 / pow( x, -p ) | |
| else if ( p % 2 == 0 ) { | |
| val y = pow( x, p / 2) | |
| y * y | |
| } | |
| else pow( x, p - 1) * x | |
| } |
This file contains hidden or 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
| #!/bin/sh | |
| # Usage: ./clear-old-data `cat $HOME/var/run/nginx.pid` -USR1 $HOME/logs/*.log | |
| if [ ! -z $1 ] ; then | |
| _PID=$1 | |
| shift | |
| _SIG=$1 | |
| shift | |
| _YESTERDAY=`date -v -1d '+%Y-%m-%d'` |