Skip to content

Instantly share code, notes, and snippets.

Bhargav Gurlanka bhargavg

Block or report user

Report or block bhargavg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bhargavg
bhargavg / LaunchProcessArgs.swift
Last active Jul 31, 2017
An interactive process
View LaunchProcessArgs.swift
import Foundation
struct LaunchProcessArgs: OptionSet {
let rawValue: Int
static let attachStdIn = LaunchProcessArgs(rawValue: 1 << 0)
static let attachStdOut = LaunchProcessArgs(rawValue: 1 << 1)
static let attachStdErr = LaunchProcessArgs(rawValue: 1 << 2)
static let interactive: LaunchProcessArgs = [.attachStdIn, .attachStdOut, .attachStdErr]
View mutual-recursion-with-composition__not-working.sml
(* Problem: Write a function that returns true
* when invoked with list of alternate 1's and 2's
*
* Example:
* matcher [1,2,1,2]
* matcher [1,2,1]
* matcher [1,2]
* matcher [1]
*
* all of the above should return true
@bhargavg
bhargavg / main.swift
Created Sep 25, 2016
Functional Integer List in Swift - Inspired by Programming Languages Lecture by Dan Grossman (Coursera)
View main.swift
indirect enum IntList {
case empty
case cons(Int, IntList)
}
extension IntList {
static func append(_ xs: IntList, _ ys: IntList) -> IntList{
switch xs {
case .empty: return ys;
case let .cons(head, tail): return .cons(head, append(tail, ys));
View swift-self-build
#!/bin/bash
#
# Faster toolchain build: skips as much as possible.
#
# To use this toolchain from the command line:"
# export TOOLCHAINS=$(whoami)
#
# we build to the same prefix every time (instead of building
# to a versioned prefix) because every time the prefix changes
# *everything* rebuilds.
View Error Handling in JSON Parsing
_ _
| |__ | |__ __ _ _ __ __ _ __ ___ ____ _
| '_ \| '_ \ / _` | '__/ _` |/ _` \ \ / / _` |
| |_) | | | | (_| | | | (_| | (_| |\ V / (_| |
|_.__/|_| |_|\__,_|_| \__, |\__,_| \_/ \__, |
|___/ |___/
Just a dummy text file to have a proper titles for gists 😒
View Supporting KeyPaths in JSON Parsing
_ _
| |__ | |__ __ _ _ __ __ _ __ ___ ____ _
| '_ \| '_ \ / _` | '__/ _` |/ _` \ \ / / _` |
| |_) | | | | (_| | | | (_| | (_| |\ V / (_| |
|_.__/|_| |_|\__,_|_| \__, |\__,_| \_/ \__, |
|___/ |___/
Just a dummy text file to have a proper titles for gists 😒
View Handling Optionals In JSON
_ _
| |__ | |__ __ _ _ __ __ _ __ ___ ____ _
| '_ \| '_ \ / _` | '__/ _` |/ _` \ \ / / _` |
| |_) | | | | (_| | | | (_| | (_| |\ V / (_| |
|_.__/|_| |_|\__,_|_| \__, |\__,_| \_/ \__, |
|___/ |___/
Just a dummy text file to have a proper titles for gists 😒
View Array_of_customers.json
[
{
"name": {
"first_name": "Lex",
"last_name": "Luthor"
},
"age": 28,
"gender": "male",
"address": {
"street": "244 Clifton Place",
View Curries.swift
func makePerson(name: String) -> (age: Int) -> (status: MaritalStatus) -> (requestIDs: [Int]) -> (address: Address) -> Person {
return { age in { status in { requestIDs in { address in
Person(name: name, age: age, status: status, requestIDs: requestIDs, address: address)
}}}}
}
func makeAddress(flatNo: String) -> (buildingName: String) -> Address {
return { buildingName in
Address(flatNo: flatNo, buildingName: buildingName)
}
View test-spm
#!/bin/bash
#
# _ _
# | |__ | |__ __ _ _ __ __ _ __ ___ ____ _
# | '_ \| '_ \ / _` | '__/ _` |/ _` \ \ / / _` |
# | |_) | | | | (_| | | | (_| | (_| |\ V / (_| |
# |_.__/|_| |_|\__,_|_| \__, |\__,_| \_/ \__, |
# |___/ |___/
#
# title : script.sh
You can’t perform that action at this time.