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 / struts2: persistence.xml
Created February 25, 2013 15:51
Struts 2 Persistence.xml OpenJPA
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="shop">
<provider>
org.apache.openjpa.persistence.PersistenceProviderImpl
@hoandang
hoandang / sql: remoteMySQL.sql
Created March 11, 2013 15:49
Connect MySQL remotely
mysql -u <server username db> -p -h <server address (eg: ec2-23-21-211-172.compute-1.amazonaws.com)>
@hoandang
hoandang / shorcuts.txt
Last active December 15, 2015 00:49
Forgettable Shorcuts
\ + c + <Space>: comment in VIM
\ + b +e : Open buffer in VIM
<eject> + Shift + control: Turn off screen macbook
@hoandang
hoandang / sql: schema_tables.sql
Created March 21, 2013 08:37
Select all tables from a particular schema
SELECT table_name FROM all_tables WHERE owner='<schema name>'
@hoandang
hoandang / sql: create_table.sql
Last active December 15, 2015 05:49
Create table from another table
create table <table_name> as (<select statement goes here>)

Setup new Mac with OSX Lion from scratch

These commands are good as of 2011-07-27.

Install Xcode 4

The download/install takes a while so start it first. When it finishes downloading you will still need to run it to complete installation.

Really the nicest choice for a terminal on OSX right now, especially with Lion style full screen support.

@hoandang
hoandang / index.html
Created June 27, 2013 07:14 — forked from mfkp/index.html
Integrate mailchimp service
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="jquery.ketchup.all.min.js" type="text/javascript"></script>
</head>
<body>
<div id="email">
<span>Enter your email to sign up</span>
<form action="/subscribe.php" id="invite" method="POST">
@hoandang
hoandang / pretty_var_dump.php
Created July 3, 2013 15:39
Pretty var_dump for PHP
echo'<pre>';var_dump($records);
or
using http://raveren.github.io/kint/#advanced
@hoandang
hoandang / serialise.js
Created July 7, 2013 12:02
Javascript: Serialise Form into Object
$.fn.serializeObject = function() {
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
@hoandang
hoandang / crop.php
Created July 7, 2013 13:03
PHP: Crop Image
<?php
$x = $_POST['x'];
$y = $_POST['y'];
$w = $_POST['w'];
$h = $_POST['h'];
$targ_w = 800;
$targ_h = 620;
$jpeg_quality = 90;