Skip to content

Instantly share code, notes, and snippets.

View McKabue's full-sized avatar

Kabue Charles McKabue

View GitHub Profile
@McKabue
McKabue / jQuery plugin to dynamically register events on dynamically added items ondemand
Last active September 28, 2015 09:08
jQuery plugin to dynamically register events on dynamically added items ondemand
(function ($) {
$.fn.EventHandler = function (options) {
var defaults = $.extend({}, options), $element, $eventsArray = [], $activityArray = [];
$element = $(this);
if (options.onEvent.length != 0) {
if(options.startEvent){
@McKabue
McKabue / JSON Path
Created May 10, 2016 12:09
This is a javascript function that traverses a JSON object however deep it is... This is important when you want to do a search on each of the elements of an object, see here https://jsfiddle.net/kyk5zf6y/
var o = {
"firstName": "John",
"lastName" : "doe",
"age" : 26,
"arr":[1,2,3],
"address" : {
"streetAddress": "naist street",
"city" : "Nara",
"postalCode" : "630-0192"
},
@McKabue
McKabue / C# Pager On IEnumerable.cs
Last active September 24, 2018 12:15
C# Pager On IEnumerable
using System;
using System.Collections.Generic;
using System.Linq;
public static class Pager
{
/// <summary>
/// Pages the specified items.
@McKabue
McKabue / Knockout.js Custom Binding for Minimalist Developer Calendar.js
Last active January 6, 2017 14:45
+this is an lightweight, simple, extensible jQuery plugin that just outputs a calendar the way a developer wants. it supports templating, adding events, in short, THIS IS THE PLUGIN YOU REFER AND/OR EXTEND WHEN YOU WANT TO CREATE A FULLY GROWN CALENDAR
ko.bindingHandlers.kocalender = {
init: function (element, valueAccessor, allBindingsAccessor, viewModel) {
var value = valueAccessor(),
instanceOptions = $.extend({
previousYearSelector: ".previousyear",
nextYearSelector: ".nextyear",
previousMonthSelector: ".previousmonth",
nextMonthSelector: ".nextmonth",
eventTemplate: '<div data-id="{{id}}" class="event">{{name}}</div>',
dateCallbacks: [
@McKabue
McKabue / Vue.js Lessons and Features I would love to see.md
Last active March 15, 2018 08:43
`Vue.js Lessons and Features I would love to see` is a compilation of experiences from other similar frameworks. I really like the fact that vue.js keeps HTML as HTML, JavaScript as Javascript and CSS as CSS, Its flexible, Clean syntax, and its more of a library than a framework
@McKabue
McKabue / Get_All_Routes_in_ASP.NET_MVC_Core_2.cs
Last active May 11, 2023 07:16
Get all routes, including default routes specified at start up
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.Internal;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using System;
using System.Linq;
using System.Threading.Tasks;
type TemplateParameterType = { [key: string]: string };
/**
* If the template from @member CompiledRouteType.template
* is an object, this type will be extended with all the
* members of that object.
*/
type TemplateMatchResponseType = {
params: TemplateParameterType,
/**
@McKabue
McKabue / JavaScript_Fullscreen_Helper_Method.js
Last active May 13, 2018 08:50
JavaScript Fullscreen Helper Method
if (!Element.prototype.fullScreen) {
var full_screen = function (element) {
var self = this;
this.change = null;
var isFullScreen = this.isFullScreen = function () {
return (document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement) ? true : false;
};
this.requestFullScreen = function () { //https://stackoverflow.com/a/33768712
// Supports most browsers and their versions.
@McKabue
McKabue / How_to_set_min_font_size_in_CSS.css
Last active May 19, 2018 19:00
How to set min-font-size in CSS :: https://stackoverflow.com/a/37836926 . This is because the static part of calc() defines the minimum. Even though the dynamic part might shrink to something near 0.
font-size:calc(12px + 1.5vw);
/*
* How to set min-font-size in CSS
* https://stackoverflow.com/a/37836926
* This is because the static part of calc() defines the minimum.
* Even though the dynamic part might shrink to something near 0.
*/