Skip to content

Instantly share code, notes, and snippets.

View juristr's full-sized avatar

Juri Strumpflohner juristr

View GitHub Profile
@juristr
juristr / Gruntfile.js
Last active December 23, 2015 07:18
Grunt development server
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.initConfig({
connect: {
server: {
options: {
port: 8000,
base: '.',
@juristr
juristr / validation.html
Created September 18, 2013 11:58
Validation error messages with Bootstrap 3
<div class="col-md-2 form-group has-error">
<label class="mandatory control-label" for="txtResidenceCAP">[lblResidenceCAP]<abbr>(*)</abbr></label>
<input class="form-control" type="text" id="txtResidenceCAP" name="residenceCap" value="38025" placeholder="[phResidenceCAP]">
<span for="txtResidenceCAP" generated="true" class="help-block" style="display: inline;">Value required!</span>
</div>
@juristr
juristr / modelevent.js
Created September 19, 2013 07:20
jmvc model events
// 1st param is the class, 2nd the jQuery.Event and 3rd the actual instance containing the data
"{Pensplan.Models.Member} updated": function (Member, ev, memberInstance) {
...
}
@juristr
juristr / hidenavbar.js
Created December 23, 2013 20:41
This script hides the navbar '.js-navbar' when scrolling downwards on a page and shows it again when scrolling upwards. Used this on my blog for articles and hiding the top-navbar.
/*
This script hides the navbar '.js-navbar'
when scrolling downwards on a page and shows it again
when scrolling upwards
*/
$(function(){
var $nav = $('.js-navbar'),
_hideShowOffset = 20,
_lastScroll = 0,
_detachPoint = 50;
@juristr
juristr / upgradewebapi.md
Last active August 29, 2015 13:56
Upgrade Gist

Upgrade WebApi beta to latest

Upgrading through the NuGet package manager is a pain

Therefore, I followed these steps

Create a new WebApi template project

@juristr
juristr / gist:10451546
Last active August 29, 2015 13:59
Dapper ODBC QueryMultiple Error
/*
Pieces of code that is being executed
*/
// our variable holding the query
private static string QUERY_ADMISSION_PERSONAL_DATA =
@"
SELECT QCLCOGNO as LastName, QCLNOME as FirstName, QCLLINGUA as PrintLanguage FROM JXPLURIF.QUADCL00F WHERE QCLDONUM=?
@juristr
juristr / new_gist_file.vbs
Created May 1, 2014 20:36
VBA script to extract birth date + gender...from a fiscal code
Private Sub doExtraction() Cells(2, 10).Activate Do While ActiveCell.Offset(0, -9).Text <> "" Dim fiscal fiscal = ActiveCell.Value If Len(fiscal) = 16 Then ActiveCell.Offset(0, 1).Value = ExtractGender(fiscal) ActiveCell.Offset(0, 2).Value = ExtractBirthdate(fiscal) End If ActiveCell.Offset(1, 0).Activate Loop End Sub Private Function ExtractGender(ByVal fiscalcode As String) Dim genderDay genderDay = Mid(fiscalcode, 10, 2) If genderDay > 40 Then ExtractGender = "W" Else ExtractGender = "M" End If End Function Private Function ExtractBirthdate(ByVal fiscalcode As String) Dim month, months, day, year As String months = "ABCDEHLMPRST" fiscalMonthIdx = Mid(fiscalcode, 9, 1) month = InStr(months, fiscalMonthIdx) day = Mid(fiscalcode, 10, 2) day = day Mod 40 year = Mid(fiscalcode, 7, 2) ExtractBirthdate = day & ".
@juristr
juristr / ContextUtil.cs
Created May 30, 2014 16:43
Helper class for testing WebApi action filters
internal static class ContextUtil
{
public static HttpControllerContext CreateControllerContext(HttpConfiguration configuration = null, IHttpController instance = null, IHttpRouteData routeData = null, HttpRequestMessage request = null)
{
HttpConfiguration config = configuration ?? new HttpConfiguration();
IHttpRouteData route = routeData ?? new HttpRouteData(new HttpRoute());
HttpRequestMessage req = request ?? new HttpRequestMessage();
req.SetConfiguration(config);
req.SetRouteData(route);
@juristr
juristr / browsehappy.html
Created June 27, 2014 13:57
Browse Happy
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
@juristr
juristr / restrictDirective.html
Created November 6, 2014 13:09
Restrict directive
<!doctype html>
<html ng-app="myApp">
<head>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css">
</head>
<body>
<h1>Tests</h1>
<p>You shouldn't see the text below:</p>
<div restrict grants="admin">Hi there</div>