Skip to content

Instantly share code, notes, and snippets.

View dereknguyen269's full-sized avatar
👋
I may be slow to respond.

dereknguyen269

👋
I may be slow to respond.
View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>{{$heading_title}}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="{{ secure_asset($site_favicon)}}" sizes="16x16">
account = Account.find_by_user_id(5)
if account.balance >= item.price
account.balance = account.balance - item.price
#some other long processes here
account.save
end
#account.balance = 100
account = Account.find_by_user_id(5)
#item.price is 50
if account.balance >= item.price
#it's good, allow user to buy this item
account.balance = account.balance - item.price
#account.balance is now 50
account = Account.find_by_user_id(5)
#account.balance is still 100
#item.price is 80
if account.balance >= item.price
#it's good, allow user to buy this item
account.balance = account.balance - item.price
#account.balance is now 20
p1 = Person.find(1)
p2 = Person.find(1)
p1.first_name = "Michael"
p1.save
p2.first_name = "should fail"
p2.save # Raises a ActiveRecord::StaleObjectError
account = Account.find_by_user_id(5)
account.lock!
#no other users can read this account, they have to wait until the lock is released
account.save!
#lock is released, other users can read this account
@dereknguyen269
dereknguyen269 / gist:1e6f7d33df721fb35a602952d6b4fb40
Created November 9, 2016 12:50
.github/PULL_REQUEST_TEMPLATE.md
Provide an explanation of **what** these changes are, and provide a
context that helps understand **why** they are made.
---
**Before submitting, check that:**
- [ ] You have added (passing) tests for your code.
- [ ] You have written good* commit messages.
- [ ] You have squashed relevant commits together.
@dereknguyen269
dereknguyen269 / readme.md
Created January 4, 2017 13:01 — forked from coolaj86/how-to-publish-to-npm.md
How to publish packages to NPM

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "you@example.com"
npm set init.author.url "http://yourblog.com"

npm adduser

– Theme Boxy: thay áo cho Sublime Text.
– SublimeCodeIntel: gợi ý code thông minh.
– Emmet: package nổi tiếng và có trên hầu hết các editor và ide hiện tại, giúp viết HTML một cách nhanh chóng, bạn có thể tìm hiểu thêm về cách sử dụng và cheatsheet của nó.
– MarkdownEditing: viết lách với Markdown
– AdvancedNewFile: tạo nhanh file và thư mục
– SideBarEnhancements: nâng cấp tính năng cho Sidebar.