Skip to content

Instantly share code, notes, and snippets.

View rhzs's full-sized avatar
:bowtie:
Simplicity's matters

Ryuici rhzs

:bowtie:
Simplicity's matters
View GitHub Profile
@rhzs
rhzs / laravel-k8s-configmap.yaml
Created August 12, 2020 01:56 — forked from mkhmylife/laravel-k8s-configmap.yaml
Laravel Kubernetes Deployment files
apiVersion: v1
kind: ConfigMap
metadata:
name: backend-config
data:
APP_DEBUG: "false"
APP_ENV: production
APP_KEY: changeme
APP_LOG_LEVEL: debug
APP_NAME: "Laravel K8s"
@rhzs
rhzs / nginx.conf
Created May 19, 2020 13:14 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@rhzs
rhzs / 0_Firecracker_on_GCE.md
Created March 15, 2020 12:50 — forked from apstndb/0_Firecracker_on_GCE.md
Run Firecracker on GCE

https://cloud.google.com/compute/docs/instances/enable-nested-virtualization-vm-instances?hl=en を参考に Compute Engine で nested VM を構築。

gcloud config set compute/zone us-central1-b
gcloud compute disks create disk1 --image-project debian-cloud --image-family debian-9
gcloud compute images create nested-vm-image --source-disk disk1 --licenses "https://www.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx"
gcloud compute instances create example-nested-vm --image nested-vm-image --min-cpu-platform="Intel Skylake"
@rhzs
rhzs / index.js
Created September 9, 2017 08:31
Fastest Validator using Next.Js, this is a demo schema validation faster than Hapi Joi schema.
// !!!!!!!!!!!
// Move this file to inside `pages` directory
// !!!!!!!!!!!
import React from "react";
import Validator from "fastest-validator";
class Index extends React.Component {
render() {
const v = new Validator();
@rhzs
rhzs / geo.js
Created November 17, 2016 20:09 — forked from mkhatib/geo.js
A Javascript utility function to generate number of random Geolocations around a center location and in a defined radius.
/**
* Generates number of random geolocation points given a center and a radius.
* @param {Object} center A JS object with lat and lng attributes.
* @param {number} radius Radius in meters.
* @param {number} count Number of points to generate.
* @return {array} Array of Objects with lat and lng attributes.
*/
function generateRandomPoints(center, radius, count) {
var points = [];
for (var i=0; i<count; i++) {
@rhzs
rhzs / android_open_cv.java
Created October 10, 2015 16:04
Convert image in android to DCT image using OpenCV and JavaCV
// Author: Rheza Satria (c) 2015
// Please mention this gist if you inspired/used it!
public static Bitmap applyDCT(Bitmap image, int blockSize) {
int _w = image.getWidth();
int _h = image.getHeight();
// Preload the opencv_objdetect module to work around a known bug.
Loader.load(opencv_objdetect.class);
AndroidFrameConverter afc = new AndroidFrameConverter();
Frame frame = afc.convert(image);

Installing go 1.5 with homebrew on OSX:

1) Create Directories

mkdir $HOME/go
mkdir -p $HOME/go/src/github.com/YOUR_USERNAME

-p means to create intermediate directories as required.

2) Setup your paths

export GOPATH=$HOME/go

@rhzs
rhzs / index.html
Created August 9, 2015 13:56
Go - Demonstrate simple HTML5 Server Side Events Example without Redis / RabbitMQ / anykind
<!DOCTYPE html>
<html>
<head>
<title>HTML5 Server Side Event Example in Go</title>
</head>
<body>
Yey! {{.}}, here are some new messages about the
current time:<br>
@rhzs
rhzs / terminal_progress_bar.rb
Created August 8, 2015 18:20
Ruby Terminal Progress Bar Example
progress = 'Progress... ['
1000.times do |i|
j = i + 1
# add 1 percent every 10 times
if j % 10 == 0
progress << "="
print "\r"
print progress + " #{j / 10} %]"
@rhzs
rhzs / zalora_jsoup.groovy
Last active August 8, 2018 00:56
Very Simple Example Java/Groovy and Jsoup library -- Crawler for Zalora Indonesia (e-commerce site)
// Download JSOUP library
@Grab('org.jsoup:jsoup:1.7.1')
// Connect and get Zalora URL via Jsoup
def doc = org.jsoup.Jsoup.connect("http://www.zalora.co.id/women/pakaian/dress/").get()
// Since the page loaded using AJAX we can't just crawl the CSS tag.
def script = doc.select("script")
def p = java.util.regex.Pattern.compile(/(?is)app.settings =(.*)app.i18n/);
def m = p.matcher(script.html());