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 akka.actor.Actor | |
import akka.actor.ActorSystem | |
import akka.actor.Props | |
object AkkaSample extends App { | |
val system = ActorSystem("AppSystem") | |
val firstActor = system.actorOf(Props[FirstActor], name="firstActor") | |
// send messages to the Actor "receive" method | |
firstActor ! "Known Message" |
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
// application.conf | |
slick.dbs.default.driver="slick.driver.PostgresDriver$" | |
slick.dbs.default.db.driver="org.postgresql.Driver" | |
slick.dbs.default.db.url="jdbc:postgresql://127.0.0.1:5432/play25" | |
slick.dbs.default.db.user="postgres" | |
slick.dbs.default.db.password="" | |
//build.sbt | |
"com.typesafe.play" %% "play-slick" % "2.0.0", | |
"com.typesafe.play" %% "play-slick-evolutions" % "2.0.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
// single line Singletons | |
/* | |
DA RULES OF DA SINGLETON, MAHN | |
There are essentially three things to remember about the Singleton: | |
A singleton has to be unique. This is why it's called a singleton. There can only be one instance for the lifetime of the application it exists in. Singletons exist to give us singular global state. Such examples are NSNotificationCenter, UIApplication, and NSUserDefaults. | |
To maintain a singleton's unique-ness, the initializer of a singleton needs to be private. This helps to prevent other objects from creating instances of your singeton class themselves. Thank you to all who pointed that out to me :) | |
Because of rule #1, in order to have only one instance throughout the lifetime of the application, that means it needs to be thread-safe. Concurrency really sucks when you think about it, but simply put, if a singleton is built incorrectly in code, you can have two threads try to initialize a singleton at the same time which can potentially give you two separate instances of a singlet |
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
extension FirstOrderAPI { | |
var method: HTTPMethod { | |
switch self { | |
case .customer,.broker, .users: | |
return .GET | |
case .AddCustomer,.AddBroker, .AddUsers: | |
return .POST | |
} | |
} | |
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. you can print enums | |
enum Animals { | |
case Dog, Cat, Troll, Dragon | |
} | |
let a = Animals.Dragon | |
print(A) | |
2. Associated values in Enums |
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
/** @jsx React.DOM */ | |
var LopMonHoc = React.createClass({ | |
getInitialState: function(){ | |
return {data: []} | |
}, | |
loadData: function(){ | |
$.ajax({ | |
url: '/daotao/lops', | |
success: function(data){ |
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
{ | |
"bold_folder_labels": true, | |
"color_scheme": "Packages/User/base16-ocean.dark (SL).tmTheme", | |
"detect_indentation": false, | |
"detect_slow_plugins": true, | |
"draw_minimap_border": true, | |
"draw_white_space": "all", | |
"ensure_newline_at_eof_on_save": true, | |
"fade_fold_buttons": false, | |
"find_selected_text": true, |
NewerOlder