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

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 / 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);
@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 / 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 / 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 / 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 / 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 / lib.rs
Last active September 6, 2020 11:03
Actix User Middleware with lifetime
use actix_http::Error;
use actix_service::ServiceFactory;
use actix_web::{dev, web, App};
use sqlx::{AnyPool};
pub fn create_app(
data: &Data,
) -> App<
impl ServiceFactory<
[package]
xxxx
[dependencies]
actix = "0.10.0-alpha.3"
actix-cors = "0.3.0-alpha.1"
actix-http = "2.0.0-beta.3"
actix-rt = "1"
actix-service = "1.0.6"
actix-web = { version = "3.0.0-beta.3", features = ["rustls"] }
[package]
name = "http"
description = "HTTP server"
version = "0.0.1"
license = "MIT"
authors = ["Singh <[email protected]>"]
edition = "2018"
[[bin]]
name = "http"