Skip to content

Instantly share code, notes, and snippets.

View david90's full-sized avatar
😛

David Ng david90

😛
View GitHub Profile
@david90
david90 / resizer.sh
Last active February 2, 2023 10:08 — forked from benvium/resizer.txt
#!/bin/bash -e
# Make sure you have installed ImageMagick
# http://cactuslab.com/imagemagick/
# Ensure we're running in location of script.
cd "`dirname $0`"
for f in *; do
if [[ $f == *@3x* ]];
then
@david90
david90 / skygear_stripe.md
Last active March 14, 2018 11:20 — forked from arsewizz/gist:c59ca68267df4b103e56082f06f9a288
Ionic payment with Stripe, then create a record at Skygear.

On Ionic side

1. Create a ionic project

  • ionic start ionicStripe blank

2. Install the stripe plugin

  • ionic cordova plugin add cordova-plugin-stripe
  • npm install --save @ionic-native/stripe

3. add stripe to module.ts

 * import { Stripe } from '@ionic-native/stripe';

4. On the payment page :

@david90
david90 / setParams.js
Created June 30, 2017 10:19
Update the title by setParams
class UserPage extends React.Component {
static navigationOptions: {
header: ({state}) => ({
left: (<NavBarBackButton />),
title: (
<UserPageTitle
userName={state.params.userName}
profilePicUrl={state.params.profilePicUrl}
/>
@david90
david90 / sampleRoute.js
Created June 30, 2017 10:17
Sample Route
const sampleRoute = {
renderNavBarLeft: () => (<NavBarBackButton />),
renderNavBarTitle: () => (<SimplePageTitle />),
renderNavBarRight: () => null,
renderScene: () => (<SamplePage />),
};
// navigator
<Navigator
{ ...otherPropsPassingToNavigator }
@david90
david90 / main.go
Created April 19, 2017 03:57
Webhook on Kubernetes
package main
import (
"context"
"encoding/json"
"log"
"net/http"
"github.com/google/go-github/github"
"golang.org/x/oauth2"
authentication "k8s.io/client-go/pkg/apis/authentication/v1beta1"
)
@david90
david90 / svm_training_result
Created February 14, 2017 09:11
SVM training result
Best parameters set:
{'kernel': 'linear', 'C': 1}
Confusion matrix:
Labels: 8531,8539,8567,8568,8599,8715,8760,8773,8777,8778,8808,8816
[[ 4 0 0 0 0 0 0 0 0 0 0 0]
[ 0 2 0 0 0 0 0 0 0 0 0 0]
[ 0 0 12 0 0 0 0 0 0 0 0 0]
[ 0 0 0 9 0 0 0 0 0 0 0 0]
@david90
david90 / train_svm.py
Created February 14, 2017 09:08
Code for the training the SVM classifier
import os
import sklearn
from sklearn import cross_validation, grid_search
from sklearn.metrics import confusion_matrix, classification_report
from sklearn.svm import SVC
from sklearn.externals import joblib
def train_svm_classifer(features, labels, model_output_path):
"""
@david90
david90 / extracting_inception.py
Created February 14, 2017 09:06
Code for extracting inception bottleneck feature
import os
import tensorflow as tf
import tensorflow.python.platform
from tensorflow.python.platform import gfile
import numpy as np
def create_graph(model_path):
"""
create_graph loads the inception model to memory, should be called before
calling extract_features.
@david90
david90 / skygear-cms-readme.md
Last active January 18, 2017 09:12
Skygear CMS - README

CMS Plugin for Skygear

This is a Skygear Plugin to provide CMS functionality to your app.

Installation

It is easy to use CMS in your Skygear app on the cloud. To do that, add the following line in your index.js in the root of your repo:

@david90
david90 / app_metrics.js
Created August 6, 2015 09:13
Simple Event tracking Server that insert records to MySQL (express, mysql module needed)
/* Server monitor */
// require('newrelic');
var mysql = require('mysql');
var express = require('express');
var app = express();
var eventsCollection;
var sessionsCollection;
/** MySQL Settings **/