How to automate Cygwin library installation

Write a cmd file as follows and put it in the same folder as cygwin installation file: setup-x86_64.exe:

setup-x86_64.exe ^
–no-shortcuts ^
–quiet-mode ^
–disable-buggy-antivirus ^
–packages ^
<lib1>,^
<lib2>,^

Advertisements

How to install VirtualBox GuestAddition on a guiless CentOs

https://www.if-not-true-then-false.com/2010/install-virtualbox-guest-additions-on-fedora-centos-red-hat-rhel/

  1. sudo yum update kernel* -y
  2. mkdir /media/cdrom
  3. mount -r /dev/cdrom /media/cdrom
  4. sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
  5. sudo yum install gcc kernel-devel kernel-headers dkms make bzip2 perl -y
  6. KERN_DIR=/usr/src/kernels/uname -r
  7. export KERN_DIR
  8. cd /media/cdrom
  9. ./VBoxLinuxAdditions.run
  10. reboot

How to completely remove docker on windows 10

From: https://success.docker.com/KBase/How_to_completely_remove_Docker

 

Save the following script in a file with extension of ps1.  Log in powershell console as admin and run the script file.

$ErrorActionPreference = “SilentlyContinue”

kill -force -processname ‘Docker for Windows’, com.docker.db, vpnkit, com.docker.proxy, com.docker.9pdb, moby-diag-dl, dockerd

try {
./MobyLinux.ps1 -Destroy
} Catch {}

$service = Get-WmiObject -Class Win32_Service -Filter “Name=’com.docker.service'”
if ($service) { $service.StopService() }
if ($service) { $service.Delete() }
Start-Sleep -s 5
Remove-Item -Recurse -Force “~/AppData/Local/Docker”
Remove-Item -Recurse -Force “~/AppData/Roaming/Docker”
if (Test-Path “C:\ProgramData\Docker”) { takeown.exe /F “C:\ProgramData\Docker” /R /A /D Y }
if (Test-Path “C:\ProgramData\Docker”) { icacls “C:\ProgramData\Docker\” /T /C /grant Administrators:F }
Remove-Item -Recurse -Force “C:\ProgramData\Docker”
Remove-Item -Recurse -Force “C:\Program Files\Docker”
Remove-Item -Recurse -Force “C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Docker”
Remove-Item -Force “C:\Users\Public\Desktop\Docker for Windows.lnk”
Get-ChildItem HKLM:\software\microsoft\windows\currentversion\uninstall | % {Get-ItemProperty $_.PSPath} | ? { $_.DisplayName -eq “Docker” } | Remove-Item -Recurse -Force
Get-ChildItem HKLM:\software\classes\installer\products | % {Get-ItemProperty $_.pspath} | ? { $_.ProductName -eq “Docker” } | Remove-Item -Recurse -Force
Get-Item ‘HKLM:\software\Docker Inc.’ | Remove-Item -Recurse -Force
Get-ItemProperty HKCU:\software\microsoft\windows\currentversion\Run -name “Docker for Windows” | Remove-Item -Recurse -Force
#Get-ItemProperty HKCU:\software\microsoft\windows\currentversion\UFH\SHC | ForEach-Object {Get-ItemProperty $_.PSPath} | Where-Object { $_.ToString().Contains(“Docker for Windows.exe”) } | Remove-Item -Recurse -Force $_.PSPath
#Get-ItemProperty HKCU:\software\microsoft\windows\currentversion\UFH\SHC | Where-Object { $(Get-ItemPropertyValue $_) -Contains “Docker” }

How to fix error “Font family [‘sans-serif’] not found” when using seaborn in jupyter running in a vagrant centos vm

yum install curl cabextract xorg-x11-font-utils fontconfig
yum install https://downloads.sourceforge.net/project/mscorefonts2/rpms/msttcore-fonts-installer-2.6-1.noarch.rpm

Note: if yum cannot install directly, you can download the rpm file from: https://downloads.sourceforge.net/project/mscorefonts2/rpms/msttcore-fonts-installer-2.6-1.noarch.rpm and install it locally.

How to add multiple database support to Spring application

Define multiple configuration files. In each configuration file, specify the JpaVendorAdapter, datasource, enityManager, entityManagerFactory, and transactionManager. You can set a default configuration file and multiple other configuration files.

A sample goes as below:

Default configuration file:

@Configuration
@EnableTransactionManagement
@EnableAutoConfiguration
@EnableJpaRepositories(
        entityManagerFactoryRef = "entityManagerFactory",
        transactionManagerRef = "transactionManager",
        basePackages = {"bmo.hub.bpm.foundation.appmonitor.db.repo"}
)
public class AppConfig {

    @Autowired
    private JpaVendorAdapter jpaVendorAdapter;

    @Autowired
    private DataSource dataSource;

    @Bean(name = "entityManager")
    public EntityManager entityManager() {
        return entityManagerFactory().createEntityManager();
    }

    @Primary
    @Bean(name = "entityManagerFactory")
    public EntityManagerFactory entityManagerFactory() {
        LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
        emf.setDataSource(dataSource);
        emf.setJpaVendorAdapter(jpaVendorAdapter);
        emf.setPackagesToScan("bmo.hub.bpm.foundation.appmonitor.db.entity");
        emf.setPersistenceUnitName("default");
        emf.afterPropertiesSet();

        return emf.getObject();
    }

    @Bean(name = "transactionManager")
    public PlatformTransactionManager transactionManager() {
        JpaTransactionManager tm = new JpaTransactionManager();
        tm.setEntityManagerFactory(entityManagerFactory());

        return tm;
    }
}

Another configuration file:

@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
        entityManagerFactoryRef = "mortgageEntityManagerFactory",
        transactionManagerRef = "mortgageTransactionManager",
        basePackages = {"bmo.hub.bpm.foundation.appmonitor.db.repo.mortgage"}
)
public class MortgageConfig {

    @Autowired
    private JpaVendorAdapter jpaVendorAdapter;

//    @Autowired
//    private DataSource dataSource;
    @Value("${spring.datasource.mortgage.url}")
    private String databaseUrl;

    @Value("${spring.datasource.mortgage.username}")
    private String username;

    @Value("${spring.datasource.mortgage.password}")
    private String password;

    @Value("${spring.datasource.mortgage.driver-class}")
    private String driverClass;

    @Bean(name = "mortgageEntityManager")
    public EntityManager entityManager() {
        return entityManagerFactory().createEntityManager();
    }

    public DataSource dataSource() {
        DriverManagerDataSource dataSource = new DriverManagerDataSource(databaseUrl, username, password);
        dataSource.setDriverClassName(driverClass);
        return dataSource;
    }

    @Primary
    @Bean(name = "mortgageEntityManagerFactory")
    public EntityManagerFactory entityManagerFactory() {
        LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
        emf.setDataSource(dataSource());
        emf.setJpaVendorAdapter(jpaVendorAdapter);
        emf.setPackagesToScan("bmo.hub.bpm.foundation.appmonitor.db.entity.mortgage");
        emf.afterPropertiesSet();

        return emf.getObject();
    }

    @Bean(name = "mortgageTransactionManager")
    public PlatformTransactionManager transactionManager() {
        JpaTransactionManager tm = new JpaTransactionManager();
        tm.setEntityManagerFactory(entityManagerFactory());

        return tm;
    }
}

And the properties file (application.yml):

selenium:
  grid:
    url: http://localhost:4444/wd/hub

scheduling:
  job:
    cron: 0 0/3 * * * *

spring:
  datasource:
    url: jdbc:oracle:thin:@10.193.61.167:1521:garnish
    username: row_dev
    password: Welcome#1
    driver-class: oracle.jdbc.driver.OracleDriver

    mortgage:
      url: jdbc:oracle:thin:@10.193.46.193:1521:mortgage
      username: mortgage
      password: MORTGAGE
      driver-class: oracle.jdbc.driver.OracleDriver

    hikari:
      connection-timeout: 60000
      maximum-pool-size: 5

 

Coding Practice & Competion Websites

  1. topcoder
    http://www.topcoder.com
    (a great blog: http://petr-mitrichev.blogspot.com/)
  2. hackerrank
    hackerrank.com
  3. leetcode
    leetcode.com
  4. coderbyte
    coderbyte.com
  5. geeksforgeeks
    geeksforgeeks.org
  6. codeforces
    codeforces.com
  7. codewars
    codewars.com
  8. codeeval
    http://www.codeeval.com
  9. spoj
    spoj.com
  10. devdraft
    devdraft.com
  11. codechef
    http://www.codechef.com
  12. projecteuler
    projecteuler.net
  13. hackerearth
    hackerearth.com
  14. checkio
    py.checkio.org
  15. codinggame
    codinggame.com
  16. theaigames
    theaigames.com
  17. programmr
    http://www.programmr.com

 

 

 

Intellij error: usage of api documented as @since…, Usage of API documented as @since 1.6+..

To get rid of the first one, you need to open up

File -> Project Structure -> Project Settings -> Modules -> "Your Module Name" -> Sources -> Language Level

and change that to the desired level i.e 1.8 or the Project Default language level

To fix the second one:

  1. File > Settings > Build, Execution, Deployment > Java Compiler
  2. Change Target bytecode version to 1.8 of the module that you are working for.