Skip to content

Instantly share code, notes, and snippets.

View henryhu712's full-sized avatar

henryhu henryhu712

View GitHub Profile
@henryhu712
henryhu712 / span_with_width.md
Created April 30, 2016 06:28
CSS span width

Set span with width

display: inline-block;
width: ...px;
@henryhu712
henryhu712 / array_from_javascript_to_php.md
Created April 14, 2016 10:43
Pass array from Javascript to PHP

JS:

JSON.stringify(myArr)

PHP

json_decode(str_replace('\', '', $_POST['var']));

@henryhu712
henryhu712 / drupal_global_variables.md
Created April 14, 2016 02:51
Drupal 7 global variables

Custom Global Variables in Drupal

It is strange that I can't get global variables in Drupal 7 with &drupal_static or $GLOBALS. Eventually $_SESSION['myVar'] successes.

Note that to remember to initiate your $_SESSION variables before using them.

@henryhu712
henryhu712 / email_login.md
Last active April 12, 2016 03:03
Email login only, not email registration

The solution is from the issue:

logintoboggan module allows to register & login with email. user_registrationpassword module allows to set password and emai validation both configuration. But it does NOT work for both modules together.

Solution:

  • Enabled user_registrationpassword;
  • Abandon logintoboggan, instead, implement email login with the following:
@henryhu712
henryhu712 / redirect_form_submit.md
Created April 11, 2016 07:59
Redirect form submit on Drupal 7

In hook_form_alter(), there are 2 methods:

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_pass') {
    $form['#submit'][] = 'reflesh_current_path';
  }
}
function reflesh_current_path($form, &$form_state) {
  $current_path = current_path();

$form_state['redirect'] = $current_path;

git show bd61ad98 // Show detailed modification

It does not work to set expandtab off if you just comment out "set expandtab" in .vimrc. Instead, set under it as follows:

set expandtab

set noexpandtab

$HOME/.my.cnf

Put the following content in the .my.cnf file:

[client]
user = username
passowrd = yourpassword

Then, you can login like this:

@henryhu712
henryhu712 / multiple_value_select.md
Created March 28, 2016 09:27
Multiple values select

HTML

HTML structure

<label for="select-age">AGE</label>
<select id="select-age" multiple="multiple" size="5" name="age[]">
    <option value="under20" selected="selected">Under 20</option>
    <option value="20-24" selected="selected">20-24</option>

25-34

@henryhu712
henryhu712 / git_config.md
Last active March 27, 2016 22:03
git config

How many config files for git?

There are 3 places where we can set git config:

  • /etc/gitconfig

This is globe config. Write and read its settings:

git config --system ...