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
/* actions fired when listing/adding/editing posts or pages */
/* admin_head-(hookname) */
add_action( 'admin_head-post.php', 'admin_head_post_editing' );
add_action( 'admin_head-post-new.php', 'admin_head_post_new' );
add_action( 'admin_head-edit.php', 'admin_head_post_listing' );
function admin_head_post_editing() {
echo 'you are editing a post';
}
@hoandang
hoandang / detect-uiscrollview-pos.md
Last active October 15, 2021 07:21
Detect uiscrollview position
@interface MyViewController : UIViewController<UIScrollViewDelegate>
@end

Then you can hook to the UIScrollView:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Set self as scroll view protocol

webView.scrollView.delegate = self;

Add UITextFieldDelegate then assign delegate for every uitextfield in the view

// Detect user touches outside keyboard and dismiss the keyboard
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
}

[texfield addTarget:self action:@selector(dismissKeyboard:) forControlEvents:UIControlEventEditingDidEndOnExit];
@hoandang
hoandang / adhoc-provision.md
Last active August 29, 2015 14:02
Create an ad-hoc provisioning
  1. Create a signed request
  2. Register UDDI for testing devices
  3. Create a provision distribution in apple dev console
  4. REMEMBER TO CHECK PROVISIONING PROFILE before archiving the project
  5. If some of the errors below occur during archiving
  • the icon or launch image error: fix the size
  • wrong builde id: make sure it fit with the bundle in apple developer console

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@hoandang
hoandang / useful-commands.md
Last active August 29, 2015 13:57
Useful custom commands
Delete remote branch
git push origin :<remote-branch-name>
Git diff 2 branches
git diff --stat --color <branch1>..<branch2> 
or
git diff --name-status <branch1>..<branch2>
@hoandang
hoandang / vhost.conf
Last active August 29, 2015 13:57
Virtual host on ubuntu
alias apache-restart="sudo /etc/init.d/apache2 restart"
alias apache-start="sudo /etc/init.d/apache2 start"
alias apache-stop="sudo /etc/init.d/apache2 stop"
# cp any template.conf from this dir (new site must have .conf extension)
alias vhost="cd /etc/apache2/sites-available"
# <VirtualHost *>
# ServerName foo.dev
# DocumentRoot /home/hoan/www/
# </VirtualHost>
@hoandang
hoandang / MtGox.php
Created March 4, 2014 05:53
A small chuck of MTGox system
<?php
namespace Money;
class Bitcoin {
#const BITCOIN_NODE = '173.224.125.222'; // w001.mo.us temporary
const BITCOIN_NODE = '50.97.137.37';
static private $pending = array();
public static function update() {
@hoandang
hoandang / media-queries.css
Created March 4, 2014 00:29
Most common media queries
@media (max-width: 1024px) { }
@media (max-width: 966px) { }
@media (max-width: 800px) { }
@media (max-width: 768px) { }
@media (max-width: 640px) { }
@media (max-width: 603px) { }
@media (max-width: 600px) { }
@media (max-width: 568px) { }
@media (max-width: 480px) { }
@media (max-width: 460px) { }
@hoandang
hoandang / apache-conf.md
Last active April 1, 2024 06:46
Sample vhost configuration

Sample apache vhost configuration

Udate /etc/hosts or c:\windows\system32\drivers\etc\hosts file so that the new servername is mapped to 127.0.0.1

Apache config file changes document root

    DocumentRoot "/Users/hoan/www"
<Directory "/Users/hoan/www">
    #

Possible values for the Options directive are "None", "All",