Skip to content

Instantly share code, notes, and snippets.

View saniaky's full-sized avatar
👋

Alexander saniaky

👋
  • Web
  • Online
View GitHub Profile
@saniaky
saniaky / example.java
Created August 29, 2015 19:42
Java reflection api
public void getObject(Object obj) {
try {
for (Field field : obj.getClass().getDeclaredFields()) {
//field.setAccessible(true); // if you want to modify private fields
System.out.println(field.getName()
+ " - " + field.getType()
+ " - " + field.get(obj));
}
} catch (IllegalAccessException e) {
e.printStackTrace();
@saniaky
saniaky / gist:7fe9c245209403b2ab567e437b9882aa
Created May 4, 2017 13:34
Check remote server SSL certificate
true | openssl s_client -connect site.com:443 -servername site.com | openssl x509 -noout -text | grep DNS:
@saniaky
saniaky / gist:7acfeb88746e4d6acc7624d3c5f50886
Last active November 28, 2017 14:01
Create MySQL database in utf8
=======> Create database
CREATE DATABASE db_name CHARACTER SET utf8 COLLATE utf8_general_ci;
@saniaky
saniaky / TokenController.java
Last active February 3, 2021 15:53
How to logout (revoke token + refresh token) user in Spring Security using OAuth 2.0
@Controller
public class TokenController {
private final TokenStore tokenStore;
@Autowired
public TokenController(TokenStore tokenStore) {
this.tokenStore = tokenStore;
}
@saniaky
saniaky / Messages.java
Created December 5, 2017 11:10
Example of using message resources in Spring Boot service layer code, in as simple way.
import org.springframework.context.MessageSource;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.stereotype.Component;
import java.util.Locale;
/**
* @author saniaky
* @since 12/5/17
*/
@saniaky
saniaky / package.json
Last active February 16, 2021 10:52
Reverse proxy server for API + create-react-app (CRA)
{
"name": "test",
"version": "0.1.0",
"private": true,
"scripts": {
"app": "concurrently \"node proxy-middleware.js\" \"npm start\"",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
@saniaky
saniaky / instructions.txt
Last active December 1, 2018 18:02
Initial Server Setup CentOS + Docker
# ============ Create separate user ============
https://www.digitalocean.com/community/tutorials/initial-server-setup-with-centos-7
https://www.digitalocean.com/community/tutorials/how-to-create-a-sudo-user-on-centos-quickstart
local$ ssh root@server_ip_address
# adduser username
# passwd username
# usermod -aG wheel username
# ============ Copy your SSH key to server ============
@saniaky
saniaky / custom_proxy_settings.conf
Last active August 15, 2023 09:05
Docker + Wordpress + Nginx Proxy + Let's encrypt + Watcher
client_max_body_size 64m;
@saniaky
saniaky / aws-s3-policy.json
Last active January 14, 2022 01:06
Backup and restore a ALL MySQL databases from a running Docker MySQL container.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowPolicy",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:ListBucket"
@saniaky
saniaky / README.md
Last active April 9, 2019 07:05
Automatic backup of all MySQL databases to AWS S3 + restore script that downloads latest backup and imports it
  1. Create S3 bucket db-backup
  2. Specify Expire Policty to remove old backups
    Open Bucket Settings -> Management -> Add lifecycle rule -> Expiration tab
    Select Expire current version of object. Use 30 days.
    Select Permanently delete previous versions. Use 1 day.
  3. Create user db-backup-user, assign inline permission policy:
    {
        "Version": "2012-10-17",
    

"Statement": [