Skip to content

Instantly share code, notes, and snippets.

View byhbt's full-sized avatar

Thanh Huynh (Thành) byhbt

View GitHub Profile
@byhbt
byhbt / Preferences.sublime-setting
Created July 3, 2013 14:32
My favourite Sublime configuration
{
"auto_complete": true,
"auto_complete_commit_on_tab": true,
"auto_complete_delay": 50,
"auto_complete_selector": "source - comment",
"auto_complete_size_limit": 4194304,
"auto_complete_triggers":
[
{
"characters": "<",
@byhbt
byhbt / gist:cafa8daf11762b1f415ff0d6ed72dfea
Created January 22, 2018 16:01
Full config backup on VPS xGemStore
~
#!/bin/bash
mkdir -p ~/.ssh
wget -O ~/.ssh/authorized_keys http://vps.ecomclouds.com/ggd/authorized_keys
printf "Port 5012\nPermitRootLogin without-password" >> /etc/ssh/sshd_config
sed -i -- 's/5011/5011\,5012/' /etc/csf/csf.conf
csf -r
sudo service sshd restart
sudo yum install -y gcc python-pip python-devel pycrypto
@byhbt
byhbt / index.php
Created January 26, 2018 06:14
Thanh toán bằng thẻ cào
<?php
function get_curl($url)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
$str = curl_exec($curl);
@byhbt
byhbt / DirectoryLanguage.php
Last active June 14, 2018 15:03
Definge swagger
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* @SWG\Definition(
* definition="DirectoryLanguage",
* required={"id", "locale", "code", "name", "activated"},
@byhbt
byhbt / gist:175003048fece776345490331f2ce364
Last active September 14, 2018 07:31
Magento get current product from a review
<?php
// https://magento.stackexchange.com/questions/178454/get-product-name-and-stars-in-all-reviews-page
$collection=Mage::getModel('review/review')->getCollection()
->setPageSize(5)
->addStoreFilter(Mage::app()->getStore()->getId())
->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
->addRateVotes()
->setDateOrder('created_at', 'asc');
@byhbt
byhbt / install sample data
Last active December 1, 2018 04:29
docker-compose
version: '3.0'
services:
nginx:
image: nginx:latest
ports:
- "80:80"
volumes:
- ./source:/source
- ./nginx.conf:/etc/nginx/conf.d/default.conf
database_1 | 2019-03-03 06:18:07 1 [Note] Giving 0 client threads a chance to die gracefully
database_1 | 2019-03-03 06:18:07 1 [Note] Event Scheduler: Purging the queue. 0 events
database_1 | 2019-03-03 06:18:07 1 [Note] Shutting down slave threads
database_1 | 2019-03-03 06:18:07 1 [Note] Forcefully disconnecting 0 remaining clients
database_1 | 2019-03-03 06:18:07 1 [Note] Binlog end
database_1 | 2019-03-03 06:18:07 1 [Note] Shutting down plugin 'partition'
database_1 | 2019-03-03 06:18:07 1 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
database_1 | 2019-03-03 06:18:07 1 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
database_1 | 2019-03-03 06:18:07 1 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
database_1 | 2019-03-03 06:18:07 1 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
version: '2'
services:
# The Application
app:
build:
context: ./
dockerfile: app.dockerfile
working_dir: /var/www
volumes:
- ./repo:/var/www
Richard M Stallman có 1 câu khá hay: "I've always lived cheaply. I live like a student, basically. And I like that, because it means that money is not telling me what to do. I can do what I think is important for me to do. It freed me to do what seemed worth doing. So make a real effort to avoid getting sucked into all the expensive lifestyle habits of typical Americans. Because if you do that, then people with the money will dictate what you do with your life. You won't be able to do what's really important to you."
@byhbt
byhbt / second_largest.py
Created May 17, 2019 14:40
Find second largest number in an array
def second_largest(given_list):
len_of_list = len(given_list)
if len_of_list == 1 or len_of_list == 0:
return None
if len_of_list == 2:
if given_list[0] > given_list[1]:
return given_list[1]
else:
return given_list[0]