Skip to content

Instantly share code, notes, and snippets.

Avatar

Kim Ellefsen ellefsen

View GitHub Profile
@ellefsen
ellefsen / Procfile
Last active Oct 28, 2020
Heroku with Google Cloud SQL and cloud_sql_proxy with PHP / Laravel
View Procfile
web: (bash ./start.sh) & vendor/bin/heroku-php-nginx public/
@ellefsen
ellefsen / nginx.conf
Created Dec 5, 2017 — forked from thoop/nginx.conf
Official prerender.io nginx.conf for nginx
View nginx.conf
# Change YOUR_TOKEN to your prerender token and uncomment that line if you want to cache urls and view crawl stats
# Change example.com (server_name) to your website url
# Change /path/to/your/root to the correct value
server {
listen 80;
server_name example.com;
root /path/to/your/root;
index index.html;
@ellefsen
ellefsen / Index.vue
Created Aug 15, 2017
Vue User Loaded
View Index.vue
<template>
<new-component :user="user" v-if="user"></new-component>
</template>
<script>
import { mapGetters } from 'vuex'
import NewComponent from '@/components/NewComponent'
export default {
components: {
@ellefsen
ellefsen / acf.php
Last active Mar 21, 2017
Add ACF fields to WordPress Page Meta field
View acf.php
<?php
/**
* Add ACF to Post meta stuff.
*/
function my_rest_prepare_post( $data, $post, $request ) {
$data->data['meta'] = array_merge($data->data['meta'], get_fields($post->ID));
return $data;
}
add_filter( 'rest_prepare_page', 'my_rest_prepare_post', 10, 3 );
@ellefsen
ellefsen / routes.php
Created Aug 17, 2016 — forked from tommymarshall/routes.php
Simple Laravel + Craft integration
View routes.php
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
View class-developer-import.php
<?php
// Published under GPL
// tutorial here: https://codeable.io/community/how-to-import-json-into-wordpress/
class Developer_Import {
public function __construct() {
add_action( 'wp_ajax_import_developer', array( $this, 'import_developer' ) );
@ellefsen
ellefsen / nginx.conf
Created Jan 9, 2016 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
View nginx.conf
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
View s3cmd_sync.sh
# Command Line to run from terminal
# Logs result to file s3_backup.log
# Command will run in the background
s3cmd sync -v /path/to/folder/ s3://s3-bucket/folder/ > s3_backup.log 2>&1 &
# Crontab command to sync folder to S3
# Command will run 1am every day and logs result to /root/s3_backup.log
0 1 * * * /usr/bin/s3cmd sync -rv /path/to/folder/ s3://s3-bucket/folder/ >> /root/s3_backup.log
View s3_backup.sh
#!/bin/bash
######
# this script uses s3cmd from http://s3tools.org/s3cmd to sync a folder in linux to s3
#
# make sure that you have configured s3cmd by running s3cmd --configure
#
# this script is usally kept in a cron to be run every x amount of hours
######