Skip to content

Instantly share code, notes, and snippets.

View haldun's full-sized avatar

Haldun Bayhantopcu haldun

  • Berlin, Germany
View GitHub Profile
@haldun
haldun / gist:6182079
Created August 8, 2013 06:42
itunes internet songs name fetcher
tell application "iTunes"
activate
repeat 64 times
tell application "System Events" to key code 36
delay 1
tell application "System Events"
keystroke "i" using {command down}
tell application "System Events" to tell application process "iTunes"
@haldun
haldun / nba-teams.txt
Created July 2, 2013 08:30
NBA team list in plain text
Atlanta Hawks
Boston Celtics
Brooklyn Nets
Charlotte Bobcats
Chicago Bulls
Cleveland Cavaliers
Dallas Mavericks
Denver Nuggets
Detroit Pistons
Golden State Warriors
@haldun
haldun / rules.rb
Created May 1, 2013 12:43
experiments with a possible rule engine
require 'json'
require 'pp'
class Node
def to_json
to_h.to_json
end
def to_h
raise "Subclass responsibility"
@haldun
haldun / gist:4573101
Created January 19, 2013 15:13
c# delegates
using System;
class LoginResponse
{
public string Token { get; set; }
public LoginResponse(string token) {
Token = token;
}
}
@haldun
haldun / convert.rb
Created December 20, 2012 18:42
Rename a bunch of destroyallsoftware screencasts with help from ffmpeg, tesseract and ruby
require 'tesseract'
ENGINE = Tesseract::Engine.new { |e| e.language = :eng }
def grab_screenshot(file)
`ffmpeg -i #{file} -ss 0 -vframes 1 -f image2 #{screenshot_name(file)} -loglevel quiet`
screenshot_name(file)
end
def screenshot_name(file)
@haldun
haldun / posts_controller.rb
Created November 11, 2012 17:48
decent exposure with sti
class PostsController < ApplicationController
respond_to :html, :json
expose(:posts) { post_type.scoped }
expose(:post_type) { params[:type].constantize }
expose(:post) do
if id = params[:id]
posts.find id
else
post_type.new params[post_type.name.downcase.to_sym]
@haldun
haldun / es.sh
Created November 7, 2012 08:06
Install ElasticSearch on Ubuntu 12.04
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.0.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share
@haldun
haldun / gist:3870544
Created October 11, 2012 06:19
comp242-11-10-2012
t = 0:0.01:2.5;
voltage = sin(2 * pi * 10* t);
current = cos(2 * pi * 10 * t);
% draw first plot
subplot(2, 1, 1); plot(voltage);
title('voltage'); xlabel('time(sec)'); ylabel('volts');
% draw second plot
subplot(2, 1, 2); plot(current);
@haldun
haldun / flags.c
Created March 18, 2012 22:12
flags in c with enum
#include <stdio.h>
typedef enum {
kShareViewTypeNone = 0,
kShareViewTypeFacebook = 1 << 0,
kShareViewTypeTwitter = 1 << 1,
kShareViewTypeAll = kShareViewTypeFacebook | kShareViewTypeTwitter
} ShareViewType;
int main (int argc, char const *argv[])
@haldun
haldun / chunk.js
Created February 16, 2012 22:36
Split an array into evenly sized subarrays
var chunk = function(array, n) {
var retval = [];
for (var i = 0, len = array.length; i < len; i += n) {
retval.push(array.slice(i, i + n));
}
return retval;
};