Skip to content

Instantly share code, notes, and snippets.

View phamngsinh's full-sized avatar

Pham Ng Sinh phamngsinh

View GitHub Profile
@phamngsinh
phamngsinh / install-remove-kubuntu
Created June 29, 2016 02:51
Install and Remove Kubuntu Desktop
sudo apt-get install ubuntu-desktop
sudo apt-get --purge remove kubuntu-desktop
sudo apt-get autoremove
@phamngsinh
phamngsinh / mail
Created July 11, 2016 05:07
gmail api send
$url= "https://www.googleapis.com/upload/gmail/v1/users/me/messages/send";
$header = array('Content-Type: message/rfc822', "Authorization: Bearer $access_token");
$from = "<$user_name> $user_email";
$line = "rn";
$raw = "Content-type: text/html; charset=UTF-8".$line;
$raw .= "To: $to ".$line;
$raw .= "from: $from".$line;
$raw .= "Reply-To: $user_email".$line;
$raw .= "subject: $subject".$line.$line;
@phamngsinh
phamngsinh / index.txt
Created July 12, 2016 12:46
fix mysql server broken at upgrade ubuntu
sudo dpkg -P mysql-server mysql-server-5.x
sudo apt-get autoremove
sudo apt-get clean
dpkg -l | grep -i mysql
sudo rm -rvf /var/lib/mysql
sudo apt-get install mysql-serve
@phamngsinh
phamngsinh / index.txt
Created July 13, 2016 03:30
Rename database in mysql
CREATE DATABASE `new_database_name` COLLATE 'utf8_unicode_ci';
RENAME TABLE `old_table` TO `new_database_name`.`old_table`;
DROP DATABASE `old_database_name`;
@phamngsinh
phamngsinh / index.txt
Created July 13, 2016 07:19
LF instead of CR+LF under OS in git
28
down vote
I come back to this answer fairly often, though none of these are quite right for me. That said, the right answer for me is a mixture of the others.
What I find works is the following:
git config --global core.eol lf
git config --global core.autocrlf input
For repos that were checked out after those global settings were set, everything will be checked out as whatever it is in the repo – hopefully LF (\n). Any CRLF will be converted to just LF on checkin.
@phamngsinh
phamngsinh / index.txt
Created July 16, 2016 07:25
What's the best CRLF,EOL in git
Two alternative strategies to get consistent about line-endings in mixed environments (Microsoft + Linux + Mac):
A. Global per All Repositories Setup
1) Convert all to one format
find . -type f -not -path "./.git/*" -exec dos2unix {} \;
git commit -a -m 'dos2unix conversion'
2) Set core.autocrlf to input on Linux/UNIX or true on MS Windowns (repository or global)
@phamngsinh
phamngsinh / index.txt
Created July 18, 2016 03:02
Refresh token in laravel
Step 1:
install https://github.com/oriceon/oauth-5-laravel
Step 2 :
get token and follow the instructions: https://github.com/oriceon/oauth-5-laravel
Step 3 :
token expired and should reset
$user = User::find($userId);
$token_interface = new \OAuth\OAuth2\Token\StdOAuth2Token($google_token, $google_refresh_token);
$googleService = \OAuth::consumer('Google');
@phamngsinh
phamngsinh / index.txt
Created July 19, 2016 21:19
CLRF and CL in git
git config --global core.autocrlf false
git config --global core.safecrlf false
@phamngsinh
phamngsinh / index.html
Created July 20, 2016 08:34
Download nhaccuatui.com
window.open($('#mp3flashPlayer').attr('src').trim(),'_blank');
@phamngsinh
phamngsinh / Custom.txt
Created July 26, 2016 10:24
Custom data pagination with Laravel 5
<?php namespace App\Http\Controllers;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
class SearchController extends Controller {
public function search()
{
.