Skip to content

Instantly share code, notes, and snippets.

@poul-kg
poul-kg / valet.conf
Last active July 1, 2024 21:34
CORS Rules for Laravel Valet Nginx
# To enable CORS you should add lines with CORS rules below to your valet.conf file
# Find the file /usr/local/etc/nginx/valet/valet.conf - this is Valet conf for Nginx
# of try to execute `locate valet.conf` and find the `valet.coinf` in `nginx` subdirectory
# after you edit your valet.conf do not forget to execute `valet restart`
server {
listen 80 default_server;
root /;
charset utf-8;
client_max_body_size 128M;
import qs from 'qs';
import Axios from 'axios';
Axios.defaults.baseURL = Craft.baseUrl;
Axios.defaults.headers.common['Accept'] = 'application/json';
Axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
Axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
Axios.interceptors.request.use(config => {
if (config.data instanceof FormData) {
@Chrisedmo
Chrisedmo / extras.sh
Last active November 15, 2016 06:13
Extra Requirements for Larval Valet + Craft 2.6
brew install php70-mcrypt
brew install php70-imagick
brew install homebrew/versions/mysql56
Then run valet restart after each.
@MisterPoppet
MisterPoppet / nav.html
Last active August 29, 2015 14:21
Recursive Macro
{% macro menu(items, class, home) %}
{% import _self as parts %}
<div class="lucky {{ class|default('main') }} menu">
{% if home|default(true) %}
<a href="{{ siteUrl }}">Home</a>
{% endif %}
{{ parts.menuItems(items) }}
</div>
{% endmacro %}
@Natetronn
Natetronn / craft-specific-syntax.md
Last active August 29, 2015 14:19
Craft CMS Project Specific Syntax Highlighting for HTML (Twig)
@Natetronn
Natetronn / .editorconfig
Created April 16, 2015 23:15
Craft CMS Editor Config with PT Coding Standards - Find your IDE/Editor here: http://editorconfig.org/#download
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
<?php
namespace Craft;
class EntryTypeSourcesPlugin extends BasePlugin
{
public function getName()
{
return Craft::t('Entry Type Sources');
}
@pburtchaell
pburtchaell / styles.css
Last active February 25, 2024 12:24
VH and VW units can cause issues on iOS devices. To overcome this, create media queries that target the width, height, and orientation of iOS devices.
/**
* VH and VW units can cause issues on iOS devices: http://caniuse.com/#feat=viewport-units
*
* To overcome this, create media queries that target the width, height, and orientation of iOS devices.
* It isn't optimal, but there is really no other way to solve the problem. In this example, I am fixing
* the height of element `.foo` —which is a full width and height cover image.
*
* iOS Resolution Quick Reference: http://www.iosres.com/
*/
@maxgalbu
maxgalbu / Switch_Node.php
Last active December 31, 2019 16:03
Switch tag for Twig, updated from https://github.com/fabpot/Twig/pull/185 to work with Twig >= 1.12
<?php
//To be added under Twig/Node/Switch.php
/*
* This file is part of Twig.
*
* (c) 2009 Fabien Potencier
* (c) 2009 Armin Ronacher
*
@electricg
electricg / mouse.js
Last active April 27, 2021 16:32
Mouse position relative to document and element
// Which HTML element is the target of the event
function mouseTarget(e) {
var targ;
if (!e) var e = window.event;
if (e.target) targ = e.target;
else if (e.srcElement) targ = e.srcElement;
if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode;
return targ;
}