Skip to content

Instantly share code, notes, and snippets.

View endymion1818's full-sized avatar
🦈
47

Ben Read endymion1818

🦈
47
View GitHub Profile
@ramseyp
ramseyp / hide-editor.php
Created November 12, 2012 15:48
Hide the content editor for certain pages in WordPress
<?php
/**
* Hide editor on specific pages.
*
*/
add_action( 'admin_init', 'hide_editor' );
function hide_editor() {
// Get the Post ID.
%reset-Button {
border: none;
margin: 0;
padding: 0;
width: auto;
overflow: visible;
background: transparent;
/* inherit font & color from ancestor */
@aamnah
aamnah / lamp.sh
Last active February 19, 2024 11:51
Bash script to install Apache, MySQL and PHP as well as PHPMyAdmin and some tweaks. For Debian and Ubuntu. To run, copy the script to the server and run ``bash lamp.sh``
#!/bin/sh
#######################################
# Bash script to install an AMP stack and PHPMyAdmin plus tweaks. For Debian based systems.
# Written by @AamnahAkram from http://aamnah.com
# In case of any errors (e.g. MySQL) just re-run the script. Nothing will be re-installed except for the packages with errors.
#######################################
#COLORS
@jeherve
jeherve / plugin.php
Last active May 14, 2016 00:59
[Jetpack] Remove all CSS.
<?php
// First, make sure Jetpack doesn't concatenate all its CSS
add_filter( 'jetpack_implode_frontend_css', '__return_false' );
// Then, remove each CSS file, one at a time
// You probably won't need them all, unless you use all the modules, and all the themes! :)
// Some of these are also only loaded on specific admin pages, so it wouldn't affect your readers
function jeherve_remove_all_jp_css() {
wp_deregister_style( 'AtD_style' ); // After the Deadline
.cloud {
@for $i from 1 through 3 {
$new-position: 10*$i;
li:nth-of-type(#{$i}) {
background-image: url("http://krystalcampioni.com/talk/clouds.svg");
top: -(#{$new-position})+(vh); // repositioning each cloud on top of each other
animation-duration: (10*$i)+(s); // each layer will have a different speed
opacity: (.25*$i); // clouds close to the camera will be more transparent
background-repeat: repeat-x; // use repeat-x to create an infinite background-scroll
@fgilio
fgilio / axios-catch-error.js
Last active April 11, 2024 19:02
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@coderbyheart
coderbyheart / import-to-contentful.js
Created May 30, 2017 14:21
Import jekyll content for contenful
const glob = require('glob')
const fs = require('fs')
const parser = require('jekyll-markdown-parser')
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '…'
})
// This API call will request a space with the specified ID

The problem with SASS mixins*

  1. mixins with SASS can balloon your css files quickly.
  2. mixins stop it being clear where stuff came from (can't search for class names for instance).

WARNING: The below is pseudo-code as I'm too lazy to double-check the APIs, output etc:

@mixin flexThing {
  color: red;
@nabilfreeman
nabilfreeman / lambda-redirect-to-trailing-slash.js
Last active March 7, 2023 20:31
Redirect to trailing slashes on CloudFront with AWS Lambda. (all this because S3 uses 302 redirects instead of 301)
'use strict';
const path = require('path')
const redirect = new_url => {
return {
status: '301',
statusDescription: 'Moved Permanently',
headers: {
location: [{
'use strict';
const pointsToFile = uri => /\/[^/]+\.[^/]+$/.test(uri);
exports.handler = (event, context, callback) => {
// Extract the request from the CloudFront event that is sent to Lambda@Edge
var request = event.Records[0].cf.request;
// Extract the URI from the request