Skip to content

Instantly share code, notes, and snippets.

View Swimburger's full-sized avatar
🍔
Creating full snack content

Niels Swimberghe Swimburger

🍔
Creating full snack content
View GitHub Profile
@Swimburger
Swimburger / index.html
Created September 28, 2015 21:32
Manual login with Google Auth in Angular Directive
<!doctype html>
<html lang="en" ng-app="app" ng-controller="MainController">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<google-sign-in-button on-sign-in="onSignIn(response)" g-client-id="CLIENTID.apps.googleusercontent.com"></google-sign-in-button>
<script src="https://apis.google.com/js/platform.js"></script>
@Swimburger
Swimburger / applicationHost.xdt
Created September 28, 2015 21:52
Add prerender to Azure Website through web.config and applicationHost.xdt with HTML5 mode on
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<proxy xdt:Transform="InsertIfMissing" enabled="true" preserveHostHeader="false"
reverseRewriteHostInResponseHeaders="false" />
<rewrite>
<allowedServerVariables>
<add name="X-Prerender-Token" xdt:Transform="InsertIfMissing" />
</allowedServerVariables>
</rewrite>
$('#calendar').clndr({
render: function (data) {
return renderCalendar(data);
}
});
}
function renderCalendar(data){
var html='',
i= 0,
day;
@Swimburger
Swimburger / app.js
Created November 5, 2015 20:40
A nice bootstrap jQuery Checkbox List-item with add control, demo: https://jsfiddle.net/1m38aha0/8/
(function () {
$.fn.checkList = function (options) {
var self = this,
checkedItems = options.checkedItems ? options.checkedItems.slice() : [], //take a copy
unCheckedItems = options.unCheckedItems ? options.unCheckedItems.slice() : [], //take a copy
valuePath = options.valuePath,
textPath = options.textPath;
this.addClass('list-group');
$('.js-table-checkable th :checkbox')
.off('click')
.on('change', function () {
var $this = $(this),
checked = $this.prop('checked'),
tr = $this.closest('.js-table-checkable')
.find('td :checkbox')
.prop('checked', checked)
.closest('tr');
if(checked){
@Swimburger
Swimburger / index.css
Last active May 9, 2016 19:45
Create a scroll container with an inset shadow to communicate to the user that there's more content. See http://jsbin.com/zatarofaxa/edit?html,css,output
*{
margin: 0;
padding: 0;
}
.outer{
height: 500px;
width: 100%;
overflow: scroll;
overflow-x: hidden;
}
@Swimburger
Swimburger / index.py
Created September 12, 2016 00:16
Find longest ordered substring in Python
longestOrderedPart = ''
randomString = 'ljdflkjdfabcdljfbcdxyzlsjmlkjqsmfslkjfqllldflsdlfsldmlsqmslfdk'
orderedPart = randomString[0]
# loop over randomString
for i in range(0, len(randomString) -1): #don't run over last character or nextCharacter will go outside of the bounds of the string
currentCharacter = randomString[i]
nextCharacter = randomString[i+1]
#if nextCharacter is bigger or equal than currentCharacter, than it was in correct order
@Swimburger
Swimburger / Google.cs
Last active June 12, 2020 13:45
Use access_type offline with the Google C# SDK to prevent the need to reauthenticate every hour
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Auth.OAuth2.Flows;
using Google.Apis.Auth.OAuth2.Requests;
using Google.Apis.Util.Store;
namespace YourNameSpace.Google
@Swimburger
Swimburger / EventEmitter.js
Last active October 26, 2016 14:49
How to have private instance variables in an ES2015 Class
function on(key, listener){
addEventListener(this.events, key, listener);
}
function off(key, listener){
if(listener) removeEventListener(this.events, key, listener);
else removeEventListeners(this.events, key);
}
function emit(key, eventArgs){
for(let listener of this.events[key]){
listener(eventArgs);
@Swimburger
Swimburger / index.html
Last active December 22, 2016 15:02
Keep multiple fields their value in sync using jquery (two way binding), see https://jsbin.com/zicocop/edit?html,js,output
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Two way binding</title>
</head>
<body>
<h1>Two way sync</h1>
<select id="month1">