Skip to content

Instantly share code, notes, and snippets.

Cheng Fan onlyurei

View GitHub Profile
@onlyurei
onlyurei / gource.sh
Last active Mar 3, 2018 — forked from XueshiQiao/gource.sh
Generate a MP4 Video for your Git project commits using Gource!
View gource.sh
# 1.install gource using HomeBrew
$ brew install gource
# 2.install avconv
git clone git://git.libav.org/libav.git
cd libav
# it will take 3-5 minutes to complie, be patient.
./configure --disable-yasm
make && make install
@onlyurei
onlyurei / .eslintrc.json
Created Jan 25, 2018
vue-prettier eslintrc example
View .eslintrc.json
{
"root": true,
"extends": [
"plugin:vue/recommended",
"groupon"
],
"plugins": [
"vue"
],
"parserOptions": {
View pagination.vue
<template>
<div v-if="length > 1" class="text-xs-center mt-5">
<v-pagination v-bind="{ length, totalVisible: totalVisibleResponsive, circle }"
v-model="page"/>
</div>
</template>
<script>
import { pagination, params } from '~/utils/mixins/pagination'
@onlyurei
onlyurei / nuxt-axios-cache.js
Created Sep 6, 2017 — forked from homerjam/nuxt-axios-cache.js
Simple plugin which decorates the community axios nuxt-module with an lru-cache
View nuxt-axios-cache.js
import hash from 'object-hash';
import sizeof from 'object-sizeof';
import lruCache from 'lru-cache';
const cacheEnabled = true;
const cacheMaxAge = 30 * 60 * 1000;
const cacheMaxSize = 128 * 1000 * 1000;
const getCacheKey = config => hash({
method: config.method,
View tire-size-calculator-manual.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="cache-control" content="no-cache" />
<meta name="robots" content="noindex, nofollow" />
<title>Tire Size Calculator Help</title>
</head>
@onlyurei
onlyurei / add-students-validation.js
Created Mar 21, 2016
Relevant JS snippet for add students validation.
View add-students-validation.js
if (exports.addStudentsValidNames().length) {
exports.addStudentsCheckingUsernames(true);
$.post('/classroom/check', {
students: JSON.stringify(exports.addStudentsValidNames())
}, function (data) {
var hasErrors;
data.each(function (i) {
i.transfer = ko.observable(null);
i.errorFields = [];
i.warningFields = [];
@onlyurei
onlyurei / add-students.html
Created Mar 21, 2016
Demonstrating backend form validations.
View add-students.html
<!-- ko ifnot: $parent.addStudentsModalEditingMode -->
<!-- ko ifnot: $parent.addStudentsShowExistingUsernameScreen -->
<h2 data-bind="string: 'confirm.new.students'" class="pull-left"></h2>
<div class="pull-right">
<button class="btn"
data-bind="string: 'add.students.validate.edits', click: function () { $parent.addStudentsValidateNames(true); },
enable: ($parent.addStudentsHasPotentialErrors() || $parent.addStudentsHasErrors()) && !$parent.addStudentsEditingFields() && !$parent.addStudentsCheckingUsernames()"></button>
<button class="btn"
data-bind="string: $parent.addStudentsDuplicateUsernames().length ? 'save.and.continue' : 'save.and.close', click: function () { $parent.addStudentsSaveAndClose(false); }, enable: $parent.addStudentsSaveAndCloseEnabled()"></button>
</div>
@onlyurei
onlyurei / knockout-custom-bindings-jquery-ui
Created Apr 19, 2015
Knockout Custom Bindings for jQuery UI Widgets (autocomplete, dragDrop, slider, sortable)
View knockout-custom-bindings-jquery-ui
define(['Knockout.Raw', 'jQuery.UI', 'Sugar'], function (ko) {
ko.bindingHandlers.autocomplete = {
init: function (element, valueAccessor, allBindingsAccessor) {
var allBindings = allBindingsAccessor();
$(element).autocomplete(Object.merge({
select: function (event, ui) {
valueAccessor()(ui.item);
}
}, allBindings.autocompleteOptions));
View elevator-saga-balanced-solution
{
init: function (elevators, floors) {
function queueDestinationForElevator(elevator, floorNum) {
if (elevator.destinationQueue.length) {
if (isElevatorGoingUp(elevator)) {
if (floorNum < elevator.destinationQueue[0]) {
if (elevator.currentFloor() < floorNum) {
elevator.destinationQueue.splice(0, 0, floorNum);
} else {
View Get URLs of all links on the page
You can’t perform that action at this time.