Skip to content

Instantly share code, notes, and snippets.

@gokman
gokman / rx subject in angular2
Created July 6, 2017 16:56
rx subject in angular2
1 First define a Rx Subject object
private subjectObject = new Subject();
2 You can publish an event by using next() method
subjectObject.next(item);
3 when Subject object publish an event it can be listened by using subscribe
@gokman
gokman / spring boot mail with freemarker template
Created June 30, 2017 10:18
spring boot mail with freemarker template
1. in build.gradle file add below dependencies:
compile('org.springframework.boot:spring-boot-starter-mail:${springBootVersion}')
compile("org.springframework.boot:spring-boot-starter-freemarker:${springBootVersion}")
2. in application.properties file add freemarker configurations
spring.freemarker.charset=UTF-8
spring.freemarker.content-type=text/html
spring.freemarker.template-loader-path=classpath:/templates/
@gokman
gokman / spring boot debug in docker
Created June 9, 2017 08:13
spring boot debug in docker
# create spring boot container
docker run -d -e "JAVA_OPTS=-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=n"
-p 8081:8081
-p 5005:5005
--name <container name> <image name>
# create debug configuration in intellij
go Run/Debug Configurations
click + button
choose Remote
@gokman
gokman / add native plugin to platform in ionic
Created June 5, 2017 12:45
add native plugin to platform in ionic
# first install plugman
npm install -g plugman
# add native plugin (ex: android plugin) to the ionic project
plugman install --platform <android or ios> --project platforms/<android or ios> --plugin <plugin location (directory or git repo url)>
@gokman
gokman / angularjs - clear form data with model after save&update
Created May 31, 2017 14:09
angularjs - clear form data with model after save&update
userSaveForm.$setPristine();
$scope.userSaveFormData = {};
@gokman
gokman / click enter execute method in angularjs
Created May 30, 2017 19:13
click enter execute method in angularjs
ng-keyup="$event.keyCode == 13 ? search() : null"
@gokman
gokman / spring boot auto deployment with git hooks and docker
Created May 26, 2017 12:41
spring boot auto deployment with git hooks and docker
1. create git bare repository on your server machine (for example a virtual machine rented from digital ocean)
git init --bare
2. go hooks folder in git repo that created above and create post-receive.sh file
3. in post-receive file write below:
#!/usr/bin/env bash
@gokman
gokman / spring boot git hook post-receive
Created May 20, 2017 14:35
spring boot git hook post-receive
#!/usr/bin/env bash
TARGET="/opt/backend"
REPO="/opt/backend.git"
TEMP="/tmp/backend"
# Extracting source to temp directory.
rm -rf $TEMP
mkdir -p $TEMP
git --work-tree=$TEMP --git-dir=$REPO checkout -f
@gokman
gokman / create bare git repository
Created May 20, 2017 10:36
create bare git repository
#create a folder
mkdir {git repo folder}
Ex: mkdir /opt/myrepo
#initialize git repository
git init --bare {git repo name}.git
Ex: git init --bare myrepo.git
#create git remote address
git remote add {remote name} {bare repository address}:{folder}/{git repo name}.git
@gokman
gokman / spring run with different profiles
Created May 16, 2017 15:26
spring run with different profiles
1. In application.properties file put below line at the top
spring.profiles.active=@activeProfiles@
2. By using above code we will determine the active profile. Then put below code to the build.gradle file in order to
find the related properties file of the selected profile.
processResources {
filesMatching('application.properties') {
filter org.apache.tools.ant.filters.ReplaceTokens, tokens: [