Skip to content

Instantly share code, notes, and snippets.

View emrepun's full-sized avatar

emrepun emrepun

  • Munich
View GitHub Profile
@emrepun
emrepun / pre_processing.py
Last active December 5, 2019 22:59
engine_gist_1
import numpy as np
import pandas as pd
from nltk.corpus import stopwords
df = pd.read_csv('city_data.csv')
def clear(city):
city = city.lower()
city = city.split()
city_keywords = [word for word in city if word not in stopwords.words('english')]
@emrepun
emrepun / BubbleSortDafny.dfy
Last active September 4, 2024 10:34
Bubble Sort method verification with Dafny
predicate sorted(a: array?<int>, l: int, u: int)
reads a
requires a != null
{
forall i, j :: 0 <= l <= i <= j <= u < a.Length ==> a[i] <= a[j]
}
predicate partitioned(a: array?<int>, i: int)
reads a
requires a != null
@emrepun
emrepun / ActivityIndicator.swift
Created July 7, 2018 10:31
Custom ActivityIndicator
import Foundation
import UIKit
class ActivityIndicator {
private init() {}
//1
static let shared = ActivityIndicator()
@emrepun
emrepun / a.swift
Created July 1, 2018 11:08
random func
func subscribeToUsers() {
//1
let secondVC = tabBarController?.viewControllers?.last as! UserViewController
secondVC.userToShowInFirstVcObservable.subscribe(onNext: { [weak self] user in
//2
self?.userToDisplay.value = user
}).disposed(by: disposeBag)
}
@emrepun
emrepun / z.swift
Created July 1, 2018 11:02
random func
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return userArray.value.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "cell") else {
@emrepun
emrepun / y.swift
Created July 1, 2018 10:59
random func
func deployUsers() {
userArray.value = [
User(name: "Narcisa", age: 21, city: "Bucharest"),
User(name: "Vincent", age: 24, city: "Hamburg"),
User(name: "Eray", age: 29, city: "Istanbul")
]
}
@emrepun
emrepun / x.swift
Created July 1, 2018 10:38
random func
func configureLabels() {
//1
userToDisplayObservable.subscribe(onNext: { [weak self] user in
//2
self?.nameLabel.text = user.name
self?.ageLabel.text = String(user.age)
self?.cityLabel.text = user.city
}).disposed(by: disposeBag)//3
}
class User {
let name: String
let age: Int
let city: String
init(name: String, age: Int, city: String) {
self.name = name
self.age = age
self.city = city
}
@emrepun
emrepun / Triangle Sum Swift.swift
Last active June 16, 2018 19:42
Sum up from top the bottom of a String Triangle with NON PRIME numbers
//Implemented in Swift 4
import Foundation
class ViewController: UIViewController {
var assignmentString = """
215
193 124
117 237 442
@emrepun
emrepun / website_blocker.py
Created January 31, 2018 14:28
Website Blocker with Python
import time
from datetime import datetime as dt
#Blocks the access to the websites incuded in the website_list, between the given hours.
#Blocking hours for this project is set to 8am - 4pm, but can be adjusted easily.
#Remember you are gonna have to run this code in sudo, or administrator role in order to access your hosts.
hosts_temp = "hosts"
hosts_path_for_windows = r"C:\Windows\System32\drivers\etc\hosts"
hosts_path ="/private/etc/hosts"
redirect = "127.0.0.1"