Skip to content

Instantly share code, notes, and snippets.

View flyakite's full-sized avatar
:bowtie:
Working from home

Shih-Wen Su flyakite

:bowtie:
Working from home
View GitHub Profile
@flyakite
flyakite / BiFunction.java
Last active November 19, 2019 10:03
Test
import java.util.function.BiFunction;
public class Main {
public static void main(String args[])
{
BiFunction<Integer, Integer, Integer> composite1 = (a, b) -> a + b;
composite1 = composite1.andThen(a -> 2 * a);
System.out.println("Composite1 = " + composite1.apply(2, 3));
@flyakite
flyakite / introrx.md
Created June 2, 2019 09:58 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@flyakite
flyakite / backup-github.sh
Created April 3, 2019 01:22 — forked from rodw/backup-github.sh
A simple script to backup an organization's GitHub repositories, wikis and issues.
#!/bin/bash
# A simple script to backup an organization's GitHub repositories.
# NOTE: if you have more than 100 repositories, you'll need to step thru the list of repos
# returned by GitHub one page at a time, as described at https://gist.github.com/darktim/5582423
GHBU_BACKUP_DIR=${GHBU_BACKUP_DIR-"github-backups"} # where to place the backup files
GHBU_ORG=${GHBU_ORG-"<CHANGE-ME>"} # the GitHub organization whose repos will be backed up
# (if you're backing up a user's repos instead, this should be your GitHub username)
GHBU_UNAME=${GHBU_UNAME-"<CHANGE-ME>"} # the username of a GitHub account (to use with the GitHub API)
#!/usr/bin/env bash
#Code adapted from https://gist.github.com/yangj1e/3641843c758201ebbc6c (Modified to Python3.5)
cd ~
#wget https://3230d63b5fc54e62148e-c95ac804525aac4b6dba79b00b39d1d3.ssl.cf1.rackcdn.com/Anaconda2-2.4.0-Linux-x86_64.sh
wget https://3230d63b5fc54e62148e-c95ac804525aac4b6dba79b00b39d1d3.ssl.cf1.rackcdn.com/Anaconda3-2.4.1-Linux-x86_64.sh
bash Anaconda3-2.4.1-Linux-x86_64.sh -b
echo 'PATH="/home/ubuntu/anaconda3/bin:$PATH"' >> .bashrc
source .bashrc
@flyakite
flyakite / CountryCodes.json
Last active March 9, 2016 04:27 — forked from Goles/CountryCodes.json
Country and Dial or Phone codes in JSON format
[{
"name": "Afghanistan",
"dial_code": "+93",
"code": "AF"
}, {
"name": "Aland Islands",
"dial_code": "+358",
"code": "AX"
}, {
"name": "Albania",
import BeautifulSoup, requests
r=requests.post('http://www.twse.com.tw/ch/trading/exchange/BWIBBU/BWIBBU.php', {'STK_NO':2330, 'myear': 2016, 'mmon':2})
soup = BeautifulSoup.BeautifulSoup(r.content)
table = soup.find('table', {'class':'board_trad'})
with open('out2.csv', 'w') as f:
trs = table.findAll('tr')
for tr in trs:
@flyakite
flyakite / example_usage_in_controllers.js
Last active November 30, 2015 05:46
service for $cordovaGoogleAnalytics
GA.startTrackerWithId('UA-70824422-1');
GA.trackView('News');
GA.addCustomDimension('Type', 'tips');
## create myapp based on sidemenu project
$ ionic start myapp sidemenu
## go to myapp folder
$ cd myapp
## list files
@flyakite
flyakite / install.sh
Last active November 15, 2015 00:29
Ionic Framework Tutorial
## Install NodeJS
## Go To https://nodejs.org/en/
## Download and Install NodeJs
## Test it!
## Open command line terminal on Mac or PowerShell on Windows
$ node -v # show node.js version
$ npm -v # show npm version

#Mobile Device Detection via User Agent RegEx

Yes, it is nearly 2012 and this exercise has been done to death in every imaginable language. For my own purposes I needed to get the majority of non-desktop devices on to a trimmed down, mobile optimized version of a site. I decided to try and chase down an up-to-date RegEx of the simplest thing that could possibly work.

I arrived at my current solution after analyzing 12 months of traffic over 30+ US based entertainment properties (5.8M+ visitors) from Jan - Dec 2011.

The numbers solidified my thoughts on the irrelevancy of including browsers/OSes such as Nokia, Samsung, Maemo, Symbian, Ipaq, Avant, Zino, Bolt, Iris, etc. The brass tacks of the matter is that you certainly could support these obscure beasts, but are you really going to test your site on them? Heck, could you even find one?! Unless the folks that pay you are die hard Treo users my guess is "No".

Interestingly enough my research shows that /Mobile/ is more efficient than **/iP(