Skip to content

Instantly share code, notes, and snippets.

🏁
Working hard

Đặng Minh Dũng dungdm93

🏁
Working hard
Block or report user

Report or block dungdm93

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
View .bashrc
alias ..='cd ..'
if [[ ! "$PATH" =~ (^|:)"$HOME/.local/bin"(:|$) ]]; then
export PATH="$HOME/.local/bin:$PATH"
fi
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$SDKMAN_DIR/bin/sdkman-init.sh" ]] && source "$SDKMAN_DIR/bin/sdkman-init.sh"
export NVM_DIR="$HOME/.nvm"
@dungdm93
dungdm93 / gitlab.rb
Last active May 14, 2019
Gitlab OAuth2 with Google
View gitlab.rb
### OmniAuth Settings
###! Docs: https://docs.gitlab.com/ce/integration/omniauth.html
gitlab_rails['omniauth_enabled'] = true # Show "Signin with..." button in Login page
gitlab_rails['omniauth_allow_single_sign_on'] = ['google_oauth2'] # Create account automatically
# gitlab_rails['omniauth_sync_email_from_provider'] = 'saml'
gitlab_rails['omniauth_auto_sign_in_with_provider'] = 'google_oauth2' # Redirect to provider login page when enter gitlab login page
# gitlab_rails['omniauth_block_auto_created_users'] = true # true: auto-created user must be admin approved
# gitlab_rails['omniauth_auto_link_ldap_user'] = false
# gitlab_rails['omniauth_auto_link_saml_user'] = false
# gitlab_rails['omniauth_external_providers'] = ['twitter', 'google_oauth2']
View web-fragment.xml
<web-fragment version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd">
</web-fragment>
@dungdm93
dungdm93 / serializable.rb
Created Mar 19, 2016
Serializable Attribute
View serializable.rb
module Serializable
extend ActiveSupport::Concern
module ClassMethods
def dump(obj)
return if obj.nil?
assert_valid_value obj
ActiveSupport::JSON.encode obj
end
@dungdm93
dungdm93 / YAML.rb
Created Mar 16, 2016
serialize using YAML coder
View YAML.rb
###
# define serialize in +ActiveRecord::AttributeMethods::Serialization#serialization+
# => create coder
# which is used in +ActiveRecord::Type::Serialized+
# attr is loaded in +ActiveRecord::Type::Serialized#type_cast_from_database+
# attr is dumped in +ActiveRecord::Type::Serialized#type_cast_for_database+
###
# active_record/coders/yaml.rb
module ActiveRecord::Coders
View RandomString.java
package com.gem.demo.java;
import java.util.NoSuchElementException;
import java.util.Random;
public class RandomString {
public static void main(String[] args) {
long time = System.currentTimeMillis();
generate("hello");
generate("world");
View TimeZone vs. ZondID.java
Arrays.stream(TimeZone.getAvailableIDs()).forEach(id -> {
boolean flag = false;
try {
ZoneId.of(id);
flag = true;
} catch (Exception e) {
//ignore;
}
if (!flag)
System.out.printf("[%s] %s%n", flag ? "x" : " ", id);
@dungdm93
dungdm93 / Model.java
Created Nov 5, 2015
[Java][JPA][Hibernate] UUID & Hibernate
View Model.java
@Entity
public class Employee extends AbstractBaseEntity {
// Approach 1:
// @Id
// public String id;
// Approach 2:
@Id
// default column type is byte array
@Type(type = "org.hibernate.type.PostgresUUIDType") // or type = "pg-uuid"
@dungdm93
dungdm93 / ConstructorReferenceDemo.java
Created Sep 1, 2015
[Java 8] Constructor Reference example
View ConstructorReferenceDemo.java
interface NoArgConstructor<T> {
T foo();
}
interface ArgConstructor<T, U> {
T bar(U arg);
}
interface MultiArgsConstructor<T, U> {
T magic(U... arg);
@dungdm93
dungdm93 / Company.java
Created Aug 31, 2015
[Java][JPA] xml vs. annotation models mapping
View Company.java
package com.gem.demo.database.model;
public class Company {
public int id;
public String name;
public String address;
...
@Override
You can’t perform that action at this time.