Skip to content

Instantly share code, notes, and snippets.

Avatar
😀

David Ng david90

😀
View GitHub Profile
@david90
david90 / skygear_stripe.md
Last active Mar 14, 2018 — forked from arsewizz/gist:c59ca68267df4b103e56082f06f9a288
Ionic payment with Stripe, then create a record at Skygear.
View skygear_stripe.md

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 Jun 30, 2017
Update the title by setParams
View setParams.js
class UserPage extends React.Component {
static navigationOptions: {
header: ({state}) => ({
left: (<NavBarBackButton />),
title: (
<UserPageTitle
userName={state.params.userName}
profilePicUrl={state.params.profilePicUrl}
/>
View sampleRoute.js
const sampleRoute = {
renderNavBarLeft: () => (<NavBarBackButton />),
renderNavBarTitle: () => (<SimplePageTitle />),
renderNavBarRight: () => null,
renderScene: () => (<SamplePage />),
};
// navigator
<Navigator
{ ...otherPropsPassingToNavigator }
@david90
david90 / main.go
Created Apr 19, 2017
Webhook on Kubernetes
View main.go
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"
)
View 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 Feb 14, 2017
Code for the training the SVM classifier
View train_svm.py
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 Feb 14, 2017
Code for extracting inception bottleneck feature
View extracting_inception.py
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 Jan 18, 2017
Skygear CMS - README
View skygear-cms-readme.md

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 Aug 6, 2015
Simple Event tracking Server that insert records to MySQL (express, mysql module needed)
View app_metrics.js
/* Server monitor */
// require('newrelic');
var mysql = require('mysql');
var express = require('express');
var app = express();
var eventsCollection;
var sessionsCollection;
/** MySQL Settings **/
View resizer.sh
#!/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
You can’t perform that action at this time.