Instantly share code, notes, and snippets.

View .block
license: gpl-3.0
View chart.component.scss
#myChart {
.axis {
path {
stroke: #ccc;
}
text {
fill: #999;
font-size: 0.6rem;
}
}
View calendar.component.html
<div class="calendar">
<div class="calendar-navs">
<div class="month-nav">
<button (click)="prevMonth()">&lt;</button>
<span class="p4">{{ currentDate.format('MMMM') }}</span>
<button (click)="nextMonth()">&gt;</button>
</div>
<div class="year-nav">
<button (click)="prevYear()">&lt;</button>
<span>{{ currentDate.format('YYYY') }}</span>
View JWT Overview.md

JSON Web Tokens

What they are

  • an open standard defining a compact and self-contained way for securely transmitting information between parties as a JSON object.

Why to use them

  • stateless sessions (load balancers, separated front and back-end)
  • easy logout
  • save on SQL queries to check user or permissions every request
View list.component.html
<div>list of things</div>
<my-pagination
(goPage)="goToPage($event)"
(goNext)="onNext()"
(goPrev)="onPrev()"
[pagesToShow]="3"
[page]="page"
[perPage]="limit"
[count]="total"></my-pagination>
View bool query
size: limit,
query: {
bool: {
must: {
multi_match: {
query: term,
fields: ['name', 'raw_name']
}
},
should: {
View Brew stuff
ps -ax | grep mysql
stop and kill any MySQL processes
brew remove mysql
brew cleanup
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/mysql*
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
View app.js
require(["thing"], function(Thing) {
var thing = new Thing({
place: "Chicago"
});
thing.runAround();
});
View btrollup.php
<?php
/*
Plugin Name: Rollup Posts
Plugin URI: http://www.bentedder.com
Description: Rollup posts from specific categories with styles
Version: 1.0
Author: Ben Tedder
Author URI: http://www.bentedder.com
License: GPL2
*/
View custom-search-form.php
/*
* This is used to override the WordPress search to ONLY search for a
* custom post type. I used it on a photographer's website (only wanted
* users to search for photo post types).
*
* I put this snippet somewhere in functions.php
*/
function bt_customize_search($form, $search_text, $button_text) {
$onfocus = " onfocus=\"if (this.value == '$search_text') {this.value = '';}\"";
$onblur = " onblur=\"if (this.value == '') {this.value = '$search_text';}\"";