Skip to content

Instantly share code, notes, and snippets.

View marcoskubis's full-sized avatar

Marcos Kubis marcoskubis

View GitHub Profile
@marcoskubis
marcoskubis / backup.php
Created June 21, 2018 13:34
Backup database and files of your VPS
<?php
$destination = "/home/user/backups";
$filename = "db_backup.sql";
$host = '127.0.0.1';
$database = 'mydb';
$password = 'mypass';
$gdrive_folder = '0B2WMB4jNcJeRVTd6TTliZWVVSFE';
// Dumps mysql database to a sql file called "db_backup.sql"
@marcoskubis
marcoskubis / AuthController.php
Created September 25, 2017 17:08
Allow login using username or email in Laravel 5.4
<?php
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class AuthController extends Controller
{
@marcoskubis
marcoskubis / mask.html
Last active September 25, 2019 01:29
Ionic 3 input mask directive
<ion-input mask='(99) 9999-9999' [(ngModel)]='phone' type='text'></ion-input>
@marcoskubis
marcoskubis / template.php
Created February 28, 2017 20:12
Simple template engine for PHP
function template($template, $array = [])
{
$res = preg_match_all("/{{(.*?)}}/", $template, $m);
foreach ($m[1] as $i => $varname) {
$val = isset($array[trim($varname)])? $array[trim($varname)] : '';
$template = str_replace($m[0][$i], sprintf('%s', $val), $template);
}
return $template;
}
@marcoskubis
marcoskubis / table-ellipsis.css
Created February 24, 2017 13:08
Bootstrap table ellipsis
.table.table-ellipsis tbody td {
max-width: 100px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap
}
@marcoskubis
marcoskubis / modal-vcenter.css
Created February 13, 2017 19:30
Bootstrap modal centralized vertically
/*
* Created by: Finik
* Copied from http://stackoverflow.com/questions/18422223/bootstrap-3-modal-vertical-position-center
*/
.modal {
text-align: center;
}
@media screen and (min-width: 768px) {
@marcoskubis
marcoskubis / bs-modal-effect.css
Last active October 19, 2016 16:45
Overrides bootstrap modal effect
.modal.fade .modal-dialog{
-webkit-transition: all .2s linear;
-o-transition: all .2s linear;
transition: all .2s linear;
opacity: 0;
transform: scale(1.08);
}
.modal.in .modal-dialog{
opacity: 1;
transform: scale(1);
@marcoskubis
marcoskubis / scopeQuery.js
Last active October 18, 2016 20:33 — forked from fabien/gist:76c28baa99de1bbdc141
Mixin for query scope on rest for loopback
module.exports = function(Model, options) {
var mergeQuery = require('loopback-datasource-juggler/lib/utils').mergeQuery;
var _ = require('lodash');
var scopes = options.scopes || _.keys(Model.scopes);
var validScopes = {};
_.each(Model.scopes, function(scope, name) {
if (scope.modelFrom === Model && scope.modelFrom === scope.modelTo) {
@marcoskubis
marcoskubis / states-cities-ibge.json
Created August 29, 2016 17:08
JSON Estados e cidades com código IBGE
[
{
"id": 1,
"name": "Acre",
"initials": "AC",
"code": 12,
"cities": [
{
"id": 27,
"name": "Acrel\u00e2ndia",