Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Tung Nguyen V. N. ntung

🏠
Working from home
Block or report user

Report or block ntung

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ntung
ntung / UserController.groovy
Created Jul 2, 2019 — forked from roalcantara/UserController.groovy
Grails + Spock: Testing Rendering views
View UserController.groovy
class UserController {
def index(final String username) {
flash.errors = "ops!"
render view: "index", model: [username:username, text:username]
}
}
View Country Dropdown List
<select>
<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">American Samoa</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
<option value="Anguilla">Anguilla</option>
<option value="Antartica">Antarctica</option>
<option value="Antigua and Barbuda">Antigua and Barbuda</option>
@ntung
ntung / Redis.sh
Created Mar 9, 2019 — forked from nrollr/Redis.sh
Install Redis via Homebrew
View Redis.sh
#!/bin/bash
brew install redis # Install Redis using Homebrew
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents # Enable Redis autostart
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist # Start Redis server via launchctl
# homebrew.mxcl.redis.plist contains reference to redis.conf file location: /usr/local/etc/redis.conf
redis-server /usr/local/etc/redis.conf # Start Redis server using configuration file, Ctrl+C to stop
redis-cli ping # Check if the Redis server is running
@ntung
ntung / squash-commits.sh
Created Jan 17, 2019 — forked from jbub/squash-commits.sh
git squash last two commits into one
View squash-commits.sh
git rebase --interactive HEAD~2
# we are going to squash c into b
pick b76d157 b
pick a931ac7 c
# squash c into b
pick b76d157 b
s a931ac7 c
@ntung
ntung / ErrorController.groovy
Created Nov 27, 2018 — forked from aeischeid/ErrorController.groovy
Alternate grails controller template and url mapping for adding a scaffolded JSON API
View ErrorController.groovy
package gvl
import grails.converters.JSON
class ErrorController {
// Forbidden
def error403() {
withFormat {
html { render(view: 'error403') }
View git-tag-delete-local-and-remote.sh
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@ntung
ntung / .gitconfig
Created Sep 3, 2018 — forked from pksunkara/.gitconfig
Sample of git config file (Example .gitconfig)
View .gitconfig
[user]
name = Pavan Kumar Sunkara
email = pavan.sss1991@gmail.com
username = pksunkara
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[sendemail]
smtpencryption = tls
@ntung
ntung / Javascript Variable Scoping.md
Created Jun 4, 2018 — forked from hartleybrody/Javascript Variable Scoping.md
Variable scoping in Javascript can be confusing so I set out to make notes of the basic rules so that I can reference them later. Hope these are useful to others, happy to talk pull requests for corrections.
View Javascript Variable Scoping.md

Javascript has two kinds of scope:

  1. Local (inside a function)
  2. Global (outside a function)

The var Keyword

  • Using the var keywords creates the variable in the current scope
    • If the current scope is global, then var is unnecessary (see below)
    • If the current scope is local, then you’re creating a local variable in the current scope
  • If you don’t use var, then Javascript goes up the “scope chain” to see if it’s already been declared
@ntung
ntung / maven-deploy-sources.sh
Created Apr 9, 2018 — forked from Ladicek/maven-deploy-sources.sh
deploy *-sources.jar to internal Maven repository
View maven-deploy-sources.sh
#!/bin/bash
# successful "mvn clean install" or a variant thereof (e.g. -DskipTests)
# is typically required before running this script
REPOSITORY_ID=...
REPOSITORY_URL=...
mvn clean source:jar
@ntung
ntung / gist:635d3baf897baefb1dd124d01028697e
Created Mar 6, 2018 — forked from digitaljhelms/gist:3099010
Squash the first two commits in a git repository's history
View gist:635d3baf897baefb1dd124d01028697e

The scenario

Your repository has two commits:

$ git log --oneline
957fbfb No, I am your father.
9bb71ff A long time ago in a galaxy far, far away....
You can’t perform that action at this time.