Skip to content

Instantly share code, notes, and snippets.

@dotJoel
dotJoel / jsonb-search-predicate.java
Last active March 7, 2024 22:56
Using JPA, here is how I created a predicate that searches a JSONB column for any of the provided keys.
builder.equal(
builder.function(
"JSONB_EXISTS_ANY",
Boolean.class,
root.get("nameOfJsonbColumnToSearch"),
builder.function(
"string_to_array",
String.class,
builder.literal(String.join(",", setOfValuesToSearchFor)),
builder.literal(",")
<?php
/**
* Batch Mockup
*
* I placed this in my BaseController.php file
*
* @usage
* $batch = new Batch('stats');
* $batch->columns = ['score', 'name'];
* $batch->data = [
@dotJoel
dotJoel / all-colleges.txt
Created February 10, 2014 15:51
A list of all colleges in the United States
Abilene Christian University (TX)
Abraham Baldwin Agricultural College (GA)
Academy of Art University (CA)
Acadia University (None)
Adams State University (CO)
Adelphi University (NY)
Adrian College (MI)
Adventist University of Health Sciences (FL)
Agnes Scott College (GA)
AIB College of Business (IA)
@dotJoel
dotJoel / database.php
Last active December 29, 2015 13:59
Line needed in a CakePHP database config to use console commands on a Mac with XAMPP
'unix_socket' => '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock'
@dotJoel
dotJoel / google-webfonts.ttf.css
Last active February 19, 2024 18:43
CSS for all of Google's TTF web fonts
@font-face {
font-family: 'ABeeZee';
font-style: normal;
font-weight: 400;
src: local('ABeeZee'), local('ABeeZee-Regular'), url(http://themes.googleusercontent.com/static/fonts/abeezee/v1/JYPhMn-3Xw-JGuyB-fEdNA.ttf) format('truetype');
}
@font-face {
font-family: 'Abel';
font-style: normal;
font-weight: 400;
@dotJoel
dotJoel / google-webfonts.css
Created August 15, 2013 21:41
Minified copy of the CSS for all of Google's WOFF web fonts, as of Aug 12, 2013
/*
Document : google-webfonts
Created on : Aug 12, 2013, 5:24:59 PM
Author : Joel Byrnes <joel@buildrr.com>
Description: Minified copy of the CSS for all of Google's web fonts, as of Aug 12, 2013
*/
@font-face{font-family:'ABeeZee';font-style:normal;font-weight:400;src:local('ABeeZee'),local('ABeeZee-Regular'),url(http://themes.googleusercontent.com/static/fonts/abeezee/v1/m_J3nYLkIiGqm2wAiy01kg.woff) format('woff')}
@font-face{font-family:'Abel';font-style:normal;font-weight:400;src:local('Abel'),local('Abel-Regular'),url(http://themes.googleusercontent.com/static/fonts/abel/v3/EAqh528fFdbUek8UOky4sA.woff) format('woff')}
@font-face{font-family:'Abril Fatface';font-style:normal;font-weight:400;src:local('Abril Fatface'),local('AbrilFatface-Regular'),url(http://themes.googleusercontent.com/static/fonts/abrilfatface/v5/X1g_KwGeBV3ajZIXQ9VnDvn8qdNnd5eCmWXua5W-n7c.woff) format('woff')}
@font-face{font-family:'Aclonica';font-style:normal;font-weight:400;src:local('Aclonica'),local('Aclonica
@dotJoel
dotJoel / googleFonts.array.php
Last active June 9, 2018 07:30
A PHP array of the names of every Google web font, as of Aug 12, 2013
<?php
$googleFonts = array('ABeeZee', 'Abel', 'Abril Fatface', 'Aclonica', 'Acme', 'Actor', 'Adamina', 'Advent Pro', 'Aguafina Script', 'Akronim', 'Aladin', 'Aldrich', 'Alef', 'Alegreya', 'Alegreya SC', 'Alex Brush', 'Alfa Slab One', 'Alice', 'Alike', 'Alike Angular', 'Allan', 'Allerta', 'Allerta Stencil', 'Allura', 'Almendra', 'Almendra Display', 'Almendra SC', 'Amarante', 'Amaranth', 'Amatic SC', 'Amethysta', 'Anaheim', 'Andada', 'Andika', 'Angkor', 'Annie Use Your Telescope', 'Anonymous Pro', 'Antic', 'Antic Didone', 'Antic Slab', 'Anton', 'Arapey', 'Arbutus', 'Arbutus Slab', 'Architects Daughter', 'Archivo Black', 'Archivo Narrow', 'Arial Black', 'Arial Narrow', 'Arimo', 'Arizonia', 'Armata', 'Artifika', 'Arvo', 'Asap', 'Asset', 'Astloch', 'Asul', 'Atomic Age', 'Aubrey', 'Audiowide', 'Autour One', 'Average', 'Average Sans', 'Averia Gruesa Libre', 'Averia Libre', 'Averia Sans Libre', 'Averia Serif Libre', 'Bad Script', 'Balthazar', 'Bangers', 'Basic', 'Battambang', 'Baumans', 'Bayon', 'Belgrano', 'Bell MT'
@dotJoel
dotJoel / bootSlide.js
Created July 11, 2013 19:48
jQuery snippet that makes bootstrap's dropdown menus slide. stolen from: https://gist.github.com/jalcine/3013002#comment-840867
$(document).ready(function() {
$('.navbar .dropdown').hover(function() {
$(this).find('.dropdown-menu').first().stop(true, true).delay(250).slideDown();
}, function() {
$(this).find('.dropdown-menu').first().stop(true, true).delay(100).slideUp();
});
});
@dotJoel
dotJoel / arrayMerge.php
Last active October 13, 2015 01:18
Merge items in an array based on a subkey, such as quantity
<?php
foreach ($items as $item) {
if (!isset($mergedItems['key']) {
$mergedItems[$item['key']] = $item;
} else {
$mergedItems[$item['key']]['subKey'] += $item['subKey'];
}
}