Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View bentedder's full-sized avatar

Ben Tedder bentedder

  • Smarsh
  • St Paul, MN
View GitHub Profile
@bentedder
bentedder / .block
Created March 19, 2018 14:49 — forked from guypursey/.block
Wrapping long labels with D3 v4 (sample data)
license: gpl-3.0
@bentedder
bentedder / chart.component.scss
Last active March 5, 2018 14:30
Stacked Bar Chart
#myChart {
.axis {
path {
stroke: #ccc;
}
text {
fill: #999;
font-size: 0.6rem;
}
}
@bentedder
bentedder / calendar.component.html
Last active August 13, 2019 07:01
calendar component angular 4
<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>

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
@bentedder
bentedder / list.component.html
Last active July 16, 2019 17:07
Pagination Component
<div>list of things</div>
<my-pagination
(goPage)="goToPage($event)"
(goNext)="onNext()"
(goPrev)="onPrev()"
[pagesToShow]="3"
[page]="page"
[perPage]="limit"
[count]="total"></my-pagination>
@bentedder
bentedder / bool query
Created March 30, 2017 13:18
Bool query
size: limit,
query: {
bool: {
must: {
multi_match: {
query: term,
fields: ['name', 'raw_name']
}
},
should: {
@bentedder
bentedder / Brew stuff
Last active December 7, 2016 16:43
brew mysql
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*
@bentedder
bentedder / app.js
Last active August 29, 2015 14:04
basic js pattern (with requirejs)
require(["thing"], function(Thing) {
var thing = new Thing({
place: "Chicago"
});
thing.runAround();
});
<?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
*/
/*
* 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';}\"";