Skip to content

Instantly share code, notes, and snippets.

View tcollins's full-sized avatar
👨‍🔧
...

Tim Collins tcollins

👨‍🔧
...
View GitHub Profile
@tcollins
tcollins / send-slack.sh
Created December 19, 2018 23:41
Shell script to send to a slack webhook
#!/bin/sh
### Usage ./send-slack.sh {TITLE} {TEXT} [Optional color hex value]
### Example ./send-slack.sh "Your Title Goes Here" "Text goes here" "#ff00ff"
TITLE=$1
TEXT=$2
COLOR=${3:-"#007dbc"}
INNER_TEMPLATE='{"color":"%s","title":"%s","fallback":"%s","text":"%s"}'
@tcollins
tcollins / gist:3b859c4cb8ec0055c47ddc779d1ba74c
Last active September 20, 2018 21:32
small-test-js-lib
function awesomeLibFunction(){
return 'this is so amazing'
}
var WIDGET_CHART_1 = {
buildChart: function(){
var self = WIDGET_CHART_1;
if(typeof Chart !== "undefined"){
self.doBuildChart();
}
else{
setTimeout(self.buildChart, 50);
console.log('widget-scripts-1.js is executing')
alert('It is working!')
@tcollins
tcollins / unzip-many-to-dir.sh
Created September 7, 2017 14:57
A simple bash script to unzip a directory of zip into separate directories based on the zip file name
FILES=zips/*.zip
for f in $FILES
do
DIRNAME=`basename $f .zip`
mkdir $DIRNAME
unzip $f -d $DIRNAME
done

Keybase proof

I hereby claim:

  • I am tcollins on github.
  • I am tcollins (https://keybase.io/tcollins) on keybase.
  • I have a public key ASBCBveVOc_48EH6yx5x9ngezYY3WwtNHp4J5GC4D2COcAo

To claim this, I am signing this object:

@tcollins
tcollins / -Spring-JPA-Dynamic-Query-With-Limit
Last active February 22, 2024 10:21
Spring Data JPA - Limit results when using Specifications without an unnecessary count query being executed
If you use the findAll(Specification, Pageable) method, a count query is first executed and then the
data query is executed if the count returns a value greater than the offset.
For what I was doing I did not need pageable, but simply wanted to limit my results. This is easy
to do with static named queries and methodNameMagicGoodness queries, but from my research (googling
for a few hours) I couldn't find a way to do it with dynamic criteria queries using Specifications.
During my search I found two things that helped me to figure out how to just do it myself.
1.) A stackoverflow question.
@tcollins
tcollins / evil.js
Created June 9, 2014 14:30
Evil javascript
alert('evil');
// Simple logger that will use firebug console log first if available, otherwise simply log to a div
// Requires jquery
// Usage L.log('log this text');
var L = {
logEnabled: true,
log: function(obj)
{
if(L.logEnabled){