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
file_contents = open 'filename.txt', &:read |
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
package com.twitter.externalstorage; | |
import android.Manifest; | |
import android.app.Activity; | |
import android.content.pm.PackageManager; | |
import android.os.AsyncTask; | |
import android.os.Bundle; | |
import android.os.Environment; | |
import android.util.Log; | |
import android.view.View; |
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
def factorial(n): | |
i = 1 | |
factorial = 1 | |
while i <= n: | |
factorial = factorial * i | |
i = i + 1 | |
return factorial |
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
def print_abacus(value): | |
abacus = '00000*****' | |
for i in range(0, 10): | |
power_of_ten = 9 - i | |
row_factor = pow(10, power_of_ten) | |
num_beads = value / row_factor | |
if num_beads > 0: | |
value = value % row_factor | |
divider = 10 - num_beads | |
print '|' + abacus[:divider] + ' ' + abacus[divider:] + '|' |
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
sealed class Either<L, R> { | |
class Left<L1, R1>(val left: L1) : Either<L1, R1>() | |
class Right<L1, R1>(val right: R1) : Either<L1, R1>() | |
} | |
val left: Either<String, Throwable> = Either.Left("foo") | |
val right: Either<String, Throwable> = Either.Right(Throwable("bar")) | |
val leftOrRight = left | |
val x: String = when (leftOrRight) { |
OlderNewer