Skip to content

Instantly share code, notes, and snippets.

View dominicgan's full-sized avatar

Dominic Gan dominicgan

View GitHub Profile
@dominicgan
dominicgan / Gulpfile.js
Created May 11, 2016 10:18
iweb front-end dev gulpfile
var gulp = require('gulp');
var open = require('gulp-open');
var gulpsass = require('gulp-sass');
var browserSync = require('browser-sync');
var gutil = require('gulp-util');
var del = require('del');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var filesize = require('gulp-filesize');
// var postcss = require('gulp-postcss');
@dominicgan
dominicgan / yii_zimbra_curl.php
Last active June 12, 2018 18:44
PHP Curl to authenticate with Zimbra API (Using Yii 1.1)
<?php
// ...
// login actions
// ...
if ($form->submitted('login') && $form->validate()) {
// assuming successful login = correct credentials,
// auth with zimbra for email and calendar, and create Z_AUTH_TOKEN
// 2 tokens, one for personal mail domain and the other for general calendar
// ZIMB_TKN & ZIMB_TKN_CAL
@dominicgan
dominicgan / yii_ssh2_write_file.php
Created May 27, 2016 10:07
Write a file to remote server with php ssh2
<?php
class ssh_test extends CWidget {
public function init() {
$success = false;
$sftp_host = '123.456.78.90';
$sftp_port = '22';
$sftp_fldr_prefix = '/var/www/';
$sftp_fldr_location = 'base_dir/sub_dir/';
@dominicgan
dominicgan / config.php
Last active July 1, 2016 04:38
Yii config to enable both yii log types
<?php
// you will need to create multiple vhost to view both log types
$http_host_development_trace = "www.url.trace"; // first vhost
$http_host_development_debug = "www.url.debug"; // second vhost
if (isset($_SERVER["HTTP_HOST"]) && $_SERVER["HTTP_HOST"] == $http_host_development_trace) {
$db['username'] = 'root';
$db['password'] = 'root';
$db['enableProfiling'] = true;
@dominicgan
dominicgan / isotope.init.js
Created July 21, 2016 02:51
Isotope with filtering in vanilla js
var grid = document.querySelector('#portfolio .portfolio-list');
console.log(grid);
var iso = new Isotope(grid, {
itemSelector: '.portfolio-list__item',
filter: '.cat-commercial, .cat-healthcare, .cat-retail, .cat-hospitality',
// sortAscending: {
// name: true,
// date: false
// },
@dominicgan
dominicgan / google-map.config.html
Last active July 25, 2016 03:52
Google map with custom style
<script src="https://maps.googleapis.com/maps/api/js?key=API_KEY_HERE&libraries=places&callback=initMap" async defer></script>
<script type="text/javascript">
// grey style
var styles = [{"featureType":"all","elementType":"all","stylers":[{"saturation":-100},{"gamma":0.5}]},{"featureType":"administrative.locality","elementType":"geometry","stylers":[{"visibility":"off"}]},{"featureType":"administrative.locality","elementType":"labels.text","stylers":[{"visibility":"on"}]},{"featureType":"administrative.locality","elementType":"labels.text.fill","stylers":[{"visibility":"on"}]},{"featureType":"administrative.locality","elementType":"labels.text.stroke","stylers":[{"visibility":"on"}]},{"featureType":"administrative.locality","elementType":"labels.icon","stylers":[{"visibility":"on"}]},{"featureType":"administrative.neighborhood","elementType":"geometry.fill","stylers":[{"visibility":"on"}]},{"featureType":"landscape.man_made","elementType":"geometry","stylers":[{"visibility":"on"}]},{"featureType":"landsca
@dominicgan
dominicgan / flickity.init.js
Created July 25, 2016 06:46
Initialize flickity
var slider = document.querySelector('#slider');
imagesLoaded(slider, function() {
// load flickity only when images have all loaded
var flkty = new Flickity( slider, {
cellAlign: 'left',
contain: true,
prevNextButtons: false,
pageDots: false,
autoPlay: 2000,
wrapAround: true,
@dominicgan
dominicgan / Package Control.sublime-settings
Created August 5, 2016 09:52
My sublime package list (Windows)
{
"bootstrapped": true,
"in_process_packages":
[
],
"installed_packages":
[
"Alignment",
"All Autocomplete",
"Babel",
@dominicgan
dominicgan / Gulpfile.js
Last active February 15, 2017 07:36
Gulpfile for html mockup creation
// set source and dest dirs for scss compilation
var scss_src = ['scss/*.scss', '!scss/_*.scss'];
var scss_dest = './public/stylesheets/theme/';
// set ports for browserSync
var bs_port_ui = 30477; // main port for viewing site
var bs_port_debug = 30478; // port to view browserSync admin panel
var bs_port_weinre = 30479; // port for browserSync to open weinre debugger (open source debug tool like chrome devtools/firebug)
// set files to watch for browserSync (reload when watched files are changed)
@dominicgan
dominicgan / fbupload.js
Created August 11, 2016 08:16
Publish photo to Facebook (jQuery Ajax - POST) - August 2016
var pgToke = 'YOUR_PAGE_TOKEN_HERE'; // generate page token with GET or in Facebook graph explorer
var caption = document.getElementById('post_status').value;
var fileUl = document.getElementById('post_img');
file = fileUl.files[0];
// Create the FormData object and attach to a key name "file"
var fd = new FormData();
fd.append("file", file);
fd.append("caption", caption);