Skip to content

Instantly share code, notes, and snippets.

View blizzrdof77's full-sized avatar

Ben Wagner blizzrdof77

View GitHub Profile
@josephabrahams
josephabrahams / histdel.sh
Created November 3, 2014 22:30
Delete previous line in .bash_history
#!/bin/sh
hist=$(history | tail -1 | awk '{ print $1 }'); history -d $hist; history -d $(expr $hist - 1); unset hist
@Jacob-Vlijm
Jacob-Vlijm / paste_snippets.py
Last active September 22, 2015 23:20
Script to paste textual snippets in applications that past with the key combination Ctrl+V. It needs xsel and xdotool to be installed
#!/usr/bin/env python3
"""
Copyright (C) 2014 Jacob Vlijm
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or any later version. This
program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. You
@lunelson
lunelson / post.md
Last active October 27, 2016 22:18
The Self-Aware Sass Mixin

I did a talk the other night at Up Front Berlin about some use cases for features in Sass from the past year. The slides are here; but I wanted to publish some notes so this post is one part of those notes.

My talk focused on the map data-type, and specifically on combining maps with directives such as @content, @at-root, and unique-id() in interesting ways. One of these is a mixin design pattern that solves some problems with using @extendand placeholder (silent) selectors in Sass:

  1. having placeholder extensions appear somewhere way up in the top of your code, because that's where you imported them; and
  2. having to think about choosing @include vs. @extend in the first place.

This "self-aware" mixin works by creating (and extending) a placeholder selector for itself dynamically, the first time it is included, and uses a map to keep records of these includes, so when it is subsequently in

@calebgrove
calebgrove / stateToAbbr.js
Last active April 24, 2024 22:18
Convert state name to abbreviation in JavaScript. There's some better solutions in the comments, so scroll down!
// There's some better solutions in the comments, so scroll down and see how other folks have improved this!
// USAGE:
// abbrState('ny', 'name');
// --> 'New York'
// abbrState('New York', 'abbr');
// --> 'NY'
function abbrState(input, to){
@kemelzaidan
kemelzaidan / ssh-copy-id.sh
Created September 17, 2014 22:04
This is a simple bash script to reproduce ssh-copy-id behavior on the Mac OS, since this shit OS doesn't have it natively.
#!/bin/bash
# This is a simple shell script to reproduce ssh-copy-id behavior
# on the MAC, since that shit OS does not have it natively.
#
# This script is under GPL version 3
# Author: Kemel Zaidan
# email: kemelzaidan AT gmail DOT com
# website: kemelzaidan.com.br
#
@thagxt
thagxt / wp-get-user-reg-date.php
Created September 7, 2014 12:01
WordPress get user registration date on author page
<?php
$user_id = get_the_author_meta('ID');
echo date("D M Y", strtotime(get_userdata($user_id)->user_registered));
?>
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@mandiwise
mandiwise / Limit Gravity Forms Upload Size
Last active January 16, 2022 14:12
Set a maximum upload size for a Gravity Forms image field
function limit_file_upload_size( $validation_result ) {
$form = $validation_result['form'];
foreach( $form['fields'] as &$field ){
// NOTE: Add a custom CSS class to your image upload field and grab onto it here...
if( strpos( $field['cssClass'], 'choose-file' ) === false )
continue;
@ihorvorotnov
ihorvorotnov / wp-get-content
Created February 21, 2014 11:20
WordPress: get post content by ID
/**
* You often need to get the content or title from a specific post.
* Sometimes, using a custom loop is the better option, but when you only need
* to get information from a specific post, there’s a better option
*/
echo get_post_field('post_content', $post_id);
@matthewpizza
matthewpizza / install-composer.sh
Created February 13, 2014 03:55
Install Composer on Webfaction
cd $HOME
ln -s `which php54` ~/bin/php
export PATH=$HOME/bin:$PATH
curl -sS https://getcomposer.org/installer | php54
echo -e "\n# Composer\nalias composer=\"php54 \$HOME/composer.phar\"" >> $HOME/.bash_profile
source $HOME/.bash_profile