Skip to content

Instantly share code, notes, and snippets.

View dboyliao's full-sized avatar

dboyliao dboyliao

View GitHub Profile
@dboyliao
dboyliao / fizz_buzz.py
Created May 26, 2016 17:34
Classic "Fizz Buzz" without "if-else"
from __future__ import print_function
def main():
while True:
x = int(input("Please enter an integer: "))
print([[[x, "Fizz"][x % 3 == 0], "Buzz"][x % 5 == 0], "FizzBuzz"][x % 15 == 0])
if __name__ == "__main__":
main()
@dboyliao
dboyliao / DFS.py
Created May 29, 2016 17:17
Simple implementation of DFS (Depth First Search)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def DFS(graph, root_node = "root"):
stack = []
children = graph[root_node]
stack = children + stack
print(root_node)

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"
)
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from __future__ import print_function
import sys
if sys.version_info.major < 3:
input = raw_input
def main():
while True:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import sys
class A(object):
"""
Base Class
"""
def __init__(self):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import sys
class A(object):
"""
Base Class
"""
def __init__(self):
#!/usr/bin/env python
from __future__ import print_function
print("Hello world")
@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 / similarity_transform.py
Last active March 7, 2024 17:14
A python implementation of Umeyama Absolute Orientation Algorithm
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
## References
- [Umeyama's paper](http://edge.cs.drexel.edu/Dmitriy/Matching_and_Metrics/Umeyama/um.pdf)
- [CarloNicolini's python implementation](https://gist.github.com/CarloNicolini/7118015)
"""
from __future__ import print_function
import numpy as np