Skip to content

Instantly share code, notes, and snippets.

View hoandang's full-sized avatar
👟
Roaming

Hoàn Đặng hoandang

👟
Roaming
  • Sydney, Australia
View GitHub Profile
@hoandang
hoandang / outHtml.js
Last active December 19, 2015 12:39
Javascript: Get outer html of a element
jQuery.fn.outerHTML = function() {
return jQuery('<div />').append(this.eq(0).clone()).html();
};
@hoandang
hoandang / get_rotate.js
Last active June 6, 2024 18:18
Javascript: get the angle by which the element is rotated
function getRotationAngle(target)
{
const obj = window.getComputedStyle(target, null);
const matrix = obj.getPropertyValue('-webkit-transform') ||
obj.getPropertyValue('-moz-transform') ||
obj.getPropertyValue('-ms-transform') ||
obj.getPropertyValue('-o-transform') ||
obj.getPropertyValue('transform');
let angle = 0;
/*
html2canvas 0.4.0 <http://html2canvas.hertzen.com>
Copyright (c) 2013 Niklas von Hertzen (@niklasvh)
Released under MIT License
*/
(function(window, document, undefined){
"use strict";
function clear_input_file(input)
{
input.replaceWith(input = input.clone(true));
}
createjs.Bitmap.prototype.setWidth = function(w)
{
if (this.image.width == 0) return;
this.scaleX = w / this.image.width;
}
createjs.Bitmap.prototype.setHeight = function(h)
{
if (this.image.height == 0) return;
@hoandang
hoandang / z-installation
Last active December 21, 2015 04:18
Install z command on Linux
Clone z from rupa github
Put . /path/to/z.sh this in your $HOME/.bashrc or $HOME/.zshrc:

#Migrating from homebrew-php to phpbrew

After installing phpbrew it's time to install a set of chosen PHP versions. My picks at the time of this writing were:

sudo phpbrew install php-5.5.0 +default+dbs+mb+apxs2=/usr/sbin/apxs
sudo phpbrew install php-5.3.27 +default+dbs+mb+apxs2=/usr/sbin/apxs
sudo phpbrew install php-5.5.0 +default+dbs+mb+apxs2=/usr/sbin/apxs

When not sure where apxs is located on your system, whereis apxs is quite chatty.

<?php
function response_json_error($app, $http_code, $msg)
{
$app->response()->status($http_code);
$app->response()->header('X-Status-Reason', $msg);
echo json_encode(array('error' => $msg));
}
function array_to_json($array)
{
return json_decode(json_encode($array));
@hoandang
hoandang / get_paramater.js
Created September 23, 2013 13:58
Get parameter query from URL
function getParameterByName(name)
{
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
#!/bin/bash
#
# Build and iPhone Simulator Helper Script
# Shazron Abdullah 2011
#
# WARN: - if your .xcodeproj name is not the same as your .app name,
# this won't work without modifications
# - you must run this script in where your .xcodeproj file is
PROJECTNAME=$1