Skip to content

Instantly share code, notes, and snippets.

View MrChebik's full-sized avatar

Oleksandr Beschasnyi MrChebik

View GitHub Profile
@MrChebik
MrChebik / gist:69b1bf4b47bf5e2560bbef2eb6c2bee3
Created March 12, 2017 12:06
jpa configuration through Java
@Configuration
@EnableJpaRepositories(value = "ru.mrchebik.repository", entityManagerFactoryRef = "entityManagerFactoryBean", transactionManagerRef = "transactionManager")
@EnableTransactionManagement
public class PersistenceJPAConfig {
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
Properties properties = new Properties();
properties.put("hibernate.hbm2ddl.auto", "update");
properties.put("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
properties.put("hibernate.connection.charSet", "UTF-8");
#!/bin/bash
MUSER="$1"
MPASS="$2"
MDB="$3"
# Detect paths
MYSQL=$(which mysql)
AWK=$(which awk)
GREP=$(which grep)
RECOMMEND TO SAVE ALSO ALL NATIVE FILES FROM DATABASE
-- backup
mysqldump -u USER -pPASSWORD DATABASE > /path/to/file/dump.sql
-- structure database
mysqldump --no-data - u USER -pPASSWORD DATABASE > /path/to/file/schema.sql
-- dump of one or else tables
mysqldump -u USER -pPASSWORD DATABASE TABLE1 TABLE2 TABLE3 > /path/to/file/dump_table.sql
-- backup and archive
mysqldump -u USER -pPASSWORD DATABASE | gzip > /path/to/outputfile.sql.gz
scp -r root@192.168.0.2:/home2/ /home/
scp root@192.168.0.1:/home/file1.zip root@192.168.0.2:/home2/
-r -- recursive
-P port -- non-standart port (22)
@MrChebik
MrChebik / optipng
Last active September 24, 2017 17:11
--Install
CentOS6:
$ yum install wget
$ wget dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
$ rpm -ivh epel-release-6-8.noarch.rpm
$ yum install optipng
Mageia:
through install manager
@MrChebik
MrChebik / mozjpeg
Last active September 24, 2017 17:12
--Install
CentOS6:
$ yum install wget autoconf automake gcc nasm git
$ wget https://github.com/mozilla/mozjpeg/releases/download/v3.1/mozjpeg-3.2-release-source.tar.gz
$ tar xvfz mozjpeg-3.2-release-source.tar.gz
$ cd mozjpeg
$ ./configure
$ make
$ make install
@MrChebik
MrChebik / pngquant
Last active September 24, 2017 17:13
--Install
Mageia:
Download libpng(16) (sourceforge, read INSTALL)
$ git clone --recursive https://github.com/pornel/pngquant.git
$ make
$ make install
--In action
$ pngquant --speed 1 /path/to/image.png
sh /path/to/script.sh > log.txt 2>&1 &
public class Main {
private static final int NUMBER_OF_CORES = Runtime.getRuntime().availableProcessors();
public static void main(String[] args) {
Stream.of("WELL, PRINCE, so Genoa and Lucca are now " +
"just family estates of the Buonapartes. But I " +
"warn you, if you don't tell me that this means " +
"war, if you still try to defend the infamies and " +
"horrors perpetrated by that Antichrist I real- " +
"ly believe he is Antichrist I will have nothing " +
public static void main(String[] args) {
final int[] pinger = {0};
System.out.println("WELL, PRINCE, so Genoa and Lucca are now just family estates of the Buonapartes. But I warn you, if you don't tell me that this means war, if you still try to defend the infamies and horrors perpetrated by that Antichrist I really believe he is Antichrist I will have nothing more to do with you and you are no longer my friend, no longer my 'faithful slave', as you call yourself! But how do you do? I see I have frightened you sit down and tell me all the news."
.trim().chars().mapToObj(i -> (char) i).collect(Collector.of(
(Supplier<List<String>>) ArrayList::new,
(array, ch) -> {
if (array.size() == 0) {
array.add("");
}