Skip to content

Instantly share code, notes, and snippets.

@nhatnx
nhatnx / embedded-file-viewer.md
Created October 13, 2017 08:14 — forked from tzmartin/embedded-file-viewer.md
Embedded File Viewer: Google Drive, OneDrive

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')

http://view.officeapps.live.com/op/view.aspx?src=[OFFICE_FILE_URL]

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>
</iframe>

OneDrive Embed Links

@nhatnx
nhatnx / order_by_enum_field_in_mysql.txt
Created November 27, 2017 10:35
ORDER BY “ENUM field” in MYSQL
ENUM values are sorted based on their index numbers, which depend on the order in which the enumeration members were listed in the column specification. For example, 'b' sorts before 'a' for ENUM('b', 'a'). The empty string sorts before nonempty strings, and NULL values sort before all other enumeration values.
To prevent unexpected results when using the ORDER BY clause on an ENUM column, use one of these techniques:
Specify the ENUM list in alphabetic order.
Make sure that the column is sorted lexically rather than by index number by coding ORDER BY CAST(col AS CHAR) or ORDER BY CONCAT(col).
@nhatnx
nhatnx / update_initial_state_form_controls.js
Created November 28, 2017 11:34
Update initial state of form controls to modify underlying form.reset() values
$('input').attr('value', function() { return this.value });
$('textarea').prop('innerHTML', function() { return this.value });
$(':checked').attr('checked', 'checked');
$(':selected').attr('selected', 'selected');
$(':not(:checked)').removeAttr('checked');
$(':not(:selected)').removeAttr('selected');
@nhatnx
nhatnx / dabblet.css
Created December 4, 2017 04:46 — forked from bhargav2785/dabblet.css
Pure CSS wave effect *
/** Pure CSS wave effect **/
div.wave{
position: relative;
width: 100%;
}
div.wave > span{
float: left;
width: 10%;
height: 200px;
animation: animate 1.5s ease-in-out alternate infinite;
@nhatnx
nhatnx / control_size_input_number_arrow_buttons.css
Created December 6, 2017 05:19
Control the size of input type=“number” arrow buttons
input[type=number] {
height: 30px;
}
input[type=number]:hover::-webkit-inner-spin-button {
width: 14px;
height: 30px;
}
@nhatnx
nhatnx / [MySQL] Order By MIXED columns.sql
Last active December 25, 2017 05:15
ORDER BY column which is a mixed of multi columns with some criteria
SELECT * FROM table
ORDER BY
CONCAT
(CASE WHEN (security_title_name IS NOT NULL AND security_title_name != '') AND (release_date IS NOT NULL AND release_date != '') AND (release_date > CURRENT_DATE) THEN security_title_name
ELSE official_title_name
END)
ASC
@nhatnx
nhatnx / ignore_events_on_element.css
Created January 10, 2018 04:37
Ignore events (click, touch...) on an element using CSS3
.element {
pointer-events: none;
}
@nhatnx
nhatnx / clear_ckeditor_content_has_only_spaces.php
Created January 17, 2018 04:15
Clear CKEditor content which has only spaces
<?php
$content = trim(preg_replace('/<p>(\s+|&nbsp;)+<\/p>/', ' ', $content));
?>
@nhatnx
nhatnx / [PHP] Array delete by value.php
Created January 17, 2018 11:39
PHP array delete by value (not key)
<?php
if (($key = array_search($del_val, $messages)) !== false) {
unset($messages[$key]);
}
?>
@nhatnx
nhatnx / break_jquery_each_loop.js
Created February 28, 2018 06:24
Break a jQuery each Loop
// To break a <var>$.each</var> loop, you have to <var>return false</var> in the loop callback.
// Returning <var>true</var> skips to the next iteration, equivalent to a <var>continue</var> in a normal loop.
$.each(array, function(key, value) {
if(value === "foo") {
return false;
}
});