Skip to content

Instantly share code, notes, and snippets.

View tanveer's full-sized avatar

Tanveer Bashir tanveer

View GitHub Profile
func generateMatrix(_ n: Int) -> [[Int]] {
var maxRow = n
var maxCol = n
var startRow = 0
var startCol = 0
let currRow = 0
let currCol = 0
var direction = "R"
func spiralTraverse(array: [[Int]]) -> [Int] {
var result = [Int]()
var seen = [[Bool]](repeating: [Bool](repeating: false, count: array[0].count), count: array.count)
var firstRow = 0
var firstCol = 0
var lastRow = array.count - 1
var lastCol = array[0].count - 1
var direction = "R"
@tanveer
tanveer / URLSession Calls in Swift 4
Created December 28, 2018 00:22 — forked from cmoulton/URLSession Calls in Swift 4
URLSession Calls in Swift 4
func makeGetCall() {
// Set up the URL request
let todoEndpoint: String = "https://jsonplaceholder.typicode.com/todos/1"
guard let url = URL(string: todoEndpoint) else {
print("Error: cannot create URL")
return
}
let urlRequest = URLRequest(url: url)
// set up the session
@tanveer
tanveer / ioslocaleidentifiers.csv
Created September 4, 2017 01:43 — forked from jacobbubu/ioslocaleidentifiers.csv
iOS Locale Identifiers
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
mr Marathi
bs Bosnian
ee_TG Ewe (Togo)
ms Malay
kam_KE Kamba (Kenya)
mt Maltese
ha Hausa
es_HN Spanish (Honduras)
ml_IN Malayalam (India)
ro_MD Romanian (Moldova)
@tanveer
tanveer / Readme.md
Created April 5, 2017 22:29 — forked from gabrielemariotti/Readme.md
A SimpleSectionedRecyclerViewAdapter: use this class to realize a simple sectioned `RecyclerView.Adapter`.

You can use this class to realize a simple sectioned RecyclerView.Adapter without changing your code.

The RecyclerView should use a LinearLayoutManager. You can use this code also with the TwoWayView with the ListLayoutManager (https://github.com/lucasr/twoway-view)

This is a porting of the class SimpleSectionedListAdapter provided by Google

Screen

Example:

@tanveer
tanveer / Readme.md
Created April 5, 2017 22:28 — forked from gabrielemariotti/Readme.md
A SimpleSectionedRecyclerViewAdapter: use this class to realize a simple sectioned `RecyclerView.Adapter`.

You can use this class to realize a simple sectioned RecyclerView.Adapter without changing your code.

The RecyclerView should use a LinearLayoutManager. You can use this code also with the TwoWayView with the ListLayoutManager (https://github.com/lucasr/twoway-view)

This is a porting of the class SimpleSectionedListAdapter provided by Google

Screen

Example:

[
{
"id": 1,
"name": "20th and C",
"area": "Stuyvesant Town",
"latitude": 40.729352,
"longitude": -73.966452,
"image_url": "http://quartersnacks.com/wp-content/uploads/2010/05/20thc-1.jpg",
"type": "Ledge, Gap",
"address": {
[
{
"id":1,
"name":"Konica Minolta",
"models":[
{
"model":"C220",
"codes":{
"123":"Tray lift",
"345":"Tray drop",
@tanveer
tanveer / osx_bootstrap.sh
Created November 10, 2016 13:34 — forked from codeinthehole/osx_bootstrap.sh
Script to install stuff I want on a new OSX machine
#!/usr/bin/env bash
#
# Bootstrap script for setting up a new OSX machine
#
# This should be idempotent so it can be run multiple times.
#
# Some apps don't have a cask and so still need to be installed by hand. These
# include:
#
# - Twitter (app store)
[
{
"id":1,
"sender":{
"id":100,
"first_name":"Mock",
"last_name":"User",
"picture_url":"https://cdn1.iconfinder.com/data/icons/user-pictures/101/malecostume-512.png",
"crew_code":"NUYAWK",
"api_key":"123456789012345"