Skip to content

Instantly share code, notes, and snippets.

View umutakturk's full-sized avatar
🏠
Working from home

Umut Akturk umutakturk

🏠
Working from home
View GitHub Profile
@umutakturk
umutakturk / A-HopperBus-CodeSample-Readme.md
Created May 29, 2018 20:11 — forked from TosinAF/A-HopperBus-CodeSample-Readme.md
Example use of the Model-View-ViewModel Pattern in iOS (Swift) as explained in http://www.objc.io/issue-13/mvvm.html. Full Source Code can be found at https://github.com/TosinAF/HopperBus-iOS

I decided to build an iOS app for my University's bus service that runs through the various campuses.

xy

It was an interesting challenge as I had nothing but the printed timetables (http://www.nottingham.ac.uk/about/documents/903-times.pdf) to use as the data.

Thus I had to come with a suitable data structure that would complement the design & user experience i had in mind for the app.

I also decided to take the challenge of writing the app in swift. This project has helped me get to up speed with swift really quickly.

@umutakturk
umutakturk / file.md
Created January 7, 2014 10:48
PHP kodun renklendirilmiş çıktısı.
$ php -s input.php > output.html
@umutakturk
umutakturk / heroku_timezone.sh
Created July 21, 2013 23:09
Change heroku timezone from the CLI.
heroku config:add TZ=Europe/Istanbul
@umutakturk
umutakturk / distance.php
Created June 27, 2013 21:21
Calculating distance between two geo-points.
<?php
function distance($fromLat, $fromLon, $toLat, $toLon) {
$radius = 6378.1; // 3963.17 miles
$dLat = deg2rad($toLat - $fromLat);
$dLon = deg2rad($toLon - $fromLon);
$tmp = cos(deg2rad(($fromLat + $toLat) / 2)) * $dLon;
$distance = $radius * sqrt($dLat * $dLat + $tmp * $tmp);
return round($distance, 1);
}
@umutakturk
umutakturk / mongodb_backup.sh
Created June 27, 2013 18:16
MongoDB Backup script.
#!/bin/bash
BACKUP_DIR="$HOME/path/to/backup"
USER="db_user"
PASS="db_pass"
HOST="db_host"
PORT="db_port"
NAME="db_name"
if [ ! -d $BACKUP_DIR ];then
@umutakturk
umutakturk / slugify.rb
Last active December 16, 2015 05:19
Translate special characters to ASCII characters in Ruby.
def slugify(text)
accents = {
['à','á','â','ã','å','ǻ','ā','ă','ą','ǎ','ª'] => 'a',
['ä','æ','ǽ'] => 'ae',
['Æ','Ǽ'] => 'AE',
['Ä'] => 'Ae',
['Ü'] => 'Ue',
['Ç','Ć','Ĉ','Ċ','Č'] => 'C',
['ç','ć','ĉ','ċ','č'] => 'c',
['Ð','Ď','Đ'] => 'D',
class BaseConvert
CHARS = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ_abcdefghijkmnopqrstuvwxyz" # !-+*$
BASE = CHARS.length
def self.num_to_str(num = nil)
str = ""
return 0 if num.nil? || num.zero?
@umutakturk
umutakturk / compile.sh
Created April 7, 2013 14:41
Compile C++ file on Ubuntu.
g++ helloWorld.cpp -o helloWorld
ls
./helloWorld
@umutakturk
umutakturk / binomial.cpp
Created October 20, 2012 12:27
Binomial Coefficients
/**
* Binomial Coefficients
*
* @author K. Umut Aktürk <http://umut.me>
* @date October 20, 2012
*/
#include <iostream>
using namespace std;
@umutakturk
umutakturk / test.cpp
Created October 19, 2012 20:32
C++ Code Samples - Week 2
#include <iostream>
using namespace std;
int main()
{
/*
int a, b;
a = 10;
b = 4;