Skip to content

Instantly share code, notes, and snippets.

@thanhhh
thanhhh / StringUtil.cs
Created December 19, 2015 07:48
Clear Vietnamese Sign C#
public class StringUtil
{
private static readonly string[] VietnameseSigns = new string[]
{
"aAeEoOuUiIdDyY",
"áàạảãâấầậẩẫăắằặẳẵ",
"ÁÀẠẢÃÂẤẦẬẨẪĂẮẰẶẲẴ",
"éèẹẻẽêếềệểễ",
"ÉÈẸẺẼÊẾỀỆỂỄ",
"óòọỏõôốồộổỗơớờợởỡ",
@thanhhh
thanhhh / Redmine installation
Last active March 11, 2024 12:23
How to configuration Redmine with puma and running on nginx (based on Gitlab's installation)
Add config/puma.ruby
--------------------
cd /home/redmine/redmine
sudo -u redmine -H curl --output config/puma.rb https://gist.github.com/thanhhh/5610668/raw/fdfe2a865c3a0afe912c8784c971ea7ca3e64cfd/puma.rb
Install Init Script
--------------------
Download the init script (will be /etc/init.d/redmine):
@thanhhh
thanhhh / puma.rb
Created May 20, 2013 06:13
Create file puma.rb on /home/redmine/redmine/config/puma.rb
#!/usr/bin/env puma
# Start Puma with next command:
# RAILS_ENV=production bundle exec puma -C ./config/puma.rb
# uncomment and customize to run in non-root path
# ENV['RAILS_RELATIVE_URL_ROOT'] = "/redmine"
application_path = '/home/redmine/redmine'
@thanhhh
thanhhh / SSLPoke.java
Created October 11, 2021 15:37 — forked from 4ndrej/SSLPoke.java
Test of java SSL / keystore / cert setup. Check the comment #1 for howto.
import javax.net.ssl.SSLParameters;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import java.io.*;
/** Establish a SSL connection to a host and port, writes a byte and
* prints the response. See
* http://confluence.atlassian.com/display/JIRA/Connecting+to+SSL+services
*/
public class SSLPoke {
@thanhhh
thanhhh / 2019-https-localhost.md
Created September 26, 2021 03:51 — forked from cecilemuller/2019-https-localhost.md
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@thanhhh
thanhhh / auto_post.php
Created November 17, 2015 08:27
Auto post to Facebook page
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Facebook\Authentication\AccessToken;
use Facebook\FacebookApp;
use Facebook\FacebookRequest;
session_start();
$app_id = '{APP ID}';
@thanhhh
thanhhh / SimpleRecyclerView.java
Created March 15, 2019 10:29 — forked from saber-solooki/SimpleRecyclerView.java
Sticky Header RecyclerView
package com.saber.customstickyheader;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
@thanhhh
thanhhh / gist:dc3e35bfa5cf90bd9c5ad311632c0c52
Created December 23, 2018 08:28 — forked from samkirton/gist:0242ba81d7ca00b475b9
Fixed a bug where images added to the MediaStore are not inserted at the front of the gallery
package com.memtrip;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.graphics.Bitmap;
@thanhhh
thanhhh / localstack.md
Created October 11, 2018 06:43 — forked from abdul/localstack.md
Working with localstack on command line

Starting localstack

C02STG51GTFM:localstack mpandit$ make infra
. .venv/bin/activate; exec localstack/mock/infra.py
Starting local dev environment. CTRL-C to quit.
Starting local Elasticsearch (port 4571)...
Starting mock ES service (port 4578)...
Starting mock S3 server (port 4572)...
Starting mock SNS server (port 4575)...
@thanhhh
thanhhh / base_instances.go
Created May 19, 2018 11:00
Check dependency injection instances between parent and child
// https://play.golang.org/p/FNyxFKcizua
package main
import (
"fmt"
)
func main() {
s := "Hello"
b := Base{Logger: &s}