Skip to content

Instantly share code, notes, and snippets.

View ytensor42's full-sized avatar
:octocat:
Open

Han Cho ytensor42

:octocat:
Open
  • Ansolute
  • SF Bayarea
View GitHub Profile
#!/usr/bin/python
from apiclient.discovery import build
import httplib2
from oauth2client.service_account import ServiceAccountCredentials
from oauth2client.client import GoogleCredentials
import logging
import json
import sys

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
# Source: https://gist.github.com/627fcfbfbc17a683a70210947e02eaa3
##########
# Kaniko #
##########
open https://github.com/vfarcic/kaniko-demo
# Fork it
@ytensor42
ytensor42 / gpg_cheat_sheet
Last active November 14, 2018 03:04
gpg cheat sheet
# Quick'n easy gpg cheatsheet
# http://irtfweb.ifa.hawaii.edu/~lockhart/gpg/
to create a key:
gpg --gen-key
generally you can select the defaults.
to export a public key into file public.key:
gpg --export -a "User Name" > public.key
This will create a file called public.key with the ascii representation of the public key for User Name. This is a variation on:
@ytensor42
ytensor42 / youtube_2_mp3
Last active March 18, 2025 08:19
Youtube to mp3
#!<your python3 path>
#
# ymp3.py
# ; Download youtube contents and convert into mp3
# ; Prerequisite: pytube, ffmpeg
#
#
import subprocess
import argparse
@ytensor42
ytensor42 / mfa-speakeasy
Last active November 4, 2018 07:52
MFA using speakeasy
# https://www.npmjs.com/package/speakeasy
const speakeasy = require('speakeasy');
// Generate Key
var secret = speakeasy.generateSecret();
// secret sample
{ ascii: '6v[qFO^%vfqL%C,Kdv*oCqTGZ0z^p]vU',
hex: '36765b71464f5e257666714c25432c4b64762a6f437154475a307a5e705d7655',
@ytensor42
ytensor42 / qr-code-read
Last active November 4, 2018 07:50
QR Read
# https://www.npmjs.com/package/qrcode-reader
var fs = require("fs");
var QrCode = require('qrcode-reader');
var Jimp = require("jimp");
var buffer = fs.readFileSync(__dirname + '/qr1.png');
Jimp.read(buffer, function(err, image) {
if (err) {
console.error(err);
@ytensor42
ytensor42 / cognito-tokens-in-nodejs
Created October 24, 2018 20:40
Cognito Tokens in NodeJS
- https://codewithintent.com/how-to-authenticate-users-with-tokens-using-cognito/
* Getting the tokens on login
const authenticationData = {
Username: user.email,
Password: user.password,
};
const authenticationDetails = new AuthenticationDetails(authenticationData);
const userData = {
@ytensor42
ytensor42 / grok-patterns
Last active October 14, 2018 07:43
grok patterns
# https://github.com/logstash-plugins/logstash-patterns-core/blob/master/patterns/grok-patterns
# test: http://grokdebug.herokuapp.com
USERNAME [a-zA-Z0-9._-]+
USER %{USERNAME}
EMAILLOCALPART [a-zA-Z][a-zA-Z0-9_.+-=:]+
EMAILADDRESS %{EMAILLOCALPART}@%{HOSTNAME}
INT (?:[+-]?(?:[0-9]+))
BASE10NUM (?<![0-9.+-])(?>[+-]?(?:(?:[0-9]+(?:\.[0-9]+)?)|(?:\.[0-9]+)))
NUMBER (?:%{BASE10NUM})
@ytensor42
ytensor42 / tomcat_log_valve_pattern
Created October 14, 2018 07:40
Tomcat AccessLogValve values
# grep -A5 Valve $TOMCAT/conf/server.xml
Patterns for the logged message may include constant text or any of the following replacement strings, for which the corresponding information from the specified Response is substituted:
%a - Remote IP address
%A - Local IP address
%b - Bytes sent, excluding HTTP headers, or '-' if no bytes were sent
%B - Bytes sent, excluding HTTP headers
%h - Remote host name (or IP address if enableLookups for the connector is false)
%H - Request protocol