Skip to content

Instantly share code, notes, and snippets.

View doulmi's full-sized avatar

CHEN Fengyu doulmi

  • French
View GitHub Profile
@doulmi
doulmi / LaravelNavbarActive.php
Created January 4, 2017 09:50
Laravel Navbar active
//Helper
/**
* Determine if this <li> is active
* return 'active' or ''
*/
public static function activeLi($routes)
{
if (is_string($routes)) {
return Route::currentRouteNamed($routes) ? 'active' : '';
} elseif (is_array($routes)) {
@doulmi
doulmi / BootstrapBtnBlank.css
Last active January 4, 2017 10:52
Bootstrap button not be blank when hover
.btn:focus, .btn.focus, .btn:active:focus, .btn:active.focus, .btn.active:focus, .btn.active.focus {
color: white;
}
&:focus, &.focus, &:active:focus, &:active.focus, &.active:focus, &.active.focus {
color: white;
}
@doulmi
doulmi / LaravelXSS.php
Created February 24, 2017 08:36
Protect from form input XSS attack
public static function stripXSS()
{
$sanitized = static::cleanArray(Input::get());
Input::merge($sanitized);
}
public static function cleanArray($array)
{
$result = array();
foreach ($array as $key => $value) {
@doulmi
doulmi / ImageUtils.php
Created March 9, 2017 08:56
ImageUtils
<?php
namespace App;
use Exception;
class ImageUtils
{
public static $_JPG = "jpg";
public static $_PNG = "png";
@doulmi
doulmi / CheckForMaintenanceMode.php
Created March 15, 2017 11:21
Maintenance mode, but server and ip in whiteliste can access
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Foundation\Application;
use Symfony\Component\HttpKernel\Exception\HttpException;
class CheckForMaintenanceMode
{
@doulmi
doulmi / iphone_disable_autozoom_input.css
Last active May 31, 2017 07:39 — forked from vedranjaic/iphone_disable_autozoom_input.css
css: iPhone - Disable auto-zoom on input fields
/*
* disable auto-zoom on iphone input field focus
* http://www.456bereastreet.com/archive/201212/ios_webkit_browsers_and_auto-zooming_form_controls/
*/
input[type='text']:focus,
input[type='number']:focus,
textarea:focus {
font-size: 16px;
}
@doulmi
doulmi / RFI Downloader.php
Created June 21, 2017 07:49
RFI Downloader.php
<?php
namespace App\Console\Commands;
use Carbon\Carbon;
use Exception;
use Illuminate\Console\Command;
require_once app_path('simple_html_dom.php');
@doulmi
doulmi / Bienvenu.php
Created June 21, 2017 07:50
Bienvenu.php
<?php
namespace App\Console\Commands;
use Carbon\Carbon;
use Illuminate\Console\Command;
require_once app_path('simple_html_dom.php');
class FrDown extends Command
@doulmi
doulmi / download_all_branches.sh
Created June 23, 2017 14:16
Download All branches
#!/bin/bash
set -x #echo on
remote_url=$(git config --get remote.origin.url)
for branch in $(git branch --all | grep '^\s*remotes' | egrep --invert-match '(:?HEAD|master)$'); do
branch_name=$(echo $branch| cut -d'/' -f 3)
git clone -b $branch_name $remote_url $branch_name
done
@doulmi
doulmi / Laravel Active menubar js.php
Created August 14, 2017 07:29
Laravel Active menubar js
// Set active state on menu element
var current_url = "{{ Request::fullUrl() }}";
var full_url = current_url+window.location.search;
var $navLinks = $("ul.sidebar-menu li a");
// First look for an exact match including the search string
var $curentPageLink = $navLinks.filter(
function() { return $(this).attr('href') === full_url; }
);
// If not found, look for the link that starts with the url
if(!$curentPageLink.length > 0){