Skip to content

Instantly share code, notes, and snippets.

View dboyliao's full-sized avatar

dboyliao dboyliao

View GitHub Profile
@dboyliao
dboyliao / svm.py
Created July 14, 2014 12:32 — forked from mblondel/svm.py
# Mathieu Blondel, September 2010
# License: BSD 3 clause
import numpy as np
from numpy import linalg
import cvxopt
import cvxopt.solvers
def linear_kernel(x1, x2):
return np.dot(x1, x2)

[TOC]

Lab Guide for Coding Beginners

亮亮(@ccwang002)| Mar, 2015 | CC 3.0 BY license

如果內容有誤,你可以用任何管道發訊息轟炸我,或用底下的 gist comment 留言。

學習方式

每個檔案都會是一個主題,主題底下會列出一些資源。資源的最後會有一個學習目標,方便讓你評估自己學到什麼程度。學習目標會給一個明確的任務,我盡量讓它能跟(宅宅的)日常生活結合。通常只要完成前一、二個目標就行了,這也不是功課所以不一定要給我看。如果你不介意給我看,我會分享我主觀的建議,但大部份的任務是沒有絕對的正確答案。只要能解決問題都是好方法。

@dboyliao
dboyliao / Scan.py
Last active August 29, 2015 14:22 — forked from enjoylife/Scan.py
# -*- coding: utf-8 -*-
"""
SCAN: A Structural Clustering Algorithm for Networks
As described in http://ualr.edu/nxyuruk/publications/kdd07.pdf
"""
from collections import deque
import numpy as np
from scipy.sparse import csr_matrix
@dboyliao
dboyliao / comprehensions.md
Created March 29, 2016 08:33 — forked from bearfrieze/comprehensions.md
Comprehensions in Python the Jedi way

Comprehensions in Python the Jedi way

Beautiful is better than ugly. Explicit is better than implicit.

-- The Zen of Python

I frequently deal with collections of things in the programs I write. Collections of droids, jedis, planets, lightsabers, starfighters, etc. When programming in Python, these collections of things are usually represented as lists, sets and dictionaries. Oftentimes, what I want to do with collections is to transform them in various ways. Comprehensions is a powerful syntax for doing just that. I use them extensively, and it's one of the things that keep me coming back to Python. Let me show you a few examples of the incredible usefulness of comprehensions.

All of the tasks presented in the examples can be accomplished with the extensive standard library available in Python. These solutions would arguably be more terse and efficient in some cases. I don't have anything against the standard library. To me there is a certain

@dboyliao
dboyliao / gist:52e68a5d9cab3592cd700eb86b099024
Created March 30, 2016 00:45 — forked from arvearve/gist:4158578
Mathematics: What do grad students in math do all day?

Mathematics: What do grad students in math do all day?

by Yasha Berchenko-Kogan

A lot of math grad school is reading books and papers and trying to understand what's going on. The difficulty is that reading math is not like reading a mystery thriller, and it's not even like reading a history book or a New York Times article.

The main issue is that, by the time you get to the frontiers of math, the words to describe the concepts don't really exist yet. Communicating these ideas is a bit like trying to explain a vacuum cleaner to someone who has never seen one, except you're only allowed to use words that are four letters long or shorter.

What can you say?

Sometimes we need to open Setting's Preferences not of our app, but of the iPhone itself. What should we do to acomplish this?

[UPDATE: Added Wallet And Apple Pay below]

[UPDATE: Changed prefs for Bluetooth]

keyboard

@dboyliao
dboyliao / pipe.go
Created August 4, 2016 12:34 — forked from matishsiao/pipe.go
named pipe sample code
package main
import (
"bufio"
"fmt"
"log"
"os"
"syscall"
"time"
)
@dboyliao
dboyliao / ralign
Created October 14, 2016 16:22 — forked from CarloNicolini/ralign
Umeyama algorithm for absolute orientation problem in Python
"""
RALIGN - Rigid alignment of two sets of points in k-dimensional
Euclidean space. Given two sets of points in
correspondence, this function computes the scaling,
rotation, and translation that define the transform TR
that minimizes the sum of squared errors between TR(X)
and its corresponding points in Y. This routine takes
O(n k^3)-time.
Inputs:
@dboyliao
dboyliao / gist:6a8f237dda95d7541ab96a616ddeb770
Created December 6, 2016 02:04 — forked from tmoertel/gist:5798134
How to transform the vanilla recursive fib function into the iterative DP version through a series of mechanical steps.
# Transforming the vanilla recursive fib into the iterative DP version
# through a series of mechanical steps.
#
# For more on converting recursive algorithms into iterative ones, see:
# http://blog.moertel.com/posts/2013-05-11-recursive-to-iterative.html
# original function
def fib(n):
@dboyliao
dboyliao / exec_with_gdb.sh
Created April 27, 2017 08:19 — forked from jserv/exec_with_gdb.sh
GDB runner
# Execute an executable under gdb, printing a call stack if we get a crash.
gdb -return-child-result -quiet -batch \
-ex "set env MALLOC_CHECK_=3" \
-ex "set print thread-events off" \
-ex run \
-ex "thread apply all backtrace full" \
-ex "quit" \
$*