Skip to content

Instantly share code, notes, and snippets.

var server = require('net').createServer();
server.on('connection', function (s) {
s.write("HTTP/1.1 200 OK\n");
s.write("Content-type: text/html\n\n");
s.write("<h1>Honey, I <span style=\"color: red;\"><3</span> U!</h1>\n");
s.end();
});
server.listen(1337);
@ConnorWGarvey
ConnorWGarvey / hubot-irc-commands.coffee
Last active December 20, 2015 06:59
IRC commands for Hubot
# Description:
# Anyone can have voice or op
#
# Commands:
# hubot make me an op
# hubot make <name> an op
# hubot give me voice
# hubot give <name> voice
module.exports = (robot) ->
@macalinao
macalinao / sad.go
Created August 4, 2016 19:10
i cry every time
// StatusesWithIds finds all condition statuses that match the given ids.
func StatusesWithIds(in []*cpb.ConditionStatus, ids []*cpb.ConditionId) []*cpb.ConditionStatus {
// create our filter set
set := map[string]bool{}
for _, id := range ids {
set[util.StringifyID(id)] = true
}
// i.e. ids.map(util.StringifyID).toSet
@ResidentMario
ResidentMario / top_500.txt
Created May 28, 2016 05:27
Top 500 Wealthiest Landowners in New York City
OwnerName
DCAS/DEPARTMENT OF ED 1.820269e+10
PORT AUTHORITY NY & N 1.801034e+10
PARKS AND RECREATION 1.163104e+10
NYC HOUSING AUTHORITY 9.589786e+09
HEALTH AND HOSPITALS 2.717476e+09
JOINTLY OWNED PLAYGRO 2.424863e+09
DEPT OF PARKS AND REC 2.386076e+09
NEW YORK UNIVERSITY 2.260595e+09
RCPI HOLDCO LCC 1.923597e+09
@pathikrit
pathikrit / EquivalenceLock.scala
Last active February 7, 2017 21:14
Locking based on object equality rather than referential equality in Scala
/**
* An util that provides synchronization using value equality rather than referential equality
* It is guaranteed that if two objects are value-equal, their corresponding blocks are invoked mutually exclusively.
* But the converse may not be true i.e. if two objects are not value-equal, they may be invoked exclusively too
* Note: Typically, no need to create instances of this class. The default instance in the companion object can be safely reused
*
* @param size There is a 1/size probability that two invocations that could be invoked concurrently is invoked sequentially
*
* Example usage:
* import EquivalenceLock.{defaultInstance => lock}
@diegopacheco
diegopacheco / FRP.md
Last active August 8, 2017 12:26
Functional Reactive Streams | FRP | Akka | Streams
import com.amazonaws.HttpMethod
import com.amazonaws.services.s3.AmazonS3Client
import com.amazonaws.services.s3.model._
...
val s3Client = new AmazonS3Client
private def getFlow(pathRaw: String, method: HttpMethod) = {
// clean the path
val path = pathRaw.dropWhile(_ == '/').trim
@OlegIlyenko
OlegIlyenko / DateType.scala
Created August 19, 2015 08:23
GraphQL scalar DateType implemented with sangria
case object DateCoercionViolation extends ValueCoercionViolation("Date value expected")
def parseDate(s: String) = Try(new DateTime(s, DateTimeZone.UTC)) match {
case Success(date) => Right(date)
case Failure(_) => Left(DateCoercionViolation)
}
val DateTimeType = ScalarType[DateTime]("DateTime",
coerceOutput = date => ast.StringValue(ISODateTimeFormat.dateTime().print(date)),
coerceUserInput = {
@gphat
gphat / gist:c9d22e1c0d3e0d2546d1
Created August 15, 2014 21:50
Cassandra Datadog JMX Config
instances:
- host: localhost
port: 7199
# user: username
# password: password
# name: cassandra_instance
# #trust_store_path: /path/to/trustStore.jks # Optional, should be set if ssl is enabled
# #trust_store_password: password
# #java_bin_path: /path/to/java #Optional, should be set if the agent cannot find your java executable
@bigsnarfdude
bigsnarfdude / t-digetst.scala
Last active November 5, 2019 03:37
T-Digest in Scala Algebird Plus method
/**
* Example of T-Digest plus method with Algebird Semigroup
*/
import com.tdunning.math.stats.TDigest
import com.twitter.algebird.{Group, Semigroup}
import io.koff.t_digest._
case object TDigestSemigroup extends Semigroup[TDigest] {