Skip to content

Instantly share code, notes, and snippets.

View jmsmrgn's full-sized avatar
🚀

James Morgan jmsmrgn

🚀
View GitHub Profile
@hughrawlinson
hughrawlinson / spotify_platform_oauth.sh
Last active January 28, 2024 02:49
Authenticate and get an oauth token for your Spotify app from the command line
#!/bin/bash
# spotify_platform_oauth.sh
#
# A script to quickly and easily generate Spotify oauth tokens given a client
# id, secret, and scope. Will authenticate a user via the browser.
# The app must have "http://localhost:8082/' as a redirect_uri
# spotify_client_creds.json should contain a spotify client id and secret pair
@nurbek-ab
nurbek-ab / functions.php
Last active April 5, 2021 10:59
Change wordpress search results permalink (base url, search base).
<?php
function nice_search_redirect() {
global $wp_rewrite;
if ( !isset( $wp_rewrite ) || !is_object( $wp_rewrite ) || !$wp_rewrite->using_permalinks() )
return;
$search_base = $wp_rewrite->search_base;
if ( is_search() && !is_admin() && strpos( $_SERVER['REQUEST_URI'], "/{$search_base}/" ) === false ) {
wp_redirect( home_url( "/{$search_base}/" . urlencode( get_query_var( 's' ) ) ) );
exit();
@paulirish
paulirish / what-forces-layout.md
Last active April 30, 2024 17:56
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
<?php
/**
* Method of listing upcoming events, complete with functional pagination
* if WP-PageNavi is installed.
*
* Implemented as a shortcode.
*
* @see https://wordpress.org/plugins/wp-pagenavi/
*/
function do_easy_event_list() {
@chrissimpkins
chrissimpkins / gist:5bf5686bae86b8129bee
Last active March 6, 2023 00:10
Atom Editor Cheat Sheet: macOS

Use these rapid keyboard shortcuts to control the GitHub Atom text editor on macOS.

Key to the Keys

  • ⌘ : Command key
  • ⌃ : Control key
  • ⌫ : Delete key
  • ← : Left arrow key
  • → : Right arrow key
  • ↑ : Up arrow key
@grncdr
grncdr / data.csv
Created June 17, 2015 22:29
Demo of importing a CSV file into a Contentful space
first name last name age
Stephen Sugden 31
Tom Reznik 29
Justin Thomas 30
@chantastic
chantastic / on-jsx.markdown
Last active March 20, 2024 01:03
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't

@paulirish
paulirish / bling.js
Last active May 1, 2024 19:56
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@seanmcn
seanmcn / gist:62a021a765ad4f8e593b
Last active February 21, 2024 11:57
The Perfect Web Server - Nginx, Ajenti, Ubuntu
#Insall Ajenti
apt-get update
wget http://repo.ajenti.org/debian/key -O- | apt-key add -
echo "deb http://repo.ajenti.org/ng/debian main main ubuntu" >> /etc/apt/sources.list
apt-get update
apt-get install ajenti
service ajenti restart
# Uninstall Apache2
sudo apt-get autoremove && sudo apt-get remove apache2*
@bobbygrace
bobbygrace / trello-css-guide.md
Last active April 22, 2024 10:15
Trello CSS Guide

Hello, visitors! If you want an updated version of this styleguide in repo form with tons of real-life examples… check out Trellisheets! https://github.com/trello/trellisheets


Trello CSS Guide

“I perfectly understand our CSS. I never have any issues with cascading rules. I never have to use !important or inline styles. Even though somebody else wrote this bit of CSS, I know exactly how it works and how to extend it. Fixes are easy! I have a hard time breaking our CSS. I know exactly where to put new CSS. We use all of our CSS and it’s pretty small overall. When I delete a template, I know the exact corresponding CSS file and I can delete it all at once. Nothing gets left behind.”

You often hear updog saying stuff like this. Who’s updog? Not much, who is up with you?