Skip to content

Instantly share code, notes, and snippets.

@sunnycyk
sunnycyk / html
Last active December 14, 2015 08:28
HTML Template
<!doctype html>
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>
@sunnycyk
sunnycyk / api.js
Created March 8, 2013 08:14 — forked from fwielstra/api.js
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
@sunnycyk
sunnycyk / style.css
Created April 6, 2013 16:09
WordPress Style.css
/*
Theme Name: wpbase
Theme URI: https://github.com/sunnycyk/wpbase
Description: A Basic WordPress Theme
Version: 0.1
Author: Sunny Cheung
Author URI: http://sunnycyk.hk
Tags:
License: GNU General Public License v2.0 & Apache License 2.0
License URI: http://www.gnu.org/licenses/gpl-2.0.html http://www.apache.org/licenses/LICENSE-2.0
var fs = require("fs")
var ssl_options = {
key: fs.readFileSync('privatekey.pem'),
cert: fs.readFileSync('certificate.pem')
};
var port = process.env.PORT || 3000;
var express = require('express');
var ejs = require('ejs');
var passport = require('passport')
@sunnycyk
sunnycyk / ie10bugfix
Created May 18, 2013 09:18
Code to fix IE 10 placeholder bug for Angular JS
config(['$provide', function($provide) {
$provide.decorator('$sniffer', ['$delegate', function($sniffer) {
var msie = parseInt((/msie (\d+)/.exec(angular.lowercase(navigator.userAgent)) || [])[1], 10);
var _hasEvent = $sniffer.hasEvent;
$sniffer.hasEvent = function(event) {
if (event === 'input' && msie === 10) {
return false;
}
_hasEvent.call(this, event);
}
<?php
add_action( 'after_setup_theme', 'bootstrap_setup' );
if ( ! function_exists( 'bootstrap_setup' ) ):
function bootstrap_setup(){
add_action( 'init', 'register_menu' );
@sunnycyk
sunnycyk / README.md
Created October 22, 2013 14:41 — forked from oodavid/README.md

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@sunnycyk
sunnycyk / Sample App
Last active December 27, 2015 05:39
angular.module('myApp')
.controller('SampleCtrl', ['$scope', 'sampleService', function($scope, sampleService) {
$scope.loaded = true;
$scope.loadedContent = null;
$scope.sampleAction = function() { // Sample Action that will call the API server
$scope.loaded = false;
$scope.loadedContent = sampleService.get({}, function(data) {
$scope.loaded = true;
}, function(err) {

Set-up remote git repository on a standard server

The first thing to do is to install Git on the remote server.

Once you do that the rest of the process is split into three sections:

  1. Server set-up
  2. Local set-up (push commits)
  3. Server (pull commits)
@sunnycyk
sunnycyk / d3Service.js
Last active January 1, 2016 04:39
Using d3 with dependency injection
angular.module('d3', [])
.provider('d3Service', function() {
function createScript($document, callback, success) {
var scriptTag = $document.createElement('script');
scriptTag.type = "text/javascript";
scriptTag.async = true;
scriptTag.src = 'http://d3js.org/d3.v3.min.js';
scriptTag.onreadystatechange = function() {
if (this.readyState == 'complete') {
callback();