Skip to content

Instantly share code, notes, and snippets.

View cschlyter's full-sized avatar

Carlos Schlyter cschlyter

  • Florianópolis - SC
View GitHub Profile
@cschlyter
cschlyter / attribute_to_file.php
Created April 24, 2013 17:07
[PHP] save attibute contents to a file.
$var_str = var_export($page, true);
file_put_contents('K:\filename.txt', $var_str);
@cschlyter
cschlyter / dropall.js
Created April 3, 2013 00:56
MongoDB: Drop all mongodb databases
// Usage: $ mongo dropAll.js
var dbs = db.getMongo().getDBNames()
for(var i in dbs){
db = db.getMongo().getDB( dbs[i] );
print( "dropping db " + db.getName() );
db.dropDatabase();
@cschlyter
cschlyter / toggleCheckbox.js
Created March 22, 2013 13:45
[javascript] toggle checkbox on/off
checkbox.attr("checked", !checkbox.attr("checked"));
@cschlyter
cschlyter / sortSelectOption.js
Last active October 2, 2024 10:05
[Javascript] Sort alphabetically the option elements of a select element by text.
function sortSelectOptions(selectElement) {
var options = $(selectElement + " option");
options.sort(function(a,b) {
if (a.text.toUpperCase() > b.text.toUpperCase()) return 1;
else if (a.text.toUpperCase() < b.text.toUpperCase()) return -1;
else return 0;
});
$(selectElement).empty().append( options );