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 / simple_word_cloud.r
Created August 22, 2012 11:15
A very simple word cloud generation code in R
library(tm)
library(wordcloud)
library(RColorBrewer)
my.corpus = Corpus(DirSource("directory_containing_files_to_be_processed"))
my.corpus <- tm_map(my.corpus, tolower)
my.corpus <- tm_map(my.corpus, stripWhitespace)
my.corpus <- tm_map(my.corpus, removePunctuation)
@emres
emres / sparql-quiz.rq
Created July 19, 2012 21:20
SPARQL Quiz
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT
?v1NoCast ?v1OuterFloat ?v1InnerFloat ?v1OuterdDecimal ?v1InnerDecimal
?v10NoCast ?v10OuterFloat ?v10InnerFloat ?v10OuterdDecimal ?v10InnerDecimal
?v100NoCast ?v100OuterFloat ?v100InnerFloat ?v100OuterdDecimal ?v100InnerDecimal
WHERE
{
BIND ( 1 / 3 as ?v1NoCast)
BIND ( xsd:float(1 / 3) as ?v1OuterFloat)
@emres
emres / get_common_actors.py
Created July 11, 2012 17:39
List the names of common actors between The Killing and Continuum
from imdb import IMDb
imdb = IMDb()
the_killing = imdb.get_movie('1637727')
continuum = imdb.get_movie('1954347')
imdb.update(the_killing, 'full credits')
imdb.update(continuum, 'episodes')
continuum_episode = continuum['episodes'][1][5]
@emres
emres / common_actors_of_the_killing_and_continuum.sparql
Created July 11, 2012 17:24
SPARQL query that tries to find the actors who took role both in Continuum and The Killing (run this query at http://live.dbpedia.org/sparql )
PREFIX dbpedia2: <http://dbpedia.org/property/>
SELECT ?artist
FROM NAMED <http://live.dbpedia.org>
WHERE {
<http://dbpedia.org/resource/The_Killing_%28U.S._TV_series%29> dbpedia2:starring ?artist .
<http://dbpedia.org/resource/Continuum_%28TV_series%29> dbpedia-owl:starring ?artist .
}
LIMIT 10
@emres
emres / common_actors_of_hoffa_and_the_shining.sparql
Created July 11, 2012 17:10
SPARQL query that successfully find the actors who took role both in The Shining and Hoffa (run this query at http://live.dbpedia.org/sparql )
PREFIX dbpedia2: <http://dbpedia.org/property/>
SELECT ?artist
FROM NAMED <http://live.dbpedia.org>
WHERE {
<http://dbpedia.org/resource/The_Shining_%28film%29> dbpedia2:starring ?artist .
<http://dbpedia.org/resource/Hoffa> dbpedia-owl:starring ?artist .
}
LIMIT 10
@emres
emres / number-of-days-between-two-dates.el
Created June 26, 2012 13:17
Number of days between two dates
(defun number-of-days-between-dates (date1 date2)
"Returns the number of days between two dates.
Usage:
(number-of-days-between-dates \"yyyy-mm-dd\" \"yyyy-mm-dd\")
Or
M-x number-of-days-between-dates"
@emres
emres / gist:1510269
Created December 22, 2011 13:11
Create bubble chart in Excel 2010
Public Sub CreateBubbleChart()
''' Reference : Tom Hollander, http://blogs.msdn.com/b/tomholl/archive/2011/03/28/creating-multi-series-bubble-charts-in-excel.aspx
If (Selection.Columns.Count <> 4 Or Selection.Rows.Count < 3) Then
MsgBox "Selection must have 4 columns and at least 2 rows"
Exit Sub
End If
Dim bubbleChart As ChartObject
Set bubbleChart = ActiveSheet.ChartObjects.Add(Left:=Selection.Left, Width:=600, Top:=Selection.Top, Height:=400)
bubbleChart.Chart.ChartType = xlBubble
@emres
emres / subtract-number-from-current-word.el
Created December 20, 2011 19:45
Substract a number from the current word and replace it with the result.
(defun subtract-number-from-current-word (number)
"Substract a number from the current word and replace it with the result.
Beware: No error checking."
(interactive "p")
(let ((curr-word (current-word)))
(kill-word 1)
(insert (int-to-string
(- (string-to-int curr-word) number)))))
@emres
emres / gist:1494671
Created December 18, 2011 22:27
Language detection in Bash command line - Norvig's problematic example
(echo `cat some_de.txt EN | gzip | wc -c` EN; \
echo `cat some_de.txt DE | gzip | wc -c` DE) \
| sort -n | head -1
@emres
emres / gist:1494649
Created December 18, 2011 22:16
Language detection in Bash command line - retrieving English and German corpus from Gutenberg
wget http://www.gutenberg.org/ebooks/46.txt.utf8 && mv 46.txt.utf8 EN && wget http://www.gutenberg.org/cache/epub/2229/pg2229.txt && mv pg2229.txt DE