Skip to content

Instantly share code, notes, and snippets.

@CosAnca
CosAnca / wordpress-missing-assets
Created October 21, 2018 18:42 — forked from ryanburnette/wordpress-missing-assets
When I'm using Vagrant for local WordPress development I hate having to move the production assets to the local development environment. This Nginx snippet looks for missing local assets at the production URL.
location ~ ^(.*)\/wp-content\/uploads\/(.*)$ {
try_files $uri @missing;
}
location @missing {
rewrite "^(.*)/wp-content/uploads/(.*)$" "http://production-url.com$1/wp-content/uploads/$2" redirect;
}
@CosAnca
CosAnca / ask.sh
Created October 6, 2018 11:18
Bash General-Purpose Yes/No Prompt Function ("ask")
# This is a general-purpose function to ask Yes/No questions in Bash, either
# with or without a default answer. It keeps repeating the question until it
# gets a valid answer.
ask() {
# https://gist.github.com/davejamesmiller/1965569
local prompt default reply
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
@CosAnca
CosAnca / README.md
Created September 16, 2018 11:23 — forked from elijahmanor/README.md
Has Deprecated Packages

Feel free to run via...

npx https://gist.github.com/elijahmanor/4cc8e3eac9fb5999c5d759388ff27c64

@CosAnca
CosAnca / _spacing-helpers.scss
Created August 31, 2018 21:46 — forked from jacurtis/_spacing-helpers.scss
SASS Margin and Padding Helpers Loop. Generates .m-t-10 type helper classes.
/*
This .scss loop will create "margin helpers" and "padding helpers" for use in your web projects.
It will generate several classes such as:
.m-r-10 which gives margin-right 10 pixels.
.m-r-15 gives MARGIN to the RIGHT 15 pixels.
.m-t-15 gives MARGIN to the TOP 15 pixels and so on.
.p-b-5 gives PADDING to the BOTTOM of 5 pixels
.p-l-40 gives PADDING to the LEFT of 40 pixels
@CosAnca
CosAnca / pseudo_elements.md
Created August 20, 2018 12:45 — forked from p3t3r67x0/pseudo_elements.md
A CSS pseudo-element is used to style specified parts of an element. In some cases you can style native HTML controls with vendor specific pseudo-elements. Here you will find an list of cross browser specific pseudo-element selectors.

Styling native elements

Native HTML controls are a challenge to style. You can style any element in the web platform that uses Shadow DOM with a pseudo element ::pseudo-element or the /deep/ path selector.

video::webkit-media-controls-timeline {
  background-color: lime;
}

video /deep/ input[type=range] {
# Install the hostsupdater:
# vagrant plugin install vagrant-hostsupdater
# Place the following code into $HOMESTEAD/scripts/homestead.rb
# I placed it somewhere near end of the file
# Add the aliases to the host machine
if Vagrant.has_plugin?('vagrant-hostsupdater')
aliases = Array.new
settings["sites"].each do |site|
@CosAnca
CosAnca / ie-edge.scss
Created June 8, 2018 08:05
IE and Edge browsers support in CSS
// For IE 9 and lower, load a conditional stylesheet:
// <!--[if IE]>
// <link rel="stylesheet" type="text/css" href="ie.css" />
// <![endif]-->
// IE 10 and up doesn't support this, so you have to use media queries:
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
/* IE10+ CSS */
@CosAnca
CosAnca / grid.scss
Created May 25, 2018 23:51 — forked from eddiemoore/grid.scss
SASS Loop to generate CSS column classes
$total-columns: 6;
$col-widths: ();
@for $i from 1 through $total-columns {
@for $j from 1 through $i {
$w: ($j/$i);
@if not index($col-widths, $w) {
.col-#{$j}-#{$i} {
width: $w * 100%;
@CosAnca
CosAnca / .deployment
Created May 22, 2018 12:48 — forked from ulrikstrid/.deployment
create-react-app azure deploy
[config]
command = bash deploy.sh
@CosAnca
CosAnca / git-sparse-checkout.sh
Created February 27, 2018 16:26
Checkout only a single directory or file from a Git repo
#!/bin/bash
DIR="/my-site"
REPO="git@github.com:username/repository.git"
BRANCH="master"
CHECKOUT_DIR="source/"
mkdir -p $DIR
if [ -d "$DIR" ]; then
cd $DIR