Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jesalg on github.
  • I am jesalg (https://keybase.io/jesalg) on keybase.
  • I have a public key whose fingerprint is 97B2 A152 B38F 12BF 08A2 6764 8176 2DFB 2471 D7BC

To claim this, I am signing this object:

@jesalg
jesalg / remove_dups.rb
Last active August 29, 2015 13:58
Simple function to remove duplicates
class Array
def remove_dups!
dup_count = Hash.new(0)
self.each do |val|
dup_count[val] += 1
end
dup_count.each do |val, count|
if count > 1
(count-1).times { self.delete_at self.rindex(val) }
class User extends AppModel {
public function beforeSave($options = array()) {
if (isset($this->data['User']['password'])) {
$this->data['User']['password'] = AuthComponent::password($this->data['User']['password'], $this->data['User']['email']);
}
return true;
}
}
@jesalg
jesalg / filter.js
Created December 2, 2011 22:36
JavaScript List Filter
// Custom css expression for a case-insensitive contains()
$.expr[':'].Contains = function(a,i,m){
return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0;
};
// Search function for Find Partners
var listFilter = function() {
var input = $("input.filterinput");
var list = $("#list");