Skip to content

Instantly share code, notes, and snippets.

View cerkit's full-sized avatar

cerkit cerkit

View GitHub Profile
@cerkit
cerkit / modifyVectorMapBorder.html
Last active June 1, 2016 13:24
Modify the border on a DevExtreme dxVectorMap widget using jQuery
<div id="mapContainer"></div>
<script type="text/javascript">
// attach map to mapContainer
var map = $("#mapContainer").dxVectorMap({
// config goes here...
}).dxVectorMap('instance');
// remove the border around the map
$("#mapContainer").children("svg:first").children("rect:first").attr("stroke-width", "0");
@cerkit
cerkit / UseAsOrCast.cs
Last active March 28, 2016 22:17
I have a dilemma. Should I use line 4, 8, 12, or 16?
// Dilemma, should I use this code:
// NOTE: existingJobDetail.Id is defined as a regular (non-nullable) int.
int? parentJobDetailId = existingJobDetail != null ? existingJobDetail.Id as int? : null;
// Or this code:
int? parentJobDetailId = existingJobDetail != null ? (int?)existingJobDetail.Id : null;
// Or (less likely):
@cerkit
cerkit / SampleMarkdownWithCodeProblem.cs
Created March 24, 2016 16:41
Markdown with code embedded in a <pre /> tag.
<pre class="line-numbers"><code class="language-csharp">static void Main(string[] args)
{
for (int i = 0; i < 10; i++)
{
// toggle between words and paragraphs
bool isEven = (i % 2) == 0;
bool isThird = (i % 3) == 0;
LipsumType lipsumType = isEven ? LipsumType.Paragraphs : LipsumType.Words;
// only start with Lorem Ipsum every third call
@cerkit
cerkit / link-to-icon-mapper.js
Last active February 16, 2016 16:45
This code is used to add Font Awesome fonts to dynamically generated navigation links based on a link-to-icon map. To use this code, make sure you have a reference to Font Awesome (http://fontawesome.io) and jQuery.
@cerkit
cerkit / bootstrap_merged_menu_example.php
Last active January 2, 2016 00:44
Bootstrap Navbar on WordPress with merged menus
<nav id="top-navbar" class="navbar navbar-default navbar-fixed-top" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/" rel="home">
@cerkit
cerkit / FizzBuzz.cs
Last active December 2, 2015 17:48
Proof that I can write code :)
for (int i = 1; i <= 100; i++)
{
if ((i % 3 == 0) && (i % 5 == 0))
{
Debug.WriteLine("FizzBuzz");
}
else if (i % 3 == 0)
{
Debug.WriteLine("Fizz");
}
<!DOCTYPE html>
<html>
<head>
<title>Settings page for Pebble</title>
<meta charset="utf-8" />
<link href="../Content/bootstrap.min.css" rel="stylesheet" />
<link href="../Content/Site.css" rel="stylesheet" />
<script src="../Scripts/bootstrap.min.js"></script>
</head>
<body>
@cerkit
cerkit / HTML Entities
Last active August 29, 2015 14:21
HTML Entities for parsing HTML within an XML parser (Like .NET System.Xml.XmlDocument)
<!DOCTYPE root [
<!ENTITY Aacute "&#193;">
<!ENTITY aacute "&#225;">
<!ENTITY Abreve "&#258;">
<!ENTITY abreve "&#259;">
<!ENTITY ac "&#8766;">
<!ENTITY acd "&#8767;">
<!ENTITY Acirc "&#194;">
<!ENTITY acirc "&#226;">
<!ENTITY acute "&#180;">
@cerkit
cerkit / SampleController.js
Created September 23, 2014 17:12
AngularJS Client for Basic Authentication - SampleController
var baseUrl = 'http://localhost:49587/api';
angular.module('app').controller('SampleController', function ($scope, $http, $cookieStore, Base64) {
$scope.refreshData = function () {
//Used to display the data
if ($cookieStore.get('basicCredentials'))
{
$http.defaults.headers.common['Authorization'] = 'Basic ' + $cookieStore.get('basicCredentials');
}
@cerkit
cerkit / CredentialsController.js
Created September 23, 2014 17:11
AngularJS Client for Basic authentication - Credentials Controller
function CredentialsController($scope, $http, $cookieStore, Base64) {
$scope.login = function (userName, password) {
var encodedUserNameAndPassword = Base64.encode(userName + ':' + password);
$http.defaults.headers.common['Authorization'] = 'Basic ' + encodedUserNameAndPassword;
$cookieStore.put('basicCredentials', encodedUserNameAndPassword);
$http.get(baseUrl + '/Values')
.success(function() {
$scope.$broadcast('event:auth-loginConfirmed');
$scope.password = '';
})