Skip to content

Instantly share code, notes, and snippets.

Avatar

henryhu712 henryhu712

  • WYSJ LLC
  • Beijing, China
View GitHub Profile
View span_with_width.md

Set span with width

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

JS:

JSON.stringify(myArr)

PHP

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

View drupal_global_variables.md

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 Apr 12, 2016
Email login only, not email registration
View email_login.md

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 Apr 11, 2016
Redirect form submit on Drupal 7
View redirect_form_submit.md

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;

View git_basic.md

git show bd61ad98 // Show detailed modification

View spf13vim_expandtab_off.md

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

View login_mysql_without_password.md

$HOME/.my.cnf

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

[client]
user = username
passowrd = yourpassword

Then, you can login like this:

View multiple_value_select.md

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

View git_config.md

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 ...