Skip to content

Instantly share code, notes, and snippets.

@johanneslamers
johanneslamers / macro.twig
Created September 22, 2016 11:55 — forked from aelvan/macro.twig
Twig macro for creating a srcset string in Craft
{% macro getSrcSet(image, sizes, upscale) %}
{%- spaceless %}
{% set sizesOut = [] %}
{% set allowScaleLarger = upscale | default(false) %}
{# loop over sizes parameter and generate transforms #}
{% for size in sizes %}
{%- spaceless %}
{% set currentTransform = {} %}
@johanneslamers
johanneslamers / v-cloak.md
Created September 22, 2016 11:52 — forked from adamwathan/v-cloak.md
Useful CSS utilities for Vue.js cloaking

Handy helpers for controlling visibility of elements until Vue has compiled.

Use like:

<div v-cloak>
  <h1>
    <span class="v-cloak--inline">Loading...</span> <!-- Only displayed before compiling -->
    <span class="v-cloak--hidden">{{ post.title }}</span> <!-- Hidden until compiling is finished -->
 
@johanneslamers
johanneslamers / form.php
Created September 22, 2016 11:48 — forked from AndreasLoukakis/form.php
vue directive for ajax submits on laravel
<form method="POST"
action="/posts/3"
v-ajax complete="Okay, the post has been deleted."
>
{{ method_field('DELETE') }}
{{ csrf_field() }}
<button type="submit">Delete Post</button>
</form>
@johanneslamers
johanneslamers / ajax_form.js
Created September 22, 2016 11:46
ajax_form
jQuery(function($) {
$('form[data-async]').on('submit', function(event) {
var $form = $(this);
var $target = $($form.attr('data-target'));
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize(),
@johanneslamers
johanneslamers / app.js
Created September 22, 2016 11:46
Ajax Form
jQuery(document).ready( function() {
jQuery('#form').show();
jQuery('#output').hide();
jQuery('#get-detail').click( function() {
var valid = true;
jQuery('input[type="text"], input[type="password"], input[type="email"]').each( function() {
@johanneslamers
johanneslamers / index.html
Created September 22, 2016 11:36 — forked from kkiernan/index.html
A Vue.js filter that formats a phone number.
<input type="text"
name="home_phone"
class="form-control"
v-model="homePhone | phone"
lazy>
@johanneslamers
johanneslamers / [1] main.js
Created September 22, 2016 11:35 — forked from hfalucas/[1] main.js
[Vue.js] Authentication and Authorization
/**
* Think of this "main.js" file as your application bootstrap.
*/
import Vue from 'vue'
import Resource from 'vue-resource'
import VueRouter from 'vue-router'
import routes from './routes'
import middleware from './middleware'
@johanneslamers
johanneslamers / set-project-perms.sh
Created September 22, 2016 11:28 — forked from khalwat/set-project-perms.sh
Properly set permissions for a Craft CMS install, including ensuring that files are all g-x. Set CHOWN_USER, CHOWN_GROUP, and BASE_DIR to whatever is appropriate, add directories that need to be writeable by the web server to DIRS[], then execute: sudo ./set-project-perms.sh PROJECT_NAME
#!/bin/bash
# Execute via: ./set-project-perms.sh PROJECT_NAME
# The paradigm is the entire project dir is owned by $CHOWN_USER with the group set to $CHOWN_GROUP
# $CHOWN_USER is an admin or user account that is used to edit files/templates, etc.
# $CHOWN_GROUP is the group of the webserver (e.g.: 'apache', 'nginx', 'httpd', etc.)
# The project dir permissions are set to 755 (-rwxr-xr-x) for directories and to 644 (-rw-r--r--) for files
# The permissions to $DIRS[] that need to be writeable are set to 775 (-rwxrwxr-x) for directories and
# 664 (-rw-rw-r--) for files. Add any assets directories, etc. as necessary.
# Change $BASE_DIR to the absolute path where your websites are stored (leaving it appended with '/$1')
@johanneslamers
johanneslamers / ajax_get.twig
Created September 22, 2016 11:27 — forked from WietseWind/ajax_get.twig
Inline edit + AJAX + VueJS using nodum
{% trim %}
{{ mongo.find({ deleted : { '$exists' : false } })|json_encode }}
{% endtrim %}
@johanneslamers
johanneslamers / json-sample.twig
Created September 22, 2016 11:22 — forked from WietseWind/json-sample.twig
nodum vuejs sample progress-bar
{{ [
{ id: 1, name: "Wietse", donkerblauw: 10, blauw: 20 },
{ id: 2, name: "Thomas", groen: 20, oranje: 40 },
{ id: 3, name: "Pepper", oranje: 90, groen: 5 },
{ id: 4, name: "Henk", blauw: 40, oranje: 20 }
]|json_encode }}