Skip to content

Instantly share code, notes, and snippets.

View ademers's full-sized avatar
🧡

Andrea ademers

🧡
View GitHub Profile
@jterrace
jterrace / xvfb
Created June 11, 2012 18:46
xvfb init script for Ubuntu
XVFB=/usr/bin/Xvfb
XVFBARGS=":1 -screen 0 1024x768x24 -ac +extension GLX +render -noreset"
PIDFILE=/var/run/xvfb.pid
case "$1" in
start)
echo -n "Starting virtual X frame buffer: Xvfb"
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
echo "."
;;
stop)
@shazow
shazow / v1
Last active June 6, 2017 06:57
post-receive hook to push-deploy with git
#!/bin/bash
# post-receive hook to push-deploy multiple branches using a git repo.
#
# Deploy by pushing $DEPLOY_BRANCH
# Rollback by force-pushing a new reference to $OVERRIDE_TAG
#
# 1. Setup your git repo:
#
# git init --bare
#
@brandonkelly
brandonkelly / templating.md
Last active March 11, 2025 21:41
Templating in EE vs. Craft
@PadreZippo
PadreZippo / embed.html
Last active September 30, 2023 17:10
iframes with constant aspect ratios
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<!-- This iframe will always fill the parent width, but will remain at 16:9 aspect ratio -->
<div class="ratio-16-9">
<iframe class="ratio-inner" src="https://sketchfab.com/models/{{model_id}}/embed"></iframe>
@adamwathan
adamwathan / v-cloak.md
Last active November 6, 2024 14:28
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 -->
 
@khalwat
khalwat / set-project-perms.sh
Last active January 1, 2020 01:10
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
This is now part of craft-scripts:
https://github.com/nystudio107/craft-scripts
@fyrebase
fyrebase / gist.php
Created May 11, 2016 10:23
Craft CMS rename asset and title on asset save
<?php
protected function initSaveAssetEventListeners()
{
craft()->on('assets.saveAsset', function(Event $event) {
if ($event->params['isNewAsset']) {
$asset = $event->params['asset'];
$source = $asset->getSource();
if (in_array($source->handle, ['myAssetSource'])) {
@engram-design
engram-design / export.php
Last active August 21, 2024 08:51
ExpressionEngine PHP Export into JSON
<?php
$channel = $_GET['id'];
$content = array();
$fields_query = $this->EE->db->query("SELECT * FROM exp_channel_fields LEFT JOIN exp_channels ON exp_channel_fields.group_id = exp_channels.field_group WHERE exp_channels.channel_id = '$channel'");
$entries_query = $this->EE->db->query("SELECT * FROM exp_channel_data cd INNER JOIN exp_channel_titles ct ON cd.entry_id = ct.entry_id WHERE cd.channel_id = '$channel'");
$fields = $fields_query->result_array();
@andrewlimaza
andrewlimaza / honeypot-example.php
Last active November 16, 2024 11:47
Simple honeypot for an HTML form using PHP
<?php
//check if form was sent
if($_POST){
$to = '[email protected]';
$subject = 'Testing HoneyPot';
$header = "From: $name <$name>";
$name = $_POST['name'];
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) {