Skip to content

Instantly share code, notes, and snippets.

View bhargavg's full-sized avatar

Bhargav Gurlanka bhargavg

View GitHub Profile
@bhargavg
bhargavg / lamp-setup
Created August 10, 2014 09:25
LAMP setup
Change Document Root
====================
cd /etc/apache2/
sudo cp sites-available/000-default.conf sites-available/mysite.conf
sudo vim sites-available/mysite.conf
change DocumentRoot and add the following
<Directory /home/bhargav/Documents/htdocs/>
Options Indexes FollowSymLinks
AllowOverride None
@bhargavg
bhargavg / unix-linux-mac-commands
Last active August 29, 2015 14:05
Unix / Linux / Mac commands
Diff two directories
====================
diff -qur --exclude="bin" --exclude="gen" DIR_1 DIR_2
-OR-
diff --brief \ # -q
--unified \ # -u
--recursive \ # -r
@bhargavg
bhargavg / android-cheat-codes
Created September 18, 2014 07:49
Android cheat codes
Change SMS Message center number
================================
Android 4.4, Dial *#*#4636#*#* (shows testing screen)
@bhargavg
bhargavg / wwdc-videos-download
Last active August 29, 2015 14:09
One liners to download all WWDC 2014 videos
# MAC (wont be able to resume a file if download is stopped in the middle)
curl --silent https://developer.apple.com/videos/wwdc/2014/ | egrep -o 'http://devstreaming.apple.com/videos/wwdc/2014/[^/]*/([0-9]+)/\1_hd_[^.]*.mov' | xargs -n1 curl -O
# Linux (wget supports resuming, freaking awesome)
wget --continue -i $(curl --silent https://developer.apple.com/videos/wwdc/2014/ | egrep -o 'http://devstreaming.apple.com/videos/wwdc/2014/[^/]*/([0-9]+)/\1_hd_[^.]*.mov')
@bhargavg
bhargavg / protocol-associated-types-properties
Created January 16, 2016 14:11
Code fails with error: "protocol 'ViewModel' can only be used as a generic constraint because it has Self or associated type requirements"
import Foundation
protocol ViewModel {
typealias ModelType
var data: ModelType { get }
}
struct ViewContainer {
var viewModels: [ViewModel]
layout-1
├── Package.swift
└── Sources
└── ModuleA
├── Bar.swift
├── Foo.swift
└── Tests
└── ModuleATests.swift
$ swift/utils/build-toolchain local.swift
./utils/build-script: using preset 'buildbot_linux', which expands to ./utils/build-script --assertions --no-swift-stdlib-assertions --llbuild --swiftpm --xctest --build-subdir=buildbot_linux --lldb --release --test --validation-test --foundation -- --swift-enable-ast-verifier=0 --install-swift --install-lldb --install-llbuild --install-swiftpm --install-xctest --install-prefix=/usr '--swift-install-components=compiler;clang-builtin-headers;stdlib;sdk-overlay;license' --build-swift-static-stdlib=1 --build-swift-stdlib-unittest-extra=1 --skip-test-lldb=1 --test-installable-package=1 --install-destdir=/home/bhargavg/workspaces/swift/swift-nightly-install --installable-package=/home/bhargavg/workspaces/swift/swift-LOCAL-2016-03-13-a-osx.tar.gz --install-foundation --reconfigure
Building the standard library for: swift-stdlib-linux-x86_64
Running Swift tests for: check-swift-all-linux-x86_64
cmark: using standard linker
+ cd /home/bhargavg/workspaces/build/buildbot_linux
#!/bin/bash
#
# _ _
# | |__ | |__ __ _ _ __ __ _ __ ___ ____ _
# | '_ \| '_ \ / _` | '__/ _` |/ _` \ \ / / _` |
# | |_) | | | | (_| | | | (_| | (_| |\ V / (_| |
# |_.__/|_| |_|\__,_|_| \__, |\__,_| \_/ \__, |
# |___/ |___/
#
# title : script.sh
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)
}
[
{
"name": {
"first_name": "Lex",
"last_name": "Luthor"
},
"age": 28,
"gender": "male",
"address": {
"street": "244 Clifton Place",