Skip to content

Instantly share code, notes, and snippets.

View TangChr's full-sized avatar

Christian Tang TangChr

View GitHub Profile
@TangChr
TangChr / datepicker-da.js
Last active February 27, 2021 15:29
jQuery: Danish localization of the jQuery UI Datepicker
(function($){
$.ui.datepicker.regional['da'] = {
closeText: 'Luk',
prevText: '<Forrige',
nextText: 'Næste>',
currentText: 'I dag',
monthNames: ['januar','februar','marts','april','maj','juni',
'juli','august','september','oktober','november','december'],
monthNamesShort: ['jan','feb','mar','apr','maj','jun',
'Jul','Aug','sep','okt','nov','dec'],
@TangChr
TangChr / file_info.php
Last active November 21, 2015 12:58
PHP: Read comment-based file-info
<?php
function get_file_info( $file ) {
$fp = fopen( $file, 'r' );
$data = fread( $fp, 8192 ); // get first 8kb
fclose( $fp );
// Capture all the header within first comment block
if( !preg_match( '!.*?/\*(.*?)\*/!ms', $data, $matches ) )
return array();
@TangChr
TangChr / WildcardMatching.cs
Last active November 21, 2015 12:57
C#: Match string with wildcard
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
namespace TangChr.Tools
{
public static class StringMatch
{
public static bool IsWildcardMatch(string search, string source)
{ // Wildcard: *
return Operators.LikeString(source, search, CompareMethod.Text);
@TangChr
TangChr / underline.htm
Last active November 21, 2015 12:59
CSS: Link with different color for underline
<!DOCTYPE html>
<html>
<head>
<title>Link Color</title>
</head>
<style>
body {
background: #2c3e50;
font-family: Arial, Verdana, sans-serif;
}
@TangChr
TangChr / ExtendForEach.cs
Created November 21, 2015 12:48
C#: Add condition to Extension Method .ForEach
using System;
using System.Collections.Generic;
using System.Linq;
namespace TangChr
{
public static class ExtendForEach
{
public static void ForEach<T>(this IEnumerable<T> collection, Action<T> action, Func<T, bool> condition)
{
@TangChr
TangChr / archive.html
Last active June 6, 2016 08:42
Liquid/Jekyll: Monthly Archive
<ul class="post-archive">
{% for p in site.posts %}
<li>
{% assign fdate = p.date | date: '%b %Y' %}
{% if cur_date != fdate %}
{% assign cur_date = fdate %}
<h3>{{ p.date | date: '%B, %Y' }}</h3>
{% endif %}
<a href="{{ p.url }}">{{ p.title }}</a>
</li>
@TangChr
TangChr / slated-corners.scss
Last active December 17, 2020 15:12
Slated corners with SASS
@mixin slated-top-left($size, $foreground, $background) {
content: '';
position: absolute;
width: 0;
top: 0;
left: 0;
border-top: $size solid $background;
border-right: $size solid $foreground;
}
@TangChr
TangChr / clean-jekyll.cmd
Created June 18, 2016 14:19
Batch: Delete all Jekyll-related files and folders created during run time
rmdir _site /s /q
rmdir .sass-cache /s /q
del Gemfile.lock
@TangChr
TangChr / .travis.yml
Last active March 2, 2017 15:57
Travis CI: Build and test Jekyll website using HTMLProofer
language: ruby
rvm: 2.3.3
branches:
only:
- master
script: bundle exec rake test
@TangChr
TangChr / aliases.txt
Last active July 20, 2019 16:18
Git Aliases
[alias]
ec = config --global -e
br = branch
sa = !git add --all
ca = !git add --all && git commit -m
up = !git pull --rebase --prune $@ && git submodule update --init --recursive
lrb = !git remote -v
co = checkout
cob = checkout -b
crb = !git cob $1 && git push origin -u