Skip to content

Instantly share code, notes, and snippets.

View Sethathi's full-sized avatar
🏗️

Sethathi Morokole Sethathi

🏗️
View GitHub Profile
@Sethathi
Sethathi / nginx_vhost
Last active March 18, 2016 10:17
Nginx Vhost
server {
listen 80;
server_name localhost;
root /var/www/html/src;
index index.php index.html index.htm;
access_log /var/log/default.access.log;
error_log /var/log/default.error.log;
location / {
@Sethathi
Sethathi / setup.sh
Last active December 16, 2016 23:26
Vagrant shell provision script
#!/bin/bash
echo "Provisioning virtual machine..."
echo "####### Installing Git"
apt-get install git -y > /dev/null
echo "####### Installing Nginx"
apt-get install nginx -y > /dev/null
# Path to your oh-my-zsh installation.
export ZSH=~/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="agnoster"
#ZSH_THEME="bira"
#ZSH_THEME="geoffgarside"
@Sethathi
Sethathi / Fresh macOS Setup.md
Created April 25, 2020 05:42 — forked from ashfurrow/Fresh macOS Setup.md
All the stuff I do on a fresh macOS Installation

Apps to install from macOS App Store:

  • Pastebot
  • GIF Brewery
  • Slack
  • Keynote/Pages/Numbers
  • 1Password
  • OmniFocus 2
  • Airmail 3
  • iA Writer
// How can this conditional be simplified?
let price = 5
if price >= 1 && price <= 5 {
print("Price within range")
}
// What's the output of this code?
extension Int {
func times(callback: (_ n: Int) -> ()) {
for n in 0...self {
callback(n)
}
}
}
2.times { (n) in
// What will be displayed by this code?
blueSquare.backgroundColor = UIColor.blue
redSquare.backgroundColor = UIColor.red
let constraints = [
redSquare.topAnchor.constraint(equalTo: blueSquare.topAnchor),
blueSquare.leftAnchor.constraint(equalTo: redSquare.leftAnchor, constant: -40),
blueSquare.bottomAnchor.constraint(equalTo: redSquare.bottomAnchor),
redSquare.rightAnchor.constraint(equalTo: blueSquare.rightAnchor, constant: -40)
]
// Why won't this compile?
var name: String?
if name != nil {
displayName(name: name)
}
func displayName(name: String) {
// display name
}
// Can you spot any issues with code?
class MyBroadcastReceiverActivity : AppCompatActivity() {
private var broadcastReceiver: BroadcastReceiver? = null
override fun onCreate(@Nullable savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_one)
}
private fun registerBroadCastReceiver() {
broadcastReceiver = object : BroadcastReceiver() {
// `BookingsActivity` is rotatable and currently loads bookings from API on each rotation. How can we prevent this from happening?
class BookingViewModel(
private val repository: BookingsRepository
) : ViewModel() {
// We want to make sure that this is only settable privately.
val bookings = MutableLiveData<List<Booking>>()
fun loadBookings() {
val bookings = repository.getBookings()