Skip to content

Instantly share code, notes, and snippets.

View pwxcoo's full-sized avatar
🐟

Xiance Wu pwxcoo

🐟
View GitHub Profile
@pwxcoo
pwxcoo / Client.cs
Created June 6, 2018 10:56
socket corresponding in Revit
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ClientDemo
@pwxcoo
pwxcoo / mathjax.html
Created August 2, 2018 03:37
mathjax
<script src="https://cdn.bootcss.com/mathjax/2.7.4/MathJax.js?config=default">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$','$'],["\\(","\\)"]],
displayMath: [['\\[','\\]'], ['$$','$$']],
},
});
</script>
@pwxcoo
pwxcoo / pac.txt
Last active September 9, 2018 14:19
pac for ss
// Generated by gfwlist2pac
// https://github.com/clowwindy/gfwlist2pac
var domains = {
"stackoverflow.com": 1,
"w3schools.com": 1,
"codeforces.com": 1,
"disqus.com": 1,
"onedrive.live.com": 1,
"quora.com": 1,
@pwxcoo
pwxcoo / findKthSmallest.cpp
Created September 10, 2018 10:29
find Kth number in two sorted arrays.
int findKthSmallest(int vec1[], int n1, int vec2[], int n2, int k)
{
if (n1 == 0)
return vec2[k - 1];
else if (n2 == 0)
return vec1[k - 1];
if (k == 1)
return vec1[0] < vec2[0] ? vec1[0] : vec2[0];
int idx1 = n1 * 1.0 / (n1 + n2) * (k - 1);
@pwxcoo
pwxcoo / lru.cpp
Last active September 11, 2018 05:55
LRU cache implemented with cpp
/**
* @author pwxcoo
* @email pwxcoo@gmail.com
* @create date 2018-09-11 10:30:47
* @modify date 2018-09-11 13:28:17
* @desc LRU cache implemented by c++
*/
#ifndef _LRUCACHE_INCLUDED_
#define _LRUCACHE_INCLUDED_
@pwxcoo
pwxcoo / sqrt.py
Created September 12, 2018 03:57
Newton Iteration Sqrt
def newtonSqrt(n, eps=1e-8):
"""
- ASSUME
f(x) = x^2 - n
when f(x)=0, x will be the root of n.
- DEDUCE BY Taylor Series Formula
f(x) = f(x0) + (x - x0)f'(x0)
- WHEN f(x)=0
x = x0 - f(x0)/f'(x0)
x will be closer to the root than x0
@pwxcoo
pwxcoo / inorder.cpp
Last active September 12, 2018 10:02
Binary Tree Traversal of Iteration (non-recursion)
vector<int> inorderTraversal(TreeNode* root) {
stack<TreeNode*> st;
vector<int> res;
auto now = root;
while(!st.empty() || now)
{
while(now)
{
st.push(now);
@pwxcoo
pwxcoo / double.cpp
Last active September 21, 2018 09:57
1. print double type value to binary/hexadecimal expression in c++ 2. double parser for converting binary to double in Python
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <cmath>
@pwxcoo
pwxcoo / navbar.html
Last active October 2, 2018 09:22
A universal navbar template
<nav class="navbar navbar-expand-lg navbar-dark bg-dark ">
<a class="navbar-brand" href="#">Popular Quotes Collection</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-end" id="navbarSupportedContent">
<ul class="navbar-nav">
<li class="nav-item ative">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
@pwxcoo
pwxcoo / json.js
Created October 5, 2018 05:54
[jQuery]Convert form to json
$.fn.serializeObject = function()
{
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');