Skip to content

Instantly share code, notes, and snippets.

View thangngoc89's full-sized avatar

Khoa Nguyen thangngoc89

View GitHub Profile
@thangngoc89
thangngoc89 / Discourse Payload
Created January 3, 2015 12:29
Discourse Payload
def to_url(base_url=nil)
base = "#{base_url || sso_url}"
"#{base}#{base.include?('?') ? '&' : '?'}#{payload}"
end
ErrorException in Guard.php line 419:
Argument 1 passed to Illuminate\Auth\Guard::login() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of Quiz\User given, called in D:\www\newquiz\app\AuthenticateUser.php on line 53 and defined
#Stace Trace
in Guard.php line 419
at HandleExceptions->handleError('4096', 'Argument 1 passed to Illuminate\Auth\Guard::login() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of Quiz\User given, called in D:\www\newquiz\app\AuthenticateUser.php on line 53 and defined', 'D:\www\newquiz\vendor\laravel\framework\src\Illuminate\Auth\Guard.php', '419', array()) in Guard.php line 419
at Guard->login(object(User), true) in AuthenticateUser.php line 53
at AuthenticateUser->execute('facebook', true, object(AuthController)) in AuthController.php line 19
at AuthController->login('facebook', object(AuthenticateUser), object(Request))
at call_user_func_array(array(object(AuthController), 'login'), array('provider' => 'facebook', object(Aut

Deploy your own PaaS!

Setting up Dokku with DigitalOcean and Namecheap

..or how I made my own heroku in a few hours for $3.98.

This write-up owes a great deal to dscape's Node.js Deployments with Docker, Dokku, & Digital Ocean, the dokku project itself, and the fine folks working on dokku's issues. I took dscape's article as a starting point when trying this out but found some details lacking so I documented my own process for getting dokku up and running.

1. Get a domain

// Test Model
<?php
use Illuminate\Database\Eloquent\Model as Eloquent;
class Test extends Eloquent {
protected $table = 'test';
protected $hidden = array();
protected $fillable = array('id', 'title');
protected $nullable = [];
public $timestamps = false;
// Database connector
<?php
use Illuminate\Database\Capsule\Manager as Capsule;
/**
* Configure the database and boot Eloquent
*/
global $capsule;
$capsule = new Capsule;
$capsule->addConnection(array(
'driver' => getenv('DB_DRIVER'),
$categories = array(
'Xe' => array(
'Xe máy',
'Xe ô tô',
),
'Điện thoại, Viễn thông' => array(
'Điện thoại',
'Linh kiện, phụ kiện',
),
);
@thangngoc89
thangngoc89 / msconvert.js
Created December 30, 2015 20:41 — forked from remino/msconvert.js
JavaScript: Convert milliseconds to object with days, hours, minutes, and seconds
function convertMS(ms) {
var d, h, m, s;
s = Math.floor(ms / 1000);
m = Math.floor(s / 60);
s = s % 60;
h = Math.floor(m / 60);
m = m % 60;
d = Math.floor(h / 24);
h = h % 24;
return { d: d, h: h, m: m, s: s };
@thangngoc89
thangngoc89 / db.js
Created June 2, 2017 13:45 — forked from soldair/db.js
backup a running node levelup process
var levelup = require('level')
var zlib = require('zlib')
var fs = require('fs')
var through = require('through')
//hot backup
db = levelup(...)
var backingup = false
@thangngoc89
thangngoc89 / berlin-jsconf-2014.md
Created July 19, 2017 11:41 — forked from nikcorg/berlin-jsconf-2014.md
Slide decks of JSConf 2014
@thangngoc89
thangngoc89 / vpn.md
Created February 14, 2018 05:56 — forked from joepie91/vpn.md
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

(A Russian translation of this article can be found here, contributed by Timur Demin.)

Why not?