Skip to content

Instantly share code, notes, and snippets.

uptime | awk -F'( |,|:)+' '{if ($7=="min") m=$6; else {if ($7~/^day/) {d=$6;h=$8;m=$9} else {h=$6;m=$7}}} {print "{\"days\":",d+0,", \"hours\":",h+0,", \"minutes\": ",m+0,"}"}'
//{"days": 0 , "hours": 9 , "minutes": 40 }
@augustine-tran
augustine-tran / S3-CORS-config.xml
Created December 23, 2015 14:05 — forked from zxbodya/S3-CORS-config.xml
Client side uploads to s3, with pre-signed upload form (PHP/JS)
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
- (IBAction)buyMoreButtonClicked:(id)sender
{
[GGProgressHUD showActivity];
NSString *productId = IAP_PRODUCT_CREDIT;
SKProduct *product = [[TNStoreHelper requestedProducts] valueForKey:productId];
if (product) {
[self purchaseProduct:product];
return;
}
- (IBAction)buyMoreButtonClicked:(id)sender
{
[GGProgressHUD showActivity];
NSString *productId = nil;
if (sender == btnCredit1) {
productId = IAP_PRODUCT_CREDIT1;
} else if (sender == btnCredit2) {
productId = IAP_PRODUCT_CREDIT2;
} else {
productId = IAP_PRODUCT_CREDIT3;
@augustine-tran
augustine-tran / autocomplete.js
Created June 27, 2014 03:34
PhalconEye how widget work
// notice $(function () {
(function (window, $, root, undefined) {
$(function () {
root.ns(
'PhalconEye.widget.autocomplete',
{
/**
* Init autocomplete.
*
* @param element Element object.
@augustine-tran
augustine-tran / PyramidController
Created June 27, 2014 03:30
PhalconEye how modal box works
$params = ['hide' => true, 'hideTimeout' => 1000];
$callbackFn = $this->request->getQuery('callbackFn', 'string');
if ($callbackFn) {
$params['customJs'] = $callbackFn . '('. $jsonData .')';
}
$this->resolveModal($params);
@augustine-tran
augustine-tran / gist:f7839608f34d74a6da68
Created June 27, 2014 03:27
PhalconEye how injector api works
/**
* Api container.
*
* @category PhalconEye
* @package Engine\Api
* @author Ivan Vorontsov <ivan.vorontsov@phalconeye.com>
* @copyright 2013-2014 PhalconEye Team
* @license New BSD License
* @link http://phalconeye.com/
*/
@augustine-tran
augustine-tran / gist:dc0ff64b6380d8ca0cc3
Created June 27, 2014 03:25
PhalconEye call model method in select box
$arrUsers = $this->di->get('sourcing')->pyramidRepository()->getTeamUsers(0);
$form = new CoreForm();
$form->addSelect('users[]', 'Users', null, $arrUsers, null, ['using' => ['id', '__getFullName']], ['data-widget'=>"dualListBox", 'multiple'=> 'true']);
@augustine-tran
augustine-tran / gist:93a157fada25391b6cbb
Created June 27, 2014 03:24
PhalconEye modal box and callback function
{% extends "../../Core/View/layouts/main.volt" %}
{% block head %}
<script type="text/javascript">
var manageUsersAction = function($btn) {
PhalconEye.widget.modal.open($btn.data('url'), {'callbackFn': 'onAfterUserSelection'});
}
var onAfterUserSelection = function(users) {
var container = $('#assigneesWrapper').html('');
@augustine-tran
augustine-tran / gist:11147852
Created April 21, 2014 16:27
Vagrant Guest fix bug of Virtual Box 4.3
sudo ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions