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
/*A zero-indexed array A consisting of N different integers is given. The array contains integers in the range [1..(N + 1)], which means that exactly one element is missing. | |
Your goal is to find that missing element. | |
Write a function: | |
int solution(int A[], int N); | |
that, given a zero-indexed array A, returns the value of the missing element. | |
For example, given array A such that: | |
A[0] = 2 | |
A[1] = 3 | |
A[2] = 1 | |
A[3] = 5 |
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 test | |
import com.decodified.scalassh._ | |
object TestSSH { | |
def main(args: Array[String]) { | |
val res = SSH("host") { client => | |
client.exec("ls -a").right.map { result => | |
println("Result:\n" + result.stdOutAsString()) | |
} |
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 scala.concurrent.impl | |
import java.util.concurrent.{ExecutorService, Executors, ThreadFactory} | |
import scala.concurrent.{ExecutionContext, ExecutionContextExecutor, Future} | |
import scala.concurrent.forkjoin.ForkJoinPool | |
import scala.util.control.NonFatal | |
import scala.util.{Failure, Success} | |
object Cancelled extends RuntimeException |
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 scalikejdbc | |
import java.sql.{Connection, ResultSet, SQLException} | |
import java.util.{Timer, TimerTask} | |
import scala.collection._ | |
import scala.util.Try | |
object SQLToIterator { | |
def apply[A, E <: WithExtractor](sql: SQL[A, HasExtractor])(implicit connectionPool: ConnectionPool): SQLToIterator[A, E] = { |
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
# pass size in mb and optional name | |
function ram_disk_mb() { | |
name=${2:-disk} | |
diskutil erasevolume HFS+ "ram_$name" $(hdiutil attach -nomount ram://$(($1*2048))) | |
} | |
# pass size in gb and optional name | |
function ram_disk_gb() { | |
ram_disk_mb $(($1*1024)) | |
} |
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
Verifying that "tolsi12.id" is my Blockstack ID. https://onename.com/tolsi12 |
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 org.bluetooth.bledemo; | |
import java.util.HashMap; | |
import android.util.SparseArray; | |
public class BleNamesResolver { | |
private static HashMap<String, String> mServices = new HashMap<String, String>(); | |
private static HashMap<String, String> mCharacteristics = new HashMap<String, String>(); | |
private static SparseArray<String> mValueFormats = new SparseArray<String>(); |
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 com.wavesplatform.wavesj.{Asset, Node, PrivateKeyAccount, Transaction} | |
object Mainb extends App { | |
val seeds = Seq.fill(30)(PrivateKeyAccount.generateSeed()) | |
val myAcc = new PrivateKeyAccount("", 0, 'W') | |
val addresses = seeds.map(s => new PrivateKeyAccount(s, 0, 'W')) | |
val txs = addresses.map(a => Transaction.makeTransferTx(myAcc, a.getAddress, 100000000, Asset.WAVES, 100000, Asset.WAVES, "")) | |
println(seeds.mkString("\n")) | |
println(txs.map(_.getJson)) |
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
#!/usr/bin/env monkeyrunner | |
import time | |
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice | |
device = MonkeyRunner.waitForConnection() | |
# Touch down screen | |
device.touch(100, 500, MonkeyDevice.DOWN) |
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
object Base58Length { | |
private val BytesMaxValue = 256 | |
private val Base58MaxValue = 58 | |
private val BytesLog = math.log(BytesMaxValue) | |
private val BaseLog = math.log(Base58MaxValue) | |
def base58Length(byteArrayLength: Int): Int = math.ceil(BytesLog / BaseLog * byteArrayLength).toInt | |
def bytesLength(base58Length: Int): Int = math.ceil(BaseLog / BytesLog * base58Length).toInt | |
} |
OlderNewer