Skip to content

Instantly share code, notes, and snippets.

@bekce
bekce / swagger-client.sh
Last active August 29, 2015 14:27
Generate swagger client
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i http://192.168.1.166:8080/v2/api-docs -l android -o out/project
@bekce
bekce / gitlab-cookbook.md
Last active September 16, 2015 19:56
Gitlab basic cookbook

Use gitlab with a docker container. This guide is vastly learned from this reference document: https://gitlab.com/gitlab-org/gitlab-ce/tree/master/docker

However there are some more ideas and gotchas, so I decided to write this gist.

Start by creating & running our container. Replace ports (host:container) as desired.

sudo docker run --detach \
    --publish 8443:443 --publish 8080:80 --publish 2222:22 \
@bekce
bekce / JPA.md
Last active October 17, 2015 16:20
JPA concise examples

JPA concise examples

One to one

class Customer
  @OneToOne(fetch=FetchType.LAZY)
  @JoinColumn(name="address_fk",nullable=false)
  Address address;
@bekce
bekce / SSLTest.java
Last active April 4, 2016 13:27
Test SSL connection to specified host and port. Sends given first message and prints the results. I've used it to test my SSL certificate on my SMTP server.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
public class SSLTest {
@bekce
bekce / automated-building-deployment-docker-microservices
Last active April 21, 2016 15:03
Automated Building and Deployment of Docker Microservices
[http://sebworks.com](http://sebworks.com)
@bekce
bekce / gist:9551f3f9c95ea4614c562ea34f9f5bbb
Last active June 8, 2016 13:46
Get new AccuWeather apiKey. This bash script retrieves the latest temporary apiKey for https://apidev.accuweather.com for your testing purposes.
wget -q -O - https://apidev.accuweather.com/developers/samples | grep "var apiKey" | cut -d'"' -f 2
@bekce
bekce / upgrade_mongodb.sh
Last active February 22, 2017 13:14
Upgrade MongoDB from 2.x to 3.4.x directly
sudo -s # shell out to root
cd
mongodump --out dump
service mongodb stop
# check if stopped and kill process if not
ps faux|grep mongod # then kill softly
ps faux|grep mongod|awk '{print $2}'|head -n 1|xargs kill
rm /var/lib/mongodb/mongod.lock
# backup data folder and configurations for extra protection
tar -cvzf data.tgz /var/lib/mongodb
@bekce
bekce / install_ruby.sh
Created July 29, 2016 07:54
Install Ruby 2.x with rbenv
# Install ruby on a clean ubuntu 14.04 machine (tested)
cd
apt-get install -y curl git gcc make libssl-dev libreadline-dev zlib1g-dev
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
. ~/.bashrc
CONFIGURE_OPTS="--disable-install-rdoc" rbenv install 2.3.1
rbenv local 2.3.1
#!/bin/sh
if [ $# -ne 4 ]
then
echo "Usage: <new-db-name> <new-user> <new-pass> <root-pass>"
exit 1
fi
dbname=$1
newuser=$2
newpass=$3
rootpass=$4
@bekce
bekce / ntfs_fix.md
Last active October 22, 2021 10:32
NTFS filename fix

If you happen to write to NTFS partitions using non-windows operating systems (such as with ntfs-3g, see this thread for more info), some of your files may have got written containing invalid characters in their names. When such a thing happen, the fix of chkdsk is just to delete them but clearly no one would ever want to have their files deleted to 'fix'!

This little script that I wrote aims to fix the invalid NTFS characters in batch and automatically by renaming the files with invalid characters to valid ones. It only fixes the characters in this set: <>:"\|?* which is pretty enough for most of the problems, but for advanced cases (like reserved names 'com', 'lpt') you must fix manually. Always double check the batch mv commands before running.

Fallacies:

  • Does not fix reserved names in Windows (like CON, PRN, AUX, NUL, COM1, COM2, etc).
  • Does not fix other illegal combination of characters like 'directory name cannot end with