Skip to content

Instantly share code, notes, and snippets.

@vordan
vordan / alert-fade-out.js
Last active August 29, 2015 14:06
Bootstrap 3: Show alert for 3.5 seconds and fade it out
$('.alert').removeClass('hide').show().delay(1000).addClass("in").fadeOut(3500);
@vordan
vordan / jqgrid-initialize.js
Created July 4, 2015 17:30
jqGrid initialization
pub.grd_mailing_campaign.jqGrid({
url: 'bl/bl_mailing_campaign.php',
postData: {
action : function() {return 'mailing_campaign_list';},
record_count : function() {return _recipients_grid_record_count();},
},
datatype: 'json',
mtype: 'POST',
jsonReader : {repeatitems: false},
caption: '',
@vordan
vordan / show-ip.sh
Created July 16, 2015 05:39
Show IP address only in Linux
ip addr show tun0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1
@vordan
vordan / exclude-tables.sh
Created July 16, 2015 05:40
Exclude tables from mysqldump
mysqldump -u username -p database --ignore-table=database.table1 --ignore-table=database.table2 > database.sql
@vordan
vordan / php-session-expiration.ini
Last active April 27, 2017 10:03
PHP Session Expiration
/etc/php5/apache2/php.ini
session.gc_maxlifetime = 172800 # 48 hourssession.
cookie_lifetime = 0
/etc/php5/cli/php.ini
session.gc_maxlifetime = 14400 # 4 hourssession.
cookie_lifetime = 0
@vordan
vordan / round-precise.js
Created August 31, 2015 18:13
Precise rounding of numbers
function round_precise(value, exp) {
if (typeof exp === 'undefined' || +exp === 0)
return Math.round(value);
value = +value;
exp = +exp;
if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0))
return NaN;
@vordan
vordan / convert-encoding.sh
Created September 14, 2015 13:37
Convert file encoding
iconv -f ISO-8859-14 Agreement.txt -t UTF-8 -o agreement.txt
@vordan
vordan / skip-to-element-ckeditor.js
Last active June 27, 2021 09:15
Skipping to an element within the CKEditor by ID and setting the cursor focus within that element
// Skipping to an element within the CKEditor by ID and setting the cursor focus within that element.
// With the element in view, you'll attempt to insert the cursor at the beginning of the element using a Range.
// Firefox will actually insert the cursor for you but Chrome wont, so the Range step is necessary.
var element = evt.editor.document.getById('someHeading');
var range;
if(element) {
element.scrollIntoView();
@vordan
vordan / new_gist_file_0
Created December 1, 2015 19:31
Repair apt-get update
sudo rm -r /var/lib/apt/lists
sudo mkdir -p /var/lib/apt/lists/partial
sudo apt-get clean
sudo apt-get update
sudo apt-key list | grep expired
@vordan
vordan / new_gist_file_0
Created December 9, 2015 15:53
Bootstrap Date Picker
$('#user_edit_date_of_registration').datepicker('setValue', _row_model.value);
var _value = formatDateISO(nz($('#user_edit_date_of_registration').data('date')));
<div id="user_edit_date_of_registration" class="input-append date" data-index="" data-date="" data-date-format="dd-mm-yyyy" data-date-viewmode="months">
<input type="text" class="input-small">
<span class="add-on"><i class="fa fa-calendar"></i></span>
</div>