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
| public static function indentJSON($json) { | |
| $result = ''; | |
| $pos = 0; | |
| $strLen = strlen($json); | |
| //$indentStr = ' '; | |
| //$newLine = "\n"; | |
| $indentStr = ' '; | |
| $newLine = "<br/>"; | |
| for($i = 0; $i <= $strLen; $i++) { $char = substr($json, $i, 1); if($char == '}' || $char == ']') { $result .= $newLine; $pos --; for ($j=0; $j<$pos; $j++) { $result .= $indentStr; } } $result .= $char; if ($char == ',' || $char == '{' || $char == '[') { $result .= $newLine; if ($char == '{' || $char == '[') { $pos ++; } for ($j = 0; $j < $pos; $j++) { $result .= $indentStr; } } } return $result; |
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
| <select id="sel1"> | |
| <option>Eric</option> | |
| <option>Joe</option> | |
| </select> | |
| <p id="eric" class="hidden">Hi, I'm eric</p> | |
| <p id="joe" class="hidden">Hi, I'm joe</p> | |
| $(document).ready(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
| _oMyController.setListener('firstEvent secondEvent', function(data) { | |
| if (data.is_second_event) { | |
| // do something specific just to the second event | |
| } | |
| // do something common to both events | |
| }); |
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 toggler(dom_element) { | |
| var inner = dom_element.innerHTML; | |
| var new_inner; | |
| if (inner.indexOf('Show') !== -1) { | |
| new_inner = inner.split('Show').join('Hide'); | |
| } else if (inner.indexOf('show') !== -1) { | |
| new_inner = inner.split('show').join('hide'); | |
| } else if (inner.indexOf('hide') !== -1) { | |
| new_inner = inner.split('hide').join('show'); |
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
| <?php | |
| function splitArray($array) { | |
| $array = $this->quoteArray($array); | |
| $fields = array_keys($array); | |
| $fields_with_ticks = array(); | |
| foreach($fields as $f) { | |
| $fields_with_ticks[] = '`'.$f.'`'; | |
| } | |
| $values = array_values($array); |
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
| var add_to_list = false; | |
| var result = []; | |
| $.each(checks, function(check) { | |
| // don't go through all the logic if we know we are going to append it | |
| if (add_to_list) { | |
| return true; | |
| } | |
| if (check()) { | |
| addToList = 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
| if (!items_by_name[name]) { | |
| items_by_name[name] = []; | |
| } | |
| items_by_name[name].push(item); | |
| // could we do something like this? | |
| items_by_name[name].smart_push(item, []) |
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 alerter(start, finish) { | |
| for (var i=0; i<=5; i++) { | |
| setTimeout(function() { | |
| alert(i); | |
| }, i*1000) | |
| } | |
| } |
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
| [ | |
| { | |
| "uid": "jhuttner", | |
| "owner": "jhuttner", | |
| "directories": ["/usr/local/adnxs"] | |
| }, | |
| { | |
| "uid": "jhuttner-personal", | |
| "owner": "jhuttner", | |
| "directories": ["/home/jhuttner/git-repos"] |
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 getName(callback) { | |
| client.select('name from people', function(err, result) { | |
| if (err) { | |
| callback(err); | |
| return; | |
| } else { | |
| // process result | |
| } | |
| }); | |
| } |