Skip to content

Instantly share code, notes, and snippets.

Avatar
🏆
Winning The Life

Seyhun Akyürek seyhunak

🏆
Winning The Life
View GitHub Profile
@seyhunak
seyhunak / EmployeeApiService.swift
Last active Sep 22, 2022
Swift 5 - MVVM - ViewController, ViewModel, Model, Datasource, Webservice
View EmployeeApiService.swift
import Foundation
class APIService : NSObject {
private let sourcesURL = URL(string: "http://dummy.restapiexample.com/api/v1/employees")!
func apiToGetEmployeeData(completion : @escaping (Employees) -> ()){
URLSession.shared.dataTask(with: sourcesURL) { (data, urlResponse, error) in
if let data = data {
let jsonDecoder = JSONDecoder()
let empData = try! jsonDecoder.decode(Employees.self, from: data)
@seyhunak
seyhunak / seeds.rb
Created Dec 7, 2013
Rails - Import SQL file as seed
View seeds.rb
unless Rails.env.production?
connection = ActiveRecord::Base.connection
connection.tables.each do |table|
connection.execute("TRUNCATE #{table}") unless table == "schema_migrations"
end
sql = File.read('db/import.sql')
statements = sql.split(/;$/)
statements.pop
@seyhunak
seyhunak / mini_magick.rb
Created Sep 9, 2013
How to add a text caption to an image with MiniMagick and Ruby
View mini_magick.rb
require 'rubygems'
require 'mini_magick'
img = MiniMagick::Image.from_file("jpeg.jpg")
img.combine_options do |c|
c.gravity 'Southwest'
c.draw 'text 10,10 "whatever"'
c.font '-*-helvetica-*-r-*-*-18-*-*-*-*-*-*-2'
c.fill("#FFFFFF")
end
@seyhunak
seyhunak / git-flow.md
Last active May 9, 2022
Git Flow - Cheatsheet
View git-flow.md

Git-Flow

Initialize a Repository for git-flow

git flow init -d

(Omit -d if you want to select values other than the defaults.)

Features

@seyhunak
seyhunak / view.rb
Created Oct 29, 2012
Custom confirmation dialog in Rails
View view.rb
# Coffeescript
$.rails.allowAction = (link) ->
return true unless link.attr('data-confirm')
$.rails.showConfirmDialog(link) # look bellow for implementations
false # always stops the action since code runs asynchronously
$.rails.confirmed = (link) ->
link.removeAttr('data-confirm')
link.trigger('click.rails')
@seyhunak
seyhunak / global.css.scss
Created Mar 14, 2014
SASS (Bourbon + Bourbon Neat) - Variables, Base, Typography classes
View global.css.scss
// Place all the styles related to the welcome controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
@import "bourbon";
@import "neat";
/*
* Variables
*/
View login_ios_version.sql
select (case when tile = 50 then 'Median' when tile = 95 then '95%' else '5%' end) as tile
, app_display_version
, max(cast( ROUND(duration/1000)/1000 as numeric) ) max_duration_s
, min(cast( ROUND(duration/1000)/1000 as numeric) ) min_duration_s
from (
select
trace_info.duration_us duration
, ntile(100) over (partition by (app_display_version) order by trace_info.duration_us) tile
, app_display_version
View login_ios_radio.sql
select (case when tile = 50 then 'Median' when tile = 95 then '95%' else '5%' end) as tile
, radio_type
, max(cast( ROUND(duration/1000) as numeric)/1000 ) max_duration_s
, min(cast( ROUND(duration/1000) as numeric)/1000 ) min_duration_s
from (
select
trace_info.duration_us duration
, ntile(100) over (partition by (radio_type) order by trace_info.duration_us) tile
View login_ios.sql
select
(case when tile = 50 then 'Median' when tile = 95 then '95%' else '5%' end) as tile
, dt
, max(cast( ROUND(duration/1000) as numeric)/1000 ) max_duration_s
, min(cast( ROUND(duration/1000) as numeric)/1000 ) min_duration_s
from (
select
trace_info.duration_us duration
, ntile(100) over (partition by (DATE(event_timestamp)) order by trace_info.duration_us) tile
View login_ios_country.sql
select (case when tile = 50 then 'Median' when tile = 95 then '95%' else '5%' end) as tile
, country
, max(cast( ROUND(duration/1000)/1000 as numeric) ) max_duration_s
, min(cast( ROUND(duration/1000)/1000 as numeric) ) min_duration_s
, logonCount
from (
select
trace_info.duration_us duration
, count(trace_info.duration_us ) OVER(partition by (country)) logonCount -- you might want to use this as a sort later