Skip to content

Instantly share code, notes, and snippets.

View ellefsen's full-sized avatar

Kim Ellefsen ellefsen

View GitHub Profile
@tillsanders
tillsanders / intro.markdown
Last active June 24, 2021 20:17
Laravel: drag-and-drop repositioning with auto-save of DB entries

Laravel: drag-and-drop repositioning with auto-save of DB entries

Use case: Database entries are represented in a table. By grabbing and moving a row up or down the table, you can change the entries' order/position. The changes are submitted automatically via ajax.

  • Uses jQueryUI (custom download: sortable is needed)
  • newly created elements are added to the top (see route /jobs/create)
@abrudtkuhl
abrudtkuhl / nginx-elasticsearch-proxy.conf
Last active August 23, 2019 01:33 — forked from karmi/nginx-elasticsearch-proxy.conf
NGINX Reverse Proxy Authentication For Elasticsearch
# Run me with:
#
# $ nginx -p /path/to/this/file/ -c nginx.conf
#
# All requests are then routed to authenticated user's index, so
#
# GET http://user:password@localhost/_search?q=*
#
# is rewritten to:
#
@mrwweb
mrwweb / mrw-tinymce-filter-example.php
Last active September 1, 2022 19:11
A plugin to modify the TinyMCE editor in WordPress 3.9+. Now available on WP.org! https://wordpress.org/plugins/mrw-web-design-simple-tinymce/
<?php
/**
* Example filter to add text style to TinyMCE filter with Mark's "MRW TinyMCE Mods" plugin
*
* Adds a "Text Styles" submenu to the "Formats" dropdown
*
* This would go in a functions.php file or mu-plugin so you don't have to modify the original plugin.
*
* $styles array Contains arrays of style_format arguments to define styles.
* Note: Should be an "array of arrays"
@madalinignisca
madalinignisca / anonymous-wordpress.php
Created September 4, 2013 19:20
"anonymous" user faked on a real user. use something like Justin's members plugin to create a custom role or wait until I'll add more code to help with many important permissions. I'm putting this together for a project I'm doing (or done when you're reading this) to be able to post anonymous using a custom child theme based on p2. something lik…
<?php
function auto_login() {
if (!is_user_logged_in()) {
//determine WordPress user account to impersonate
$user_login = 'anonymous';
//get user's ID
$user = get_userdatabylogin($user_login);
$user_id = $user->ID;
@Abban
Abban / cookie.php
Last active January 4, 2019 21:48
WP Config for multiple environments. Code is for this blog post: http://abandon.ie/wordpress-configuration-for-multiple-environments/
@kenzie
kenzie / craft.conf
Last active May 17, 2018 17:48
Nginx virtual host configuration for Craft CMS, PHP5-FPM, NGINX 1.2.1 and craft/config/general.php for friendly URLs.
server {
listen 80;
root /var/www/craft.dev/public;
index index.php index.html index.htm;
server_name craft.dev;
location / {
try_files $uri $uri/ @rewrites;
@Shelob9
Shelob9 / foundation-interchange.php
Last active July 31, 2023 16:01
Function to use Foundation's Interchange to make WordPress images automatically responsive. Also included is a function to add Interchange to the theme if Foundation is not already being used. http://foundation.zurb.com/docs/components/interchange.html
add_filter('post_thumbnail_html', 'slug_responsive_img', 5, 5);
//Image sizes for Interchange
add_image_size( 'fd-lrg', 1024, 99999);
add_image_size( 'fd-med', 768, 99999);
add_image_size( 'fd-sm', 320, 9999);
function slug_responsive_img($html, $post_id, $post_thumbnail_id, $size, $attr) {
//make image links
$attachment_id = $post_thumbnail_id;
$default = wp_get_attachment_image_src($attachment_id);
@msurguy
msurguy / eloquent.md
Last active February 8, 2022 03:13
Laravel 4 Eloquent Cheat Sheet.

Conventions:

Defining Eloquent model (will assume that DB table named is set as plural of class name and primary key named "id"):

class Shop extends Eloquent {}

Using custom table name

protected $table = 'my_shops';

@mattbanks
mattbanks / Gruntfile.js
Last active June 13, 2019 12:09
Gruntfile.js for use in developing and deploying WordPress themes
'use strict';
module.exports = function(grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig({
// watch for changes and trigger compass, jshint, uglify and livereload
watch: {
@benmay
benmay / single-user-loggin.php
Last active March 14, 2019 17:51
Ensures only one user at a time can be logged into WordPress, ie, 2 people can't login using the same account.
<?php
/*
Plugin name: Single user login
Plugin URI:
Description:
Author: Ben May
Author URI:
Version: 0.1
*/