Skip to content

Instantly share code, notes, and snippets.

View giautm's full-sized avatar
😍
Nice to meet you ʕ◔ϖ◔ʔ

Giau. Tran Minh giautm

😍
Nice to meet you ʕ◔ϖ◔ʔ
View GitHub Profile
@giautm
giautm / base64.js
Created December 25, 2015 19:56 — forked from whatnickcodes/base64.js
How to Encode and Decode Strings with Base64 in JavaScript
// Create Base64 Object
var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r
@giautm
giautm / s3-public-bucket-policy.json
Last active February 22, 2017 15:11 — forked from ScottPhillips/s3-public-bucket-policy.json
Amazon S3 Bucket Policy : Restrict Access to Specific Referer
{
"Version":"2008-10-17",
"Id":"http referer policy example",
"Statement":[
{
"Sid":"Allow get requests referred by www.mysite.com and mysite.com",
"Effect":"Allow",
"Principal":"*",
"Action":"s3:GetObject",
"Resource":"arn:aws:s3:::YOUR_S3_BUCKET_NAME/*",
@giautm
giautm / feathersjs-auth0.js
Created March 7, 2017 06:19 — forked from theevangelista/feathersjs-auth0.js
A hook to populate an user from Auth0 into feathersjs
const request = require('request-promise');
const errors = require('feathers-errors');
const options = {
idField: 'sub',
issuer: 'iss'
};
module.exports = function() {
import React, {Component} from 'react';
import {View, Text, Navigator, StatusBar} from 'react-native';
import SideMenu from './Router.js'
import Authentication from './Authentication/Authentication.js';
import Main from './Main/Main.js';
import ChangeInfo from './ChangeInfo/ChangeInfo.js';
import OrderHistory from './OrderHistory/OrderHistory.js';
@giautm
giautm / c
Last active December 23, 2017 05:12
Bug
import React from 'react';
import Link from 'next/link';
import { translate } from 'react-i18next';
import i18n from '../i18n';
import Frontend from '../components/frontend/Frontend/Frontend';
class Home extends React.Component {
render() {
return (
@giautm
giautm / app.go
Created November 1, 2018 17:21 — forked from delphinus/app.go
example to encode/decode gob in gin https://github.com/gin-gonic/gin/issues/1357
package main
import (
"bytes"
"encoding/gob"
"net/http"
"github.com/gin-gonic/gin"
)
@giautm
giautm / compound-to-unicode.js
Last active September 11, 2023 03:39 — forked from redphx/compound-to-unicode.java
[Javascript] Chuyển tiếng Việt tổ hợp sang dựng sẵn
function compoundUnicode(str) {
return `${str}`
.replace(/\u0065\u0309/g, '\u1EBB') // ẻ
.replace(/\u0065\u0301/g, '\u00E9') // é
.replace(/\u0065\u0300/g, '\u00E8') // è
.replace(/\u0065\u0323/g, '\u1EB9') // ẹ
.replace(/\u0065\u0303/g, '\u1EBD') // ẽ
.replace(/\u00EA\u0309/g, '\u1EC3') // ể
.replace(/\u00EA\u0301/g, '\u1EBF') // ế
.replace(/\u00EA\u0300/g, '\u1EC1') // ề
@giautm
giautm / grace.go
Created May 23, 2020 17:06 — forked from rcrowley/grace.go
Graceful stop in Go
package main
import (
"log"
"net"
"os"
"os/signal"
"sync"
"syscall"
"time"
@giautm
giautm / vscode-remote-ssh-root.sh
Created July 31, 2021 10:21
workaround hack to open vscode remote as root without logging in as root
# Add sudo to node runner
sed -i "/node/s/^/sudo /" ~/.vscode-server/bin/*/server.sh
# Restart remote vscode
pkill -f vscode
@giautm
giautm / jira_oauth.go
Created October 27, 2021 17:53 — forked from Lupus/jira_oauth.go
Example of using OAuth authentication with JIRA in Go
package main
import (
"context"
"crypto/rsa"
"crypto/x509"
"encoding/json"
"encoding/pem"
"fmt"
"log"