Skip to content

Instantly share code, notes, and snippets.

@tlan16
tlan16 / Bind Validation to “Process to checkout” button in Magento.md
Last active November 26, 2015 03:42
Bind Validation to “Process to checkout” button in Magento

As per request by a customer, they need to add a customised validation in the checkout process. The customer cannot proceed to checkout in some circumstances:

The grand total of the shopping cart exceed a certain amount There is at least one product in the shopping cart belongs to a certain category If all of the conditions above is met, then the customer cannot checkout. In this case, I just disabled the “process to checkout” button.

The file been overloaded is

app\design\frontend\base\default\template\checkout\onepage\link.phtml

@tlan16
tlan16 / nodejs_orm.js
Last active November 29, 2015 07:45
nodejs_orm.js
var express = require('express');
var orm = require("orm");
var app = express();
var bodyParser = require('body-parser');
var port = process.env.PORT || 8080;
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
var db = orm.connect('mongodb://localhost/docman');
@tlan16
tlan16 / data.json
Created December 4, 2015 22:39
A Simple Angular JS Range Data Selector
{
"errors": {
"OOR": "out of range"
},
"data": {
"type1": {
"subtype1": [
{
"range": [
0,
@tlan16
tlan16 / gist:af0138a3e3426f9cc824
Created January 4, 2016 10:42 — forked from Flet/gist:5447732
Sublime Text: Eclipse Shortcuts keymap
[
{ "keys": ["f12"], "command": "htmlprettify"},
{ "keys": ["f1"], "command": "fold" },
{ "keys": ["f2"], "command": "unfold" },
{ "keys": ["ctrl+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": "@"} },
{ "keys": ["ctrl+space"], "command": "auto_complete" },
{ "keys": ["ctrl+space"], "command": "replace_completion_with_auto_complete", "context":
[
{ "key": "last_command", "operator": "equal", "operand": "insert_best_completion" },
@tlan16
tlan16 / The Technical Interview Cheat Sheet.md
Created January 6, 2016 13:31 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@tlan16
tlan16 / docx2md.md
Created May 23, 2017 23:14 — forked from jesperronn/docx2md.md
Convert a Word Document into MD

Converting a Word Document to Markdown in One Move

The Problem

A lot of important government documents are created and saved in Microsoft Word (*.docx). But Microsoft Word is a proprietary format, and it's not really useful for presenting documents on the web. So, I wanted to find a way to convert a .docx file into markdown.

Installing Pandoc

On a mac you can use homebrew by running the command brew install pandoc.

The Solution

@tlan16
tlan16 / rename.sh
Last active December 15, 2017 14:15
Cleanup unwanted part of movie/anime name part(s)
# README: install renamer first by `npm -g install renamer`
renamer --regex --find '(?<=^\[直播\]).+(?=\d\d\d\d-\d\d-\d\d)|(?<=^\[直播\].+)\[|(?<=^\[直播\].+)\]|^\[直播\]' **/*
renamer --regex --find '\[(BDRip|BDRIP)\]' **/*
renamer --regex --find '\[AVC_AAC\]' **/*
renamer --regex --find '\[GB\]' **/*
renamer --regex --find '\[BIG5\]' **/*
renamer --regex --find '\[GB_CN\]' **/*
renamer --regex --find '\[MP(4|5)\]' **/*
renamer --regex --find '\[HDTV\]' **/*
@tlan16
tlan16 / convert_pipe.sh
Last active April 15, 2022 09:58
ffmpeg convert pipeline
#!/usr/bin/env bash
# Usage Example: find ./*.{mp4,flv} -type f | parallel -j 2 --keep-order --line-buffer ./convert_pipe.sh {} {.}.mkv
# Please use git bash on windows
set -e
# Shell colors
NC='\e[0m' # No Color
DRY_RUN=0
INPUT=""
@tlan16
tlan16 / shanbay_extractor.js
Last active February 1, 2018 13:55
extract self-created dictionary from shanbay.com
// ==UserScript==
// @name New ES6-Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description shows how to use babel compiler
// @author You
// @require https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.18.2/babel.js
// @require https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.16.0/polyfill.js
// @require http://unpkg.com/xlsx/dist/shim.min.js
// @require http://unpkg.com/xlsx/dist/xlsx.full.min.js
@tlan16
tlan16 / ykdl_auto.sh
Last active August 8, 2018 10:48
automatically download via ykdl
#!/usr/bin/env bash
echo "$(date)"
PATH="/home/frank/.local/bin:/usr/local/bin:$PATH"
# get arguments
INFO_ONLY=0
while getopts ":o:i" opt; do