Skip to content

Instantly share code, notes, and snippets.

@thanhluu
thanhluu / my.cnf
Created February 15, 2016 14:29
Best MySQL Configuration (/etc/my.cnf) for 2GB RAM VPS
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used (fedora >= 15).
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mysqld according to the
@thanhluu
thanhluu / Swift Variables and Constants.swift
Last active April 29, 2016 14:11
Swift Variables and Constants
let favoriteProgramingLanguage = "Swift"
let year = 2014 // Int
var version = 2.0 // Double
var isAwesome = true // Bool
var someString = ""
@thanhluu
thanhluu / Swift Function.swift
Created April 29, 2016 14:11
Swift Function
// Swift Functions
func calculateArea(length: Int, width: Int) -> Int {
let area = length * width
return area
}
// Room 1
let areaOfRoom1 = calculateArea(10, width: 8)
@thanhluu
thanhluu / Swift Struct & Class.swift
Created April 29, 2016 14:13
Swift Struct & Class
let x1 = 0
let y1 = 0
let coordinate1: (x: Int, y: Int) = (0,0)
coordinate1.x
struct Point {
let x: Int
let y: Int
@thanhluu
thanhluu / Bai Tap Class.swift
Created April 29, 2016 14:13
Bai Tap Class
class Point {
var x: Int
var y: Int
init(x: Int, y: Int){
self.x = x
self.y = y
}
}
@thanhluu
thanhluu / Bai Tap Struct.swift
Created April 29, 2016 14:14
Bai Tap Struct
struct User {
var fullName: String
var email: String
var age: Int
}
var someUser = User(fullName: "Thanh Luu", email: "[email protected]", age: 27)
var anotherUser = someUser
let week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
func weekdayOrWeekend(day: String) -> String {
switch day {
case "Saturday", "Sunday": return "Weekend"
case "Monday", "Tuesday", "Wednesday", "Thursday", "Friday": return "Weekday"
default: return "This isn't a valid day in the Western calendar"
}
}
struct Person {
let firstName: String
let middleName: String?
let lastName: String
func getFullName() -> String {
if middleName == nil {
return firstName + " " + lastName
} else {
return firstName + " " + middleName! + " " + lastName
class Point {
var x: Int
var y: Int
init(x: Int, y: Int){
self.x = x
self.y = y
}
}
class Address {
var streetName: String?
var buildingNumber: String?
var apartmentNumber: String?
}
class Residence {
var address: Address?
}