Skip to content

Instantly share code, notes, and snippets.

@getmetorajesh
getmetorajesh / Sample akka scala
Last active June 11, 2016 15:32
Akka scala sample
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"
// 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",
@getmetorajesh
getmetorajesh / singleton swift
Created March 1, 2016 05:39
Single line singleton swift
// 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
extension FirstOrderAPI {
var method: HTTPMethod {
switch self {
case .customer,.broker, .users:
return .GET
case .AddCustomer,.AddBroker, .AddUsers:
return .POST
}
}
1. you can print enums
enum Animals {
case Dog, Cat, Troll, Dragon
}
let a = Animals.Dragon
print(A)
2. Associated values in Enums
@getmetorajesh
getmetorajesh / lopmonhoc.js.jsx
Last active August 29, 2015 14:27 — forked from revskill10/lopmonhoc.js.jsx
Integrate Datatable with React.js
/** @jsx React.DOM */
var LopMonHoc = React.createClass({
getInitialState: function(){
return {data: []}
},
loadData: function(){
$.ajax({
url: '/daotao/lops',
success: function(data){
{
"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,