This file contains 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
# Activates mod_security | |
SecRuleEngine On | |
# Only filters requests for /toto | |
SecRule REQUEST_FILENAME "!^/toto" "phase:1,skip:5,nolog" | |
# Only filters requests for rosalind | |
SecRule REQUEST_HEADERS:Host "rosalind\.abgenomica\.com" "phase:1,skip:5,nolog" | |
# Stores the number of visits in variable IP.pagecount | |
SecAction "phase:1,nolog,initcol:IP=%{REMOTE_ADDR},setvar:IP.pagecount=+1,expirevar:IP.pagecount=60" | |
# Denies requests when excessive | |
# 429 would be a better error status but mod_security rewrites it as 500 :-( |
This file contains 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
# spec/support/capybara/select2_helper.rb or features/support/select2_helper.rb | |
module Select2Helper | |
# @example | |
# select2 "Item", from: "select_id" | |
# select2 /^Item/, from: "select_id" | |
# | |
# @note Works with Select2 version 3.4.1. | |
def select2(text, options) | |
find("#s2id_#{options[:from]}").click |
This file contains 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
import android.content.Context; | |
import android.graphics.drawable.Drawable; | |
import android.util.AttributeSet; | |
import android.view.MotionEvent; | |
import android.view.View; | |
import android.widget.AutoCompleteTextView; | |
/** | |
* sub class of {@link android.widget.AutoCompleteTextView} that includes a clear (dismiss / close) button with | |
* a OnClearListener to handle the event of clicking the button |
This file contains 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
class ActiveRecord::Base | |
def self.import!(record_list) | |
raise ArgumentError "record_list not an Array of Hashes" unless record_list.is_a?(Array) && record_list.all? {|rec| rec.is_a? Hash } | |
return record_list if record_list.empty? | |
(1..record_list.count).step(1000).each do |start| | |
key_list, value_list = convert_record_list(record_list[start-1..start+999]) | |
sql = "INSERT INTO #{self.table_name} (#{key_list.join(", ")}) VALUES #{value_list.map {|rec| "(#{rec.join(", ")})" }.join(" ,")}" | |
self.connection.insert_sql(sql) |
This file contains 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
Install Snort and Barnyard2 virtualbox ubuntu 12.04 and 14.04 | |
Aug 2014: | |
Snort: | |
... in virtualbox set Network + Advanced 'Promiscuous Mode' to 'Allow All' | |
sudo apt-get install snort | |
ps aux | grep -i snort | |
sudo service snort stop | |
sudo nano /etc/snort/snort.conf |