Skip to content

Instantly share code, notes, and snippets.

View juristr's full-sized avatar

Juri Strumpflohner juristr

View GitHub Profile
@juristr
juristr / index.html
Created June 27, 2018 12:58
Geolocation tests
<html>
<body>
<button id="gpsStart">Start</button>
<button id="gpsStop">Stop</button>
<button id="checkStatus">Status</button>
<div id="log"></div>
<script>
(function () {
var old = console.log;
@juristr
juristr / README.md
Last active May 30, 2018 08:37
Plunker - Angular v5 configuration

Plunker with Angular v5

Unfortunately when you create a new Plunker demo, the files are imported in a way from NPM to always take the latest version. This is good in a way and bad in another as now with the release of Angular version 6 & RxJS 6 most Plunkers simply break.

Option 1: Upgrade your Plunks

The best option is to upgrade and give your users/readers the latest and greatest stuff Angular version 6 and RxJS version 6 provide.

Option 2: Patch your Plunks

@juristr
juristr / gist:9b10ffb06488eecd8d25
Last active August 29, 2015 14:27
GitHub Issue Badges

Classifying good PRs/Issues

As I briefly highlighted in my blog post about how to properly create a GitHub PR, a good bug report or PR contains an automated test that reproduces the issue.

OSS tip: If you want a bug fixed faster, submit a PR with a failing test rather than an issue.

— Sindresaurus (@sindresorhus) March 21, 2015
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

Especially newcomers might not know about this. Kent C. Dodds does already invest a lot in trying to get newcomers to submit PRs.

@juristr
juristr / gist:fee92f837c4c5d32847a
Last active August 29, 2015 14:10
Render some JSON

Disclaimer: I'm not a Java expert, so please provide me some enhanced version if mine is suboptimal!

What I want to achieve is to render the following "static" JSON:

{
  "errors": [
    { "name": "Server said this field is required" },
    { "name": "Oh...and this one failed as well" }
 ]
@juristr
juristr / gist:15e5bf322f7c06be64bb
Created November 26, 2014 15:30
Requirejs - model-factory
/*jshint unused: vars */
require.config({
paths: {
sinon: '../../bower_components/sinon/lib/sinon',
'sass-bootstrap': '../../bower_components/sass-bootstrap/dist/js/bootstrap',
metisMenu: '../../bower_components/metisMenu/dist/metisMenu',
jquery: '../../bower_components/jquery/dist/jquery',
'angular-ui-router': '../../bower_components/angular-ui-router/release/angular-ui-router',
'angular-translate-loader-partial': '../../bower_components/angular-translate-loader-partial/angular-translate-loader-partial',
'angular-translate': '../../bower_components/angular-translate/angular-translate',
@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>
@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 / 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 / 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 / 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=?