Skip to content

Instantly share code, notes, and snippets.

View namnv609's full-sized avatar
🥰
Preparing for something new

NamNV609 namnv609

🥰
Preparing for something new
View GitHub Profile
@namnv609
namnv609 / gist:055023db0ff9b4b73686280e193f179a
Created December 8, 2016 01:45 — forked from tonykwon/gist:8910261
MySQL - Row size too large - BLOB prefix of 768 bytes is stored inline
-- Error Message: Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
--
-- our table name that has this issue is XYZ
--
SET GLOBAL innodb_file_format=Barracuda;
SET GLOBAL innodb_file_per_table=ON;
ALTER TABLE XYZ ROW_FORMAT=COMPRESSED;
@namnv609
namnv609 / pre-push
Created December 1, 2016 03:08
CI local for Git client
#!/usr/bin/env bash
redColor="\033[0;31m"
noColor="\033[0m"
function exitCodeToText() {
text="${redColor}NG${noColor}"
if [[ "$1" == "0" ]]; then
text="OK"
fi
@namnv609
namnv609 / laravel-nginx
Created November 25, 2016 09:15
NginX and PHP7 with Laravel config
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root <Path to project folder>/public;
index index.php index.html index.htm;
server_name <Server name or IP address>;
location / {
@namnv609
namnv609 / resumable-download.php
Created September 12, 2016 10:43 — forked from kosinix/resumable-download.php
PHP - resumable download
<?php
class ResumeDownload {
private $file;
private $name;
private $boundary;
private $delay = 0;
private $size = 0;
function __construct($file, $delay = 0) {
if (! is_file($file)) {
======= Prolbem =================================================================================================================
I have installed : ruby-2.0.0,postgres-9.2 , now in rails app when I execute:
rake db:create , command I get:
PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
HINT: Use the same encoding as in the template database, or use template0 as template.
: CREATE DATABASE "my_db_name" ENCODING = 'unicode'.......
bin/rake:16:in `load'
@namnv609
namnv609 / export-csv.rb
Created June 28, 2016 03:51
Example export CSV with CP932 in Ruby on Rails
require "csv"
class Admin::ExportsController < Admin::BaseAdminController
def index
admin = Admin.first
csv_string = CSV.generate do |csv|
csv << Admin.attribute_names
csv << admin.attributes.values
end
@namnv609
namnv609 / ws-with-nginx-proxy
Created June 24, 2016 04:32
ActionCable WebSocket with NginX proxy
server {
listen 80;
listen 443 ssl;
server_name servername.domain;
ssl on;
ssl_certificate /etc/apache2/ssl/apache.crt;
ssl_certificate_key /etc/apache2/ssl/apache.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
@namnv609
namnv609 / ws-with-apache2-proxy.conf
Last active February 12, 2019 21:13
ActionCable WebSocket with Apache2 proxy
<VirtualHost *:80 *:443>
# Domain
ServerName servername.domain
SSLEngine On
SSLProxyEngine On
# Path to SSL CRT file
SSLCertificateFile /etc/apache2/ssl/apache.crt
# Path to SSL KEY file
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
@namnv609
namnv609 / vietnam-mobile-phone-classify.php
Created February 19, 2016 08:54
Vietnam mobile phone classify
<?php
$phones = [
"0987654321",
"0912345678",
"01234567890",
"01650930293",
"0992938392",
"01882938493",
"0902938292",
@namnv609
namnv609 / php-datetime-range.php
Created February 18, 2016 13:43
Create datetime range with a date
<?php
$date = "2016-01-01";
$outputFormat = "d/m/Y H:i:s";
$startTime = strtotime(date($date));
$endTime = strtotime(sprintf("%s 23:59:59", $date));
$dateTimes = [];
while ($startTime < $endTime) {
$startTime += 60;