Skip to content

Instantly share code, notes, and snippets.

View tranductam2802's full-sized avatar
🔥
Fulltime Mobile Developer! Part-time Poker dealer

Trần Đức Tâm tranductam2802

🔥
Fulltime Mobile Developer! Part-time Poker dealer
View GitHub Profile
(function () {
'use strict';
if (location.host !== 'daynhauhoc.com') {
const checkHost = confirm('Bookmarklet does not work on this page.\nDo you want to open DayNhauHoc?');
if (checkHost) top.location.href = 'https://daynhauhoc.com';
return;
}
if (!Discourse.User.current()) {
@tranductam2802
tranductam2802 / OpenSSL Errors and Rails – Certificate Verify Failed.md
Created August 9, 2018 06:48
Are you getting an error “OpenSSL certificate verify failed” with Ruby? You may be seeing Ruby errors with OpenSSL because of outdated SSL certificate files. These problems are most common with Ruby 2.1 on Mac OS X.

OpenSSL Errors and Rails – Certificate Verify Failed

Errors overviews

The error message:

openssl::ssl::sslerror: ssl_connect returned=1 errno=0 state=sslv3 read server certificate b: certificate verify failed

or

could not load openssl. you must recompile ruby with openssl support or change the sources in your gemfile from 'https' to 'http'. instructions for compiling with openssl using rvm are available at rvm.io/packages/openssl.

@tranductam2802
tranductam2802 / install-ruby-2_5_1-with_rbenv.sh
Last active August 23, 2018 08:04 — forked from turadg/install-ruby-2.0.0.sh
Install Ruby (default 2.2) with Readline and latest OpenSSL (環境管理ツールのrbenvを作成する)
#!/usr/bin/env sh
echo '# Update the newest brew tool'
brew update
echo '# Upgrade any that were already installed'
brew upgrade rbenv ruby-build readline openssl
echo "# Install what's missing"
brew install rbenv ruby-build readline openssl
@tranductam2802
tranductam2802 / bottle_hello.py
Created August 9, 2018 08:06 — forked from drgarcia1986/bottle_hello.py
Python HelloWorld (WebFrameworks) Collection
# -*- coding: utf-8 -*-
from bottle import route, run
@route('/')
def index():
return '<h1>Hello World/h1>'
run(host='localhost', port=8000)
@tranductam2802
tranductam2802 / Cookbook.md
Last active August 21, 2018 06:58
Include the cheat sheet and the best technical question's answer.

Service vs IntentService

When to use?

  • The Service can be used in tasks with no UI, but shouldn't be too long. If you need to perform long tasks, you must use threads within Service.

  • The IntentService can be used in long tasks usually with no communication to Main Thread. If communication is required, can use Main Thread handler or broadcast intents. Another case of use is when callbacks are needed (Intent triggered tasks).

How to trigger?

  • The Service is triggered by calling method startService().
@tranductam2802
tranductam2802 / install-ruby-2_5_1-on-rails-5_2_0-with_rbenv.sh
Last active August 23, 2018 08:06
Install Ruby (2.5.1) on Rails (5.2.0) with Readline and latest OpenSSL (環境管理ツールのrbenvを作成する)
#!/usr/bin/env sh
echo ' # Update the newest brew tool'
brew update
echo ' # Upgrade any that were already installed'
brew upgrade rbenv ruby-build readline openssl
echo ' # Install the missing package'
brew install rbenv ruby-build readline openssl
package io.github.view
import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.util.AttributeSet
import android.view.View
import io.github.utils.DimensionUtils
import java.util.regex.Pattern
@tranductam2802
tranductam2802 / gitlab.cli
Created January 3, 2019 13:45
Config GitLab CI - demo for Android
# Newest JDK
image: openjdk:8-jdk
variables:
RUNNER_HOME: "/home/gitlab-runner"
ANDROID_HOME: "${RUNNER_HOME}/android-sdk-linux"
# Android target SDK configured on build.gradle
ANDROID_TARGET_SDK: "25"
# Android compile SDK configured on build.gradle
ANDROID_COMPILE_SDK: "25"
@tranductam2802
tranductam2802 / ping.py
Created May 27, 2019 01:44
Ping all local network for finding avaiable IP address
import subprocess
import ipaddress
from subprocess import Popen, PIPE
network = ipaddress.ip_network('192.168.0.0/24')
for idx in network.hosts():
ip = str(idx)
toping = Popen(['ping', '-w', '300', ip], stdout=PIPE)
output = toping.communicate()[0]
hostalive = toping.returncode
@tranductam2802
tranductam2802 / ssh_client.py
Created September 6, 2019 05:30
Funny SSH client has written by Python for learning paramiko library
from termcolor import *
from sys import stdin
import colorama
import paramiko as ssh
import sys
import time
import os
HOST = ''
USER = ''