Skip to content

Instantly share code, notes, and snippets.

View emres's full-sized avatar
💭
"The purpose of computing is insight, not numbers." -- Richard W. Hamming

Emre Sevinç emres

💭
"The purpose of computing is insight, not numbers." -- Richard W. Hamming
View GitHub Profile
@emres
emres / stormTopologyCheck.py
Created April 27, 2017 10:02 — forked from wesfloyd/stormTopologyCheck.py
Script runs constantly at X seconds interval checking to see if topologies have stopped processing new Tuples
# Wes Floyd April 2015
import sys
import requests
import json
import argparse
import pprint
import time
pp = pprint.PrettyPrinter(indent=4)
@emres
emres / calculate.test-result.el
Last active February 26, 2017 14:27
Emacs Lisp function to calculate a test result
(defun calculate-test-result ()
"Calculate test result.
This function assumes that you use Y for correct answers, and N for wrong ones."
(interactive)
(let* ((correct (how-many "Y" 1))
(wrong (how-many "N" 1))
(total (+ correct wrong))
(percentage (/ (* 100.0 correct)
total)))
(message (concat "Your test score percentage: "
(if (friday-the-13th-full-moon-p)
"Bad luck!"
"Good luck!")
@emres
emres / friday-the-13th-full-moon.el
Created November 12, 2015 22:14
Emacs Lisp function to check whether the current date is Friday the 13th with full moon
(require 'cl)
(defun friday-the-13th-full-moon-p ()
"Return true if the current day is Friday the 13th with a full moon."
(let ((value)
(current-day (nth 3 (decode-time)))
(current-month (nth 4 (decode-time)))
(current-year (nth 5 (decode-time)))
(full-moon 2))
(dolist (elt (lunar-phase-list current-month current-year) value)
  1. General Background and Overview
@emres
emres / newStructure.scala
Created October 28, 2014 20:04
Alternative methods for creating a new structure based on an existing
/**
* Given the following:
*/
val myArray = Array(("the", (1, 2)), ("word", (3, 4)), ("count", (5, 6)))
/**
* How can we create a new Array such as
*
* Array(("the", 3), ("word", 7), ("count", 11))
@emres
emres / keybase.md
Created October 8, 2014 07:31
keybase.md

Keybase proof

I hereby claim:

  • I am emres on github.
  • I am emres (https://keybase.io/emres) on keybase.
  • I have a public key whose fingerprint is 52A4 4218 B7EC BED2 1312 DDFE 694E 5BD4 AEC5 CE26

To claim this, I am signing this object:

@emres
emres / PatternPower.scala
Created January 4, 2014 19:14
A concrete demonstration of the technique presented by Joshua Suereth in Devoxx 2013.
case class Person(name: String, residence: Seq[Residence])
case class Residence(city: String, country: String)
object LivesIn {
def unapply(p: Person): Option[Seq[String]] =
Some(
for(r <- p.residence)
yield r.city
)
}
object LivesIn {
def unapply(p: Person): Option[Seq[String]] =
Some(
for(r <- p.residence)
yield r.city
)
}
class StringSeqContains(value: String) {
def unapply(in: Seq[String]): Boolean =
val peopleInIstanbul = people collect {
case person @ LivesIn(Istanbul()) => person.name
}