Skip to content

Instantly share code, notes, and snippets.

View jamesnguyen101's full-sized avatar

Loi Nguyen jamesnguyen101

View GitHub Profile
@jamesnguyen101
jamesnguyen101 / HttpURLConnectionExample.java
Created January 16, 2019 07:28 — forked from hitenpratap/HttpURLConnectionExample.java
Send HTTP POST/GET request using HttpURLConnection in java
package com.hprog99;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
@jamesnguyen101
jamesnguyen101 / Call SOAP_XML
Created January 16, 2019 07:27 — forked from kodiyan/Call SOAP_XML
Call SOAP URL and send the Request XML and Get Response XML back
/* Call SOAP URL and send the Request XML and Get Response XML back */
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
@jamesnguyen101
jamesnguyen101 / schema.sql
Created December 21, 2018 03:22 — forked from fernandomantoan/schema.sql
Schema for PostgreSQL to use with JdbcTokenStore (Spring Security OAuth2)
create table oauth_client_details (
client_id VARCHAR(256) PRIMARY KEY,
resource_ids VARCHAR(256),
client_secret VARCHAR(256),
scope VARCHAR(256),
authorized_grant_types VARCHAR(256),
web_server_redirect_uri VARCHAR(256),
authorities VARCHAR(256),
access_token_validity INTEGER,
refresh_token_validity INTEGER,
@jamesnguyen101
jamesnguyen101 / RequestAndResponseLoggingFilter.java
Created November 27, 2018 16:48 — forked from int128/RequestAndResponseLoggingFilter.java
Spring Web filter for logging request and response
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.util.ContentCachingRequestWrapper;
import org.springframework.web.util.ContentCachingResponseWrapper;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
@jamesnguyen101
jamesnguyen101 / RsaExample.java
Created March 31, 2018 08:47 — forked from nielsutrecht/RsaExample.java
Example of RSA generation, sign, verify, encryption, decryption and keystores in Java
import javax.crypto.Cipher;
import java.io.InputStream;
import java.security.*;
import java.util.Base64;
import static java.nio.charset.StandardCharsets.UTF_8;
public class RsaExample {
public static KeyPair generateKeyPair() throws Exception {
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA");
@jamesnguyen101
jamesnguyen101 / monitor.sh
Created February 25, 2018 16:45 — forked from mheadd/monitor.sh
Simple bash script to check whether MySQL is running.
#!/bin/bash
UP=$(pgrep mysql | wc -l);
if [ "$UP" -ne 1 ];
then
echo "MySQL is down.";
sudo service mysql start
else
echo "All is well.";
fi
@jamesnguyen101
jamesnguyen101 / gist:14b8b48cf338e3f2233e77669c959d38
Created January 31, 2018 17:35 — forked from Ara4Sh/gist:863e4796801f0453460faddb78e0ea62
Nginx Redirect if useragent is android or iphone
# 1
location / {
set $mobile 0;
if ($http_user_agent ~* "iphone|android") {
set $mobile 1;
}
if ($mobile = 1) {
# return or rewrite to somewhere
}
}
@jamesnguyen101
jamesnguyen101 / latest-ffmpeg-centos6.sh
Created January 17, 2018 03:44 — forked from mustafaturan/latest-ffmpeg-centos6.sh
Installs latest ffmpeg on Centos 6
# source: https://trac.ffmpeg.org/wiki/CentosCompilationGuide
yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel
mkdir ~/ffmpeg_sources
cd ~/ffmpeg_sources
curl -O http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
@jamesnguyen101
jamesnguyen101 / Linux Static IP
Created October 31, 2017 16:17 — forked from fernandoaleman/Linux Static IP
How To Configure Static IP On CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@jamesnguyen101
jamesnguyen101 / nginxvarcore.md
Created October 20, 2017 17:41 — forked from esfand/nginxvarcore.md
Nginx Variables

Embedded Variables

The ngx_http_core_module module supports embedded variables with names matching the Apache Server variables. First of all, these are variables representing client request header fields, such as $http_user_agent, $http_cookie, and so on. Also there are other variables:

  • $arg_name
    argument name in the request line