This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function MYMODULENAME_init() { | |
| if (arg(0) == 'admin') { | |
| // for module-specific css and JS | |
| drupal_add_js(drupal_get_path('module', 'MYMODULENAME') . '/toggle-chk.js'); | |
| } | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // this works, with the toggle-chk.js logic | |
| $form['blacklist'] = array( | |
| '#type' => 'checkbox', | |
| '#attributes' => array( 'data-unset-if-checked' => 'whitelist' ) | |
| ); | |
| $form['whitelist'] = array( | |
| '#type' => 'checkbox', | |
| '#attributes' => array( 'data-unset-if-checked' => 'blacklist' ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // toggle-chk.js | |
| // ------------------------------------------------------------------ | |
| // | |
| // functions to toggle the checked state of checkboxes. | |
| // | |
| // The Drupal FAPI is too cumbersome to use for setting up | |
| // mutually exclusive checkboxes. | |
| // | |
| // created: Wed Aug 3 15:53:33 2016 | |
| // last saved: <2016-August-03 16:17:04> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // this will not work | |
| $form['whitelist'] = array( | |
| '#type' => 'checkbox', | |
| '#states' => array( | |
| // uncheck this box when the other checkbox is checked. | |
| 'unchecked' => array( | |
| ':input[name="blacklist"]' => array('checked' => TRUE), | |
| ), | |
| ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $form['settings'] = array( | |
| '#type' => 'textfield', | |
| '#states' => array( | |
| // Only show this field when the 'toggle_me' checkbox is enabled. | |
| 'visible' => array( | |
| ':input[name="toggle_me"]' => array('checked' => TRUE), | |
| ), | |
| ), | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # -*- mode:shell-script; coding:utf-8; -*- | |
| # | |
| # pcopy is "preserve copy"? copy a file while preserving the directory structure. | |
| # | |
| # | |
| # Created: <Fri Jun 24 13:07:52 2016> | |
| # Last Updated: <2016-July-19 20:25:05> | |
| # | |
| # example: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // dateFormat.js | |
| // ------------------------------------------------------------------ | |
| // | |
| // format a date, easily. | |
| // | |
| // created: Mon Jul 18 11:24:41 2016 | |
| // last saved: <2016-July-18 11:47:12> | |
| ;(function (){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // humanizeDuration.js | |
| // ------------------------------------------------------------------ | |
| // | |
| // derived from https://github.com/EvanHahn/HumanizeDuration.js | |
| // | |
| // created: Mon Jul 18 11:13:09 2016 | |
| // last saved: <2016-July-18 11:15:53> | |
| ;(function (){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private LoadingCache<String, JWSVerifier> macVerifierCache; | |
| ... | |
| macVerifierCache = CacheBuilder.newBuilder() | |
| .concurrencyLevel(4) | |
| .maximumSize(1048000) | |
| .expireAfterAccess(10, TimeUnit.MINUTES) | |
| .build(new CacheLoader<String, JWSVerifier>() { | |
| public JWSVerifier load(String key) throws UnsupportedEncodingException { | |
| byte[] keyBytes = key.getBytes(StandardCharsets.UTF_8); | |
| // NB: this will throw if the string is not at least 16 chars long |