View content.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct PostContent: Codable { | |
struct Paragraph: Codable { | |
let id: String | |
let text: String | |
} | |
struct Section: Codable { | |
let id: String | |
let startIndex: Int | |
} | |
var paragraphs: [Paragraph] |
View sample.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"paragraphs": [{ | |
"id": "p0", | |
"text": "aaa" | |
}, | |
{ | |
"id": "p1", | |
"text": "bbb" | |
}, | |
{ |
View .cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef _MSC_VER | |
// windows OS | |
# define BREAK_HERE() __debugbreak() | |
#elif defined(ARCH_X64) || defined(ARCH_X86) | |
// linux or iOS based systems | |
# define BREAK_HERE() __asm__("int $3") | |
#else | |
# define BREAK_HERE() raise(SIGTRAP) | |
#endif |
View factory.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: A UIKit based Playground for presenting user interface | |
import UIKit | |
import PlaygroundSupport | |
enum Maps : Int { | |
case google = 1 | |
case apple | |
} |
View attributedText.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let html = """ | |
<html> | |
<body> | |
<p style="color: blue; | |
font-size: 20px; | |
"> |
View gist:2c015c0d0b7746df4a10a15aeb18acf3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/Users/darshan/Downloads/ffmpeg -filter:v idet -frames:v 100 -an -f rawvideo -y /dev/null -i /Users/darshan/Dropbox/Public/1080i/interlaced/Mug\ Drop_Interlaced_4ss.mp4 | |
video:303750kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000% | |
[Parsed_idet_0 @ 0x7facaf200000] Repeated Fields: Neither: 63 Top: 20 Bottom: 18 | |
[Parsed_idet_0 @ 0x7facaf200000] Single frame detection: TFF: 81 BFF: 0 Progressive: 20 Undetermined: 0 | |
[Parsed_idet_0 @ 0x7facaf200000] Multi frame detection: TFF: 101 BFF: 0 Progressive: 0 Undetermined: 0 |
View fizzbuzz.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write a program that outputs the string representation of numbers from 1 to n. | |
But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”. | |
Example: | |
n = 15, | |
Return: | |
[ |
View minRotation.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func findMin(_ nums: [Int]) -> Int { | |
let firstElement = nums[0] | |
let lastElement = nums[nums.count-1] | |
if(firstElement < lastElement) | |
{ | |
// go from the first element | |
var minElement = firstElement | |
for item in nums | |
{ | |
if !(item > firstElement) && (item < lastElement) |
View gist:f9900e3b05f46096fc674d062f2441b7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class Solution { | |
func flipAndInvertImage(_ A: [[Int]]) -> [[Int]] | |
{ | |
if(A.count > 0) | |
{ | |
var finalArray = [[Int]]() | |
for item in A { | |
View gist:b56c06d8a432a3639911f9adc609aed4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First thing is you need a AVAsset. | |
// Once you have an asset, you need to determine the type of preset you need to use. | |
// You can consider a preset as a set of properties, which is provided to the exporter. | |
// I do this for helping me with my export. | |
-(NSString*)determineCompatibleExportPresetForAsset:(AVAsset*)asset | |
{ | |
NSArray<NSString*>* presetsRankedByPriority = @[AVAssetExportPresetHighestQuality, AVAssetExportPresetMediumQuality, AVAssetExportPresetLowQuality]; | |
NSArray* compatiblePresets = [AVAssetExportSession exportPresetsCompatibleWithAsset:asset]; | |
for (NSString* preset in presetsRankedByPriority) |
NewerOlder