Skip to content

Instantly share code, notes, and snippets.

View kewang's full-sized avatar
🎯
Focusing

Kewang kewang

🎯
Focusing
View GitHub Profile
@kewang
kewang / WordWrap.java
Last active September 13, 2016 15:48
import java.util.Random;
public class Main {
public static void main(String[] args) {
long start = System.currentTimeMillis();
Random r = new Random();
for (int i = 0; i < 1000; i++) {
for (int j = 0; j < 1000; j++) {
if (r.nextInt(4) == 0) {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kewang
kewang / git-overwrite-branch.sh
Created November 14, 2016 10:31 — forked from brev/git-overwrite-branch.sh
Git overwrite branch with another branch
# overwrite master with contents of seotweaks branch (seotweaks > master)
git checkout seotweaks # source name
git merge -s ours master # target name
git checkout master # target name
git merge seotweaks # source name
@kewang
kewang / git-merge-test.sh
Last active February 23, 2023 10:04
Git merge dry-run
#!/bin/sh
BRANCH=$1
git merge --no-commit --no-ff $1; git status; git merge --abort
# References: https://stackoverflow.com/questions/501407/is-there-a-git-merge-dry-run-option
@kewang
kewang / slick.htm
Last active November 29, 2016 14:23
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>CodePen - A Pen by Mu Chun Wang</title>
<link rel='stylesheet prefetch' href='https://cdn.jsdelivr.net/jquery.slick/1.6.0/slick.css'>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
<script src='https://cdn.jsdelivr.net/jquery.slick/1.6.0/slick.min.js'></script>
</head>
@kewang
kewang / list_ca.js
Last active December 11, 2016 16:34
$(function(){
var queryDict = {};
location.search.substr(1).split("&").forEach(function(item) {queryDict[item.split("=")[0]] = item.split("=")[1]}); // 取得網址列的參數
$(".nav>ul>li:has(ul)>a").after('<a href="#" class="menu-plus">+</a>'); // 判斷第一層裡面是否還有選單,有的話就加上 <a href="#" class="menu-plus">+</a>
$(".nav>ul>li>ul>li:has(ul)>a").after('<a href="#" class="menu-plus">+</a>'); // 判斷第二層裡面是否還有選單,有的話就加上 <a href="#" class="menu-plus">+</a>
$(".nav>#nav-btn").click(function() { // 當點選 #nav-btn 時,就開關第一層的 menu
$(function(){
$(".hide-form-title").click(function(){ // 點選 title 的時候
$(this).siblings(".hide-form").slideToggle(function(){ // 找出同一層的 hide-form,然後開關
var img = $(this).siblings(".hide-form-title").find("img"); // 然後再找回原來 title 裡面的 img
var src = img.attr("src"); // 把 src 找出來
if (src === "images/down-arrow.png") { // 做上下箭頭的切換
img.attr("src", "images/up-arrow.png");
} else {
img.attr("src", "images/down-arrow.png");
/*price range*/
$('#sl2').slider();
var RGBChange = function() {
$('#RGB').css('background', 'rgb('+r.getValue()+','+g.getValue()+','+b.getValue()+')')
};
/*scroll to top*/
<div class="container">
<div class="row">
<div class="col-sm-3">
<div class="left-sidebar">
<h2>Product Categories</h2>
<div class="panel-group category-products" id="accordian"><!--category-productsr-->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordian" href="#sportswear">