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
___________ | |
/ \ | |
| Warning ! | | |
\___________/ | |
| | |
-------- __@ __@ | __@ __@ __~@ | |
----- _`\<,_ _`\<,_ _`\<,_ _`\<,_ _`\<,_ | |
---- (*)/ (*) (*)/ (*) (*)/ (*) (*)/ (*) (*)/ (*) | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
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
// build.sbt: | |
// | |
// scalaVersion := "2.11.7" | |
// | |
// libraryDependencies ++= Seq( | |
// "com.github.fomkin" %% "scala-reql-akka" % "0.1.0-SNAPSHOT", | |
// "com.github.fomkin" %% "pushka-json" % "0.2.0", | |
// "com.typesafe.akka" %% "akka-actor" % "2.3.7" | |
// ) |
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
r.db("involve").table("authorization_codes").get(phoneNumber) update { doc ⇒ | |
// Prepare query to SMSC | |
val sendSms = { | |
val params = s"phones=$phoneNumber&mes=$authorizationCode&fmt=3" | |
r.http(s"https://smsc.ru/sys/send.php?login=user&psw=******&$params") | |
} | |
// Check SMS limit is not reached | |
val timeIsOk = r.now().toEpochTime() - doc.getField("last_update").toEpochTime() > 3600 | |
val countIsOk = doc.getField("count") < 3 | |
// If is fine then execute request |
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 java.io.InputStream | |
import java.util.zip.ZipInputStream | |
import scala.io.Source | |
import scala.io.Codec | |
import scala.xml.XML | |
object SimpleOsdParser { | |
type Table = Map[String, Seq[Seq[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
// require() some stuff from npm (like you were using browserify) | |
// and then hit Run Code to run it on the right | |
var IncrementalDOM = require('incremental-dom'), | |
elementOpen = IncrementalDOM.elementOpen, | |
elementOpenStart = IncrementalDOM.elementOpenStart, | |
elementOpenEnd = IncrementalDOM.elementOpenEnd, | |
elementClose = IncrementalDOM.elementClose, | |
elementVoid = IncrementalDOM.elementVoid, | |
text = IncrementalDOM.text, |
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
kevent(0x3, 0x0, 0x0) = 1 0 | |
kevent(0x3, 0x0, 0x0) = 1 0 | |
recvfrom_nocancel(0x4, 0x7FFF5996E6F0, 0x1C) = 28 0 | |
recvfrom_nocancel(0x4, 0x7FFD117007A0, 0x32) = 50 0 | |
select_nocancel(0x5, 0x7FFF5996E720, 0x0) = 0 0 | |
kevent(0x3, 0x7FFF5996E1F0, 0x1) = 0 0 | |
sendto_nocancel(0x4, 0x7FFD11700710, 0x1C) = 28 0 | |
close_nocancel(0x3) = 0 0 | |
getrlimit(0x1008, 0x7FFF5996E748, 0x1C) = 0 0 | |
open_nocancel("/etc/hosts\0", 0x0, 0x1B6) = 3 0 |
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 scala.concurrent.Future | |
import scala.util.{Failure, Success} | |
object Czar { | |
class Context | |
case class ApiTestException(message: String, context: Context, cause: Option[Throwable] = None) | |
extends Exception(message) | |
} | |
trait Czar { |
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 scala.concurrent.Future | |
import scala.language.{implicitConversions, higherKinds, postfixOps} | |
import scala.concurrent.ExecutionContext.Implicits.global | |
trait Kleisli[M[+_], -A, +B] { | |
def apply(a: A): M[B] | |
def >=>[C](k: Kleisli[M, B, C]): Kleisli[M, A, C] | |
def <=<[C](k: Kleisli[M, C, A]): Kleisli[M, C, B] | |
} |
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
<? | |
$ADDYBOT_TOKEN = 'Your token from AddyBot Cabinet'; | |
// The data to send to the API | |
$postData = array( | |
'language' => 'english', | |
'userIdentifier' => 'telegram_user_id' | |
); | |
// Setup cURL |
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 Fsm(states) { | |
var self = this; | |
function onTransition(state, data) { | |
self.state = state; | |
self.data = data; | |
states[state](data, onTransition); | |
} | |
onTransition(Object.getOwnPropertyNames(states)[0], null); | |
} |