Skip to content

Instantly share code, notes, and snippets.

@khoand0000
khoand0000 / test
Created December 14, 2014 19:25
test perfomance
ab -c 200 -n 2000
@khoand0000
khoand0000 / php-frameworks-libraries.md
Last active September 12, 2015 15:00
list of php frameworks and libraries

Used

  • send HTTP request: guzzle, php-curl-class (still comparing them)
  • slim (RESTful framework)
  • yii, symfony, cakephp (framework)
  • briannesbitt/Carbon (datetime lib)

Haven't used, will use in future

  • laravel
@khoand0000
khoand0000 / form.js
Last active August 29, 2015 14:21
submit form by ajax
$(function() { // wait for the DOM to be ready
$('#foo').submit(function() { // bind function to submit event of form
$.ajax({
type: $(this).attr('method'), // get type of request from 'method'
url: $(this).attr('action'), // get url of request from 'action'
data: $(this).serialize(), // serialize the form's data
success: function(response) {
// if everything goes well, update the div with the response
$('#result').html(response);
}
@khoand0000
khoand0000 / infinity.js
Created May 14, 2015 05:20
Infinity scrolling
$(window).scroll(function(){
// maybe include - $('#footer').outerHeight(true) <-- height with margin
if ($(window).scrollTop() >= $(document).height() - $(window).height()) {
// do something, load more products, etc
}
});
@khoand0000
khoand0000 / json-structure.md
Last active November 11, 2016 06:19
RESTful guidline

usage

  • return collection. *http code: 200
[
  {id:1},
  {id:2}
]
  • return single object. http code: 200
@khoand0000
khoand0000 / json.php
Created July 7, 2015 10:35
return json header
header('Content-Type: application/json');
@khoand0000
khoand0000 / ajax.php
Created July 15, 2015 18:31
get link to process wordpress ajax in frontend
<script type="text/javascript">
var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
</script>
@khoand0000
khoand0000 / get-object-ionicModal.md
Last active August 29, 2015 14:25
$ionicModal: fromTemplate vs. fromTemplateUrl functions

To get object ionicModal:

  • fromTemplate()
var template='<ion-modal-view>
    <ion-header-bar><h1 class="title">title</h1></ion-header-bar>
    <ion-content>content</ion-content>
</ion-modal-view>';
$scope.modal = $ionicModal.fromTemplate('templates/code-modal.html', {
 scope: $scope,
@khoand0000
khoand0000 / ionicModal-ionicPopup-ionicPopver.md
Last active January 11, 2017 17:34
$ionicModal vs. $ionicPopup vs. $ionicPopover
  • $ionicModal: show dialog (must provide UI) at center screen if large screen (ipad, pc); otherwise, showing fullscreen overlays current screen, allow close modal by clicking backdrop
  • $ionicPopover: show dialog (must provide UI) at element occurs event (button), allow close modal by clicking backdrop
  • $ionicPopup: show dialog (confirm, alert, prompt or custome) at center screen, doesn't allow close modal by clicking backdrop
@khoand0000
khoand0000 / show-model.md
Last active August 29, 2015 14:25
There are 2 ways to show model
  • ng-model for elements use value attribute to show information like <input>
<input type="text" ng-model="contact.name">
  • {{ model }} for elements use inner content to show information like <div>, <a>, ...
<div>
{{contact.name}}
</div>