Skip to content

Instantly share code, notes, and snippets.

@jmosbech
jmosbech / border-collapse.patch
Created June 6, 2012 19:12
border-collapse.patch
js/jquery.stickytableheaders.js | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/js/jquery.stickytableheaders.js b/js/jquery.stickytableheaders.js
index 281af35..f4fd91e 100644
--- a/js/jquery.stickytableheaders.js
+++ b/js/jquery.stickytableheaders.js
@@ -87,16 +87,23 @@
};
@jmosbech
jmosbech / sanitizeFilename.js
Last active December 12, 2015 07:08
first go at a filename santitizer that supports non ascii chars
function sanitizeFilename (filename){
var blacklist = /[^\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF0-9a-z'\s\-_]/gi;
return filename.replace(blacklist, '').trim().substring(0, 200); // 200 should be more than enough, but still safe
}
@jmosbech
jmosbech / Exec-Sproc.ps1
Created May 26, 2013 19:40
Executes a Stored Procedure from Powershell and returns the first output DataTable
# Executes a Stored Procedure from Powershell and returns the first output DataTable
function Exec-Sproc{
param($Conn, $Sproc, $Parameters=@{})
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandType = [System.Data.CommandType]::StoredProcedure
$SqlCmd.Connection = $Conn
$SqlCmd.CommandText = $Sproc
foreach($p in $Parameters.Keys){
[Void] $SqlCmd.Parameters.AddWithValue("@$p",$Parameters[$p])
@jmosbech
jmosbech / array-upsert.js
Created August 22, 2013 06:30
attempt to emulate the missing support for mongo array upserts
// mongo array upsert
mongo('settings').update({'authorizations._id': {$ne: app._id}}, {$push: {'authorizations': app}}, {safe: true, 'new': true}, function(err, newSettings){
if (err) {
return callback(err);
}
if (!newSettings) {
return mongo('settings').update({'authorizations._id': app._id}, {$set: {'authorizations.$': app}}, {safe: true}, callback);
}
callback();
});
@jmosbech
jmosbech / centered-with-footer.html
Created August 24, 2013 19:50
vertically centered block with sticky footer and a minimum-height.
@jmosbech
jmosbech / screenshot.applescript
Last active January 3, 2016 19:09
Trigger Monosnap's Capture Area shortcut (`⌥⌘5`)
tell application "System Events"
key code 23 using {option down, command down}
end tell
@jmosbech
jmosbech / webstorm-jsx.md
Created January 25, 2014 23:09
WebStorm and JSX

Webstorm and JSX

@jmosbech
jmosbech / wstorm
Last active September 11, 2017 22:27
Windows command line shortcut to WebStorm. Clone, add to path, celebrate!
#!/bin/sh
# find newest webstorm install
WS=`find /C/Program\ Files\ \(x86\)/JetBrains/*/bin/webstorm.exe -type f -printf '%T@ %p\n' | sort -r | sed 's/^[^ ]* //' | head -n 1`
# open current dir
DIR=`pwd`
`"$WS" "$DIR"` &
@jmosbech
jmosbech / get-jira-items.sh
Created November 14, 2014 11:35
Find JIRA items in Git commits
#!/bin/sh
RANGE=$1
git log --grep="[A-Z]\+-[0-9]\+" --format=%s $RANGE \
| awk 'match($0, /[A-Z]+-[0-9]+/) {print substr($0, RSTART, RLENGTH)}' \
| sort -t "-" -k1,1 -k2,1n \
| uniq