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 / People.scala
Created January 4, 2014 19:00
A List of People objects.
val people =
List(Person("Emre", List(Residence("Antwerp", "BE"))),
Person("Berk", List(Residence("Antwerp", "BE"))),
Person("Ergin", List(Residence("Istanbul", "TR"),
Residence("Ankara", "TR"))),
Person("Ahmet", List(Residence("Istanbul", "TR"))))
@emres
emres / primeAges.sh
Created December 20, 2013 10:37
Prints how many prime ages you have left (that is, if you are 31 already.)
echo "You have, with high probability, at most" $(for age in {32..122}; do factor $age | cut -d' ' -f3 | grep -v "[0-9]\+"; done | wc -l) "prime birthdays left."
@emres
emres / HelloWorldGWT.java
Last active December 23, 2015 07:18
A very short example to demonstrate that GWT SDK 2.5.1 still does not support Java 7 constructs, such as switch statements for String values: even though the file compiles fine, it gives error during run-time.
package com.manning.gwtia.ch02.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
public class HelloWorld implements EntryPoint {
@Override
public void onModuleLoad() {
@emres
emres / source_stats.sh
Created September 10, 2013 09:51
Finds the .java or .xml files in the ~/dev and prints the number of lines, excluding lines with blanks.
find ~/dev -regextype posix-egrep -iregex ".*(java|xml)" -print0 | xargs -0 -I sourceFile sed '/^[ \t]*$/d' sourceFile | wc -l
.PS
box rad 0.15
move down
move right
box rad 0.15
spline <-> from 1st box .e right then down left to last box .w
.PS
box rad 0.15
move down
move right
box rad 0.15
spline <-> from 1st box .e right then down left to last box .w
.PE
@emres
emres / textbook.R
Created May 24, 2013 20:12
R source code that is used for producing the graphics used in the blog entry titled "Results of the survey: Why don’t we have secondary school textbooks with source code in them?"
## textbook.R
## Tested on:
## R version 2.15.1 (2012-06-22) -- "Roasted Marshmallows"
library(ggplot2)
library(car)
setwd("~/Documents/programming/R/")
textbook <- read.csv("textbook.csv", na.strings = "")
@emres
emres / lid.sh.post
Created February 26, 2013 20:28
/etc/acpi/local/lid.sh.post file as a workaround for 'suspend not working when laptop is closed' problem.
#!/bin/bash
grep -q closed /proc/acpi/button/lid/*/state
if [ $? = 0 ]
then
dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
fi
@emres
emres / ProcessBlog.scala
Created February 9, 2013 21:08
A very short Scala program that I have created to process my wordpress blog's imported XML file to detect the gist URLs
import xml.XML
object ProcessBlog extends App {
val myBlog = XML.loadFile("fzblogs.wordpress.2013-02-08.xml")
for (item <- (myBlog \\ "item")) {
val indexOfGist = item.text.indexOf("//gist")
if (indexOfGist > 0) {
println((item \\ "guid").text + " " +
@emres
emres / CpuThreadAnalyser.sh
Created August 28, 2012 10:05
Prints information about the Java threads that consumes most of the CPU
#!/bin/bash
# Prints information about the Java threads that consumes most of the CPU
# Derived from the information given in the blog entry at
#
# http://nurkiewicz.blogspot.be/2012/08/which-java-thread-consumes-my-cpu.html
#
# Changelog:
#
# - Removed the `top', `perl', and `grep' dependencies.