Skip to content

Instantly share code, notes, and snippets.

View khlbrg's full-sized avatar
💭
Working

Andreas Kihlberg khlbrg

💭
Working
View GitHub Profile
@khlbrg
khlbrg / install.md
Last active April 2, 2016 19:53 — forked from zaherg/install.md
Creating Your Laravel & nginx Server

Creating Your Laravel & nginx Server

updating your system

	apt-get update && apt-get upgrade
	adduser [username]
	usermod -aG sudo [username]
	apt-get -y install git

Now you will have to logout then you need to login using the user you create

@khlbrg
khlbrg / gist:8051282
Created December 20, 2013 06:51
Remove 301 redirect loop on Wordpress on Nginx
location / {
try_files $uri $uri/ /index.php?q=$uri$is_args&$args;
}
//in functions.php in theme
add_filter( 'got_rewrite', '__return_true' );
@khlbrg
khlbrg / functions.php
Last active March 15, 2016 20:53
Specify custom post types by code
function my_custom_tpa() {
$labels = array(
'name' => _x( 'TPA', 'tpa' ),
'singular_name' => _x( 'TPA', 'tpa' ),
'add_new' => _x( 'Add New', 'book' ),
'add_new_item' => __( 'Add New TPA' ),
'edit_item' => __( 'Edit TPA' ),
'new_item' => __( 'New TPA' ),
'all_items' => __( 'All TPA' ),
'view_item' => __( 'View TPA' ),
@khlbrg
khlbrg / gist:8436191
Last active January 3, 2016 08:29
Make surf CSRF is checked on eash post request on Laravel Controllers
class BaseController extends Controller {
public function __construct()
{
// CSRF protection for all POST requests
$this->beforeFilter('csrf', array('on' => 'post'));
}
}
@khlbrg
khlbrg / create.blade.php
Last active July 11, 2018 21:54
Showing error messages for Laravel forms
<div class="form-group input-group-lg @if ($errors->has('email')) has-error @endif">
{{ Form::text('email', null, array('class' => 'form-control tooltip-form', 'placeholder' => 'Email', 'id' => 'email', 'title' => 'Email')) }}
@if ($errors->has('email')) {{ $errors->first('email')}} @endif
</div>
@khlbrg
khlbrg / functions.php
Created February 20, 2014 12:02
Set another language in WPML
add_action('after_setup_theme', 'my_icl_set_current_language');
function my_icl_set_current_language($lang) {
global $sitepress;
$lang = 'sv';
$sitepress->switch_lang($lang);
}
@khlbrg
khlbrg / style.less
Last active May 26, 2022 15:04
Remove all style from a html select
select {
border:none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
-ms-appearance: none; /* get rid of default appearance for IE8, 9 and 10*/
}
@khlbrg
khlbrg / gist:9724368
Created March 23, 2014 15:13
Create an alias for composer running hhvm
alias composer='hhvm /usr/local/bin/composer'
@khlbrg
khlbrg / functions.php
Last active April 11, 2016 11:37
Easy way to be able to send mail with SMTP in Wordpress.
add_action('phpmailer_init','send_smtp_email');
function send_smtp_email( $phpmailer )
{
// Define that we are sending with SMTP
$phpmailer->isSMTP();
// The hostname of the mail server
$phpmailer->Host = "smtp.example.com";
// Use SMTP authentication (true|false)
@khlbrg
khlbrg / index.html
Last active April 4, 2016 19:31
Check if isEditing
var a = document.createElement('a');
a.href = window.location.href;
if (a.search.indexOf('isEditing=true') !== -1) {
}