Skip to content

Instantly share code, notes, and snippets.

View Ovilia's full-sized avatar
:octocat:

Wenli Zhang Ovilia

:octocat:
View GitHub Profile
@Ovilia
Ovilia / 001.grammer.the.good.parts.01.js
Created February 14, 2013 08:14
JavaScript escape related string
// In JavaScript string, you don't need to escape /
var a = "a/b"; // will give "a/b"
// But if you use \, it can be escaped
var b = "a\/b"; // will also give "a/b"
// While \ should always be escaped
var c = "a\b"; // will give "a" since \b means a backspace,
// which does nothing special here
{% capture tags %}
{% for tag in site.tags %}
{{ tag[0] }}
{% endfor %}
{% endcapture %}
{% assign sortedtags = tags | split:' ' | sort %}
{% for tag in sortedtags %}
<div id="tag-{{ tag }}" class="tag-posts">
{% for post in site.posts %}
@Ovilia
Ovilia / 2014-07-15-jekyll-related-posts-without-plugin
Created July 15, 2014 16:04
Jekyll Related Posts without Plugin
@Ovilia
Ovilia / 2014-08-03-make-your-own-social-sharing-bar-with-jekyll-01
Created August 3, 2014 15:55
2014-08-03-make-your-own-social-sharing-bar-with-jekyll-01
{% assign tagStr = '' %}
{% for tag in page.tags %}
{% capture tagStr %}{{ tagStr }},{{ tag }}{% endcapture %}
{% endfor %}
@Ovilia
Ovilia / 2014-08-03-make-your-own-social-sharing-bar-with-jekyll-02
Created August 3, 2014 16:07
2014-08-03-make-your-own-social-sharing-bar-with-jekyll-02
{% capture url %}{{ site.url }}{{ page.url }}{% endcapture %}
{% if page.shortUrl != null %}
{% assign url = page.shortUrl %}
{% endif %}
@Ovilia
Ovilia / 2014-08-03-make-your-own-social-sharing-bar-with-jekyll-03.html
Last active August 29, 2015 14:04
2014-08-03-make-your-own-social-sharing-bar-with-jekyll-03
{% assign tagStr = '' %}
{% capture url %}{{ site.url }}{{ page.url }}{% endcapture %}
{% if page.shortUrl != null %}
{% assign url = page.shortUrl %}
{% for tag in page.tags %}
{% capture tagStr %}{{ tagStr }},{{ tag }}{% endcapture %}
{% endfor %}
{% endif %}
<hr />
<h4>Share This Post</h4>
@Ovilia
Ovilia / 2014-08-03-make-your-own-social-sharing-bar-with-jekyll-04.html
Created August 3, 2014 16:22
2014-08-03-make-your-own-social-sharing-bar-with-jekyll-04
<a href="https://twitter.com/intent/tweet?text={{ page.title }}&url={{ page.url }}&via=OviliaZhang"></a>
@Ovilia
Ovilia / 2014-08-04-replace-last-filter-for-jekyll-liquid-01.html
Created August 4, 2014 14:51
2014-08-04-replace-last-filter-for-jekyll-liquid-01
<a class="button view-source" href="https://raw.githubusercontent.com/Ovilia/blog/gh-pages/_posts/{{ page.url | append: '@' | replace: '/', '-' | remove_first: '-' | remove: '-@' }}.md" target="_blank">View Source on GitHub</a>
@Ovilia
Ovilia / sortings
Created June 10, 2015 12:59
Sorting Algorithms
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
//#define PRINT_RESULT
// insert sort: n * n
template <typename T>
void insertSort(int len, T* arr)
@Ovilia
Ovilia / SleepBot.js
Last active December 26, 2015 10:44
Analysize Sleeping Records from SleepBot
var fs = require('fs');
// SleepBot.csv is downloaded from https://mysleepbot.com
var lines = fs.readFileSync('SleepBot.csv').toString().split('\n');
var sumToSleep = 0;
var sumToAwake = 0;
var sumSleepMin = 0;