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 Person(name) { | |
this.name = name; | |
} | |
var john = new Person('John'); | |
// implicit done by node.js: | |
// exports = module.exports | |
exports.myperson = john; | |
// test = require('./lib/test'); |
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
.gist .line, | |
.gist .line-number { | |
font-size: 12px !important; | |
line-height: 20px !important; | |
margin-bottom: 0px !important; | |
} | |
.gist * { | |
margin-bottom: 0px; | |
} |
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 flash.events.MouseEvent; | |
var sUrl:String = "http://<VIDEO_URI>"; | |
var metaObj:Object = new Object(); | |
var connection:NetConnection = new NetConnection(); | |
var stream:NetStream; | |
connection.connect(null); | |
stream = new NetStream(connection); | |
stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); |
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
implicit val transformFormat: Reads[JsObject] = { | |
(__ \ 'situation).json.update(of[JsString].map { | |
case JsString(situation) => JsString(Sanitizer.toMarkDown(situation)) | |
}) andThen | |
(__ \ 'solution).json.update(of[JsString].map { | |
case JsString(solution) => JsString(Sanitizer.toMarkDown(solution)) | |
}) andThen | |
(__ \ 'name).json.update(of[JsString].map { | |
case JsString(raw) => JsString(Sanitizer.toText(raw)) | |
}) andThen |
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 models | |
import _root_.utils.Sanitizer | |
import reactivemongo.bson._ | |
import play.modules.reactivemongo.json.BSONFormats._ | |
import play.api.libs.json._ | |
import play.api.libs.json.Reads._ | |
import play.api.libs.functional.syntax._ | |
import play.api.libs.json.JsString | |
import scala.Some |
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
for { | |
res <- collection.update(Json.obj("slug" -> idea_slug, "user_id" -> Json.obj("$ne" -> vote.user_id)), | |
Json.obj("$addToSet" -> Json.obj(addType -> vote), | |
"$pull" -> Json.obj(removeType -> Json.obj("user_id" -> vote.user_id)), | |
"$addToSet" -> Json.obj("metrics.attachedUsers" -> vote.user_id)) | |
, getLastError, false) | |
idea <- findOne(Json.obj("slug" -> idea_slug)) | |
} yield { | |
idea | |
} |
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 may need to download angular-routes separately - I got it along with the angular webjar | |
// 2. add path and shim config | |
// require config | |
requirejs.config({ | |
shim: { | |
"app": ["angular"], | |
"angular-route": ["angular"] // !!! |
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
var zlib = require('zlib'); | |
var xml2js = require('xml2js'); | |
var xmlCrypto = require('xml-crypto'); | |
var crypto = require('crypto'); | |
var xmldom = require('xmldom'); | |
var querystring = require('querystring'); | |
var moment = require('moment'); | |
var xmlenc = require('xml-encryption'); | |
var xpath = require('xpath'); |
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
<?php | |
// Connect to mySQL (*blocking*) | |
$link = mysqli_connect("localhost", "user", "password", "test"); | |
// Run a query and store result object (*blocking*) | |
if($result = mysqli_query($link, "SELECT * FROM Person")) { | |
// Fetch data from phps internal buffer into $data | |
$data = mysqli_fetch_all($result); |
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 nodes http module | |
var http = require('http'); | |
// Require a third party mysql module (use "npm install mysql" to install it) | |
var mysql = require('mysql'); | |
// Create a connection pool | |
var pool = mysql.createPool({ | |
host: 'localhost', | |
user: 'username', |
OlderNewer