Skip to content

Instantly share code, notes, and snippets.

@vienvu89
vienvu89 / 200lab_golang_training_food_delivery.sql
Created May 12, 2021 14:55 — forked from viettranx/200lab_golang_training_food_delivery.sql
This is an example DB schema for Food Delivery training project
DROP TABLE IF EXISTS `carts`;
CREATE TABLE `carts` (
`user_id` int NOT NULL,
`food_id` int NOT NULL,
`quantity` int NOT NULL,
`status` int NOT NULL DEFAULT '1',
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`user_id`,`food_id`),
- (id<CAAction>)actionForLayer:(CALayer *)layer forKey:(NSString *)event {
if (layer == self.shapeLayer && [event isEqualToString:@"strokeEnd"]) {
//Only perform animation action when in a UIView animation block
CAAnimation *opacityAction = (id)[super actionForLayer:layer forKey:@"opacity"];
if (opacityAction && ![opacityAction isKindOfClass:[NSNull class]] && [opacityAction isKindOfClass:[CAAnimation class]]) {
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:event];
animation.fromValue = [layer.presentationLayer valueForKey:event];
animation.duration = opacityAction.duration;
return animation;
} else {
<x
xmlns="jabber:x:data" type="form">
<title>Room configuration</title>
<instructions>The room "5ae8806bcf3508a9e0ed6ecedd160627" has been created. To accept the default configuration, click the "OK" button. Or, modify the settings by completing the following form:</instructions>
<field var="FORM_TYPE" type="hidden">
<value>http://jabber.org/protocol/muc#roomconfig</value>
</field>
<field var="muc#roomconfig_roomname" type="text-single" label="Room Name">
<value>5ae8806bcf3508a9e0ed6ecedd160627</value>
</field>
@vienvu89
vienvu89 / tabbarItem.swift
Last active February 3, 2016 10:18
Set Background for Tabbar Item Active and change color certain item:
// Add background color to middle tabBarItem
let itemIndex = 2
let bgColor = UIColor(red: 0.08, green: 0.726, blue: 0.702, alpha: 1.0)
let itemWidth = tabBar.frame.width / CGFloat(tabBar.items!.count)
let bgView = UIView(frame: CGRectMake(itemWidth * itemIndex, 0, itemWidth, tabBar.frame.height))
bgView.backgroundColor = bgColor
tabBar.insertSubview(bgView, atIndex: 0)
@vienvu89
vienvu89 / tabbarItem.m
Last active February 3, 2016 10:18
Set Background for Tabbar Item Active and change color certain item:
NSInteger numberOfItems = self.tabBar.items.count;
CGSize tabBarItemSize = CGSizeMake(self.tabBar.frame.size.width / numberOfItems, self.tabBar.frame.size.height);
self.tabBar.selectionIndicatorImage = [UIImage imageWithColor:[UIColor colorWithHexString:@"#040A0F" ] size:tabBarItemSize];
NSInteger itemIndex = 2;
CGFloat itemWidth = self.tabBar.frame.size.width / numberOfItems;
@vienvu89
vienvu89 / addContraint.m
Last active January 11, 2016 01:25
Sometimes when add child view controller programmatically and just add subview fill all container. You have to add constraint again and again. This snip set code will help you add by one line of code.
//
// CommonAutolayoutUtils.h
// Vien Vu
//
// Created by Vien Vu on 1/8/16.
// Copyright © 2016 Vien Vu. All rights reserved.
//
#import <Foundation/Foundation.h>
@vienvu89
vienvu89 / AddConstraint.swift
Last active February 1, 2016 10:30
Sometimes when add child view controller programmatically and just add subview fill all container. You have to add constraint again and again. This snip set code will help you add by one line of code.
//Add constraint with top left right bottom is (0, 0, 0, 0)
func addChildToContainer(parent container: UIView, child childView: UIView) {
container.addSubview(childView)
childView.translatesAutoresizingMaskIntoConstraints = false
let views = Dictionary(dictionaryLiteral: ("childView", childView),("container", container))
//Horizontal constraints
let horizontalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("H:|[childView]|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views)
container.addConstraints(horizontalConstraints)