Skip to content

Instantly share code, notes, and snippets.

View nickhsu's full-sized avatar

Nick Hsu nickhsu

  • Taiwan
View GitHub Profile
@nickhsu
nickhsu / sslocal
Created December 19, 2016 03:29 — forked from Jimmy-Xu/sslocal
/etc/init.d/sslocal
#!/bin/bash
set -e
### BEGIN INIT INFO
# Provides: sslocal
# Required-Start: $syslog $remote_fs
# Required-Stop: $syslog $remote_fs
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
@nickhsu
nickhsu / convert-to-webp.sh
Last active December 9, 2016 04:34 — forked from SandroMachado/convert-to-webp.sh
Script to convert all the `JPEG` images to the `WEBP` format in your Android project
#/bin/sh
# Inpiration: http://engineeringblog.yelp.com/2016/05/yelp-android-app-went-on-a-diet.html
# `-lossless` not used to give support for Android 4.0+
# Make sure cwebp is installed.
if ! type "cwebp" > /dev/null; then
echo "Please install cwebp to continue:"
echo "brew install webp"
exit 1
fi
@nickhsu
nickhsu / gist:73166d4e94179ce7ec97e8c8312c41d7
Created November 18, 2016 08:29 — forked from brentsimmons/gist:5810992
Detect a tap on a URL inside a UITextView.Note: the rs_links method isn't included -- you'll need something that takes text and returns an array of detected links. This gist just demonstrates walking through the UITextView characters.
#import "UITextView+RSExtras.h"
@implementation UITextView (RSExtras)
static BOOL stringCharacterIsAllowedAsPartOfLink(NSString *s) {
/*[s length] is assumed to be 0 or 1. s may be nil.
Totally not a strict check.*/
if (s == nil || [s length] < 1) {
#!/usr/bin/env ruby
puts <<-HEREDOC
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="container">
@nickhsu
nickhsu / data.json
Last active January 24, 2016 04:52
[
{
"id":null,
"ph":5.66,
"temperature":25.1,
"turbidity":121,
"level":23,
"created_at":1453533323
},
{
a = [
{_id: "123", val: "123"},
{_name: "456", val: "456"}
];
result = a.reduce(function(previousValue, currentValue) {
if (currentValue._id) {
previousValue[currentValue._id] = currentValue;
}
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
padding-top: 40px;
}
</style>
<title>WKWebView Demo</title>
<meta charset="UTF-8">
@nickhsu
nickhsu / es.sh
Last active January 1, 2016 06:49 — forked from rajraj/es.sh
cd ~
sudo yum update
sudo yum install java-1.7.0-openjdk.i686 -y
wget http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.20.5.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share