Skip to content

Instantly share code, notes, and snippets.

View chrisst's full-sized avatar

Chris Stephens chrisst

View GitHub Profile
@chrisst
chrisst / gist:4272284
Created December 12, 2012 22:34
Truefit AB Test code
<script>
console.log('Truefit activation Promowell');
require([ 'order!jquery', ], function($) {
console.log('inside the require');
$.subscribe('load.truefit', function(context) {
// truefit loaded
console.log('Subscribing to truefit');
tfc.event('tfc-fitrec-product', 'render', function(context) {
// truefit rendered, activate AB test
<script type="text/javascript">
require([
'order!jquery',
'order!http://bck-cdn.truefitcorp.com/fitrec/bck/js/jqModal.js',
'order!http://bck-cdn.truefitcorp.com/fitrec/bck/js/fitrec.js'
], function($) {
tfc.event('tfc-fitrec-product', 'render', function(context) {
if ($('.tfc-fitrec-result.success').length > 0 || $('.tfc-fitrec-result.nouser').length > 0) {
window.optimizely.push(["activate", 152385827]);
@chrisst
chrisst / gist:6127166
Created July 31, 2013 23:28
SeleniumPercentageOff fix
commit 6d12abfa57e15e49e13b8a2fae9d56f35261a7c0
Author: Chris Stephens <cstephens@backcountry.com>
Date: Wed Jul 31 17:08:39 2013 -0600
[FIX_SELENIUM] fix the sale perctange off test so it doesn't include products that have a range of sale prices
diff --git a/qa-automation-tests/src/main/java/com/backcountry/component/retail/BasePLPPages.java b/qa-automation-tests/src/main/java/com/backcountry/component/retail/BasePLPPages.java
index 960d357..ce11290 100644
--- a/qa-automation-tests/src/main/java/com/backcountry/component/retail/BasePLPPages.java
+++ b/qa-automation-tests/src/main/java/com/backcountry/component/retail/BasePLPPages.java
@chrisst
chrisst / gist:4f73aec279c706dc154c
Last active August 29, 2015 14:05
polling_with_promises
checkForField: function(url, field) {
var deferred = Q.defer();
var count = 0;
var success = function(resp) {
if (count > 9) {
deferred.reject();
return;
}
count++;
console.log("counting " + count);
class ShirtSerializer(serializers.ModelSerializer):
campaign = serializers.SlugRelatedField(slug_field='slug')
shirt_text = ShirtTextSerializer(many=True, allow_add_remove=True,)
shirt_artwork = ShirtArtworkSerializer(many=True, allow_add_remove=True,)
shirt_text = ShirtTextSerializer(many=True,)
shirt_artwork = ShirtArtworkSerializer(many=True,)
skus = SkuSerializer(many=True, required=False,)
def get_identity(self, data):
Traceback (most recent call last):
File "/Users/chrisst/.virtualenvs/redditmade/lib/python2.7/site-packages/django/core/handlers/base.py", line 112, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/chrisst/.virtualenvs/redditmade/lib/python2.7/site-packages/rest_framework/viewsets.py", line 78, in view
return self.dispatch(request, *args, **kwargs)
File "/Users/chrisst/.virtualenvs/redditmade/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 57, in wrapped_view
return view_func(*args, **kwargs)
File "/Users/chrisst/.virtualenvs/redditmade/lib/python2.7/site-packages/rest_framework/views.py", line 400, in dispatch
response = self.handle_exception(exc)
File "/Users/chrisst/.virtualenvs/redditmade/lib/python2.7/site-packages/rest_framework/views.py", line 397, in dispatch
@chrisst
chrisst / vba_sux
Created October 14, 2014 01:21
visual basic message box
' MsgBox means that when the macro is run a message box (no input space) will pop up
' Add in an option to end the macro if the person doesn't want to continue
imavariable = MsgBox("Please Note, this macro sometimes takes a while to run. Do you want to continue?", vbYesNo)
If imavariable = vbNo Then Exit Sub
' InputBox means that when the macro is run a pop-up box will ask for input
' Put in the verbiage you want shown in the pop up box
InvoiceNo = InputBox("Invoice Number (ex:B-SP-14-xxx)")
InvoiceDate = InputBox("Invoice Date (format: mm/dd/yyyy)")
MonthSvc = InputBox("Month of Incurred Services Being Invoiced (ex: Sep 2014)")
Dim jan, feb, mar, apr, may, jun, july, aug, sep, nov, dec as String
' I'm calling it a string here cause I didn't want to deal with parsing numbers from euros. If the values are straight numbers you can always swap to Integer, Long, Currency, etc (https://msdn.microsoft.com/en-us/library/office/gg264241.aspx)
' loop over the rows in the first sheet
for sheet1_row_num = 1 To 50
{
jan = cell(sheet1_row_num, 6).Value
feb = cell(sheet1_row_num, 7).Value
mar = cell(sheet1_row_num, 8).Value
...
@chrisst
chrisst / fooz.adoc
Last active January 5, 2016 02:07
foo
//
// Export Commands
// ===============
// to HTML5:
// asciidoc -b html5 -a icons -a theme=default -a data-uri -a toc2 -a pygments -f javaeeworkshop.conf javaeeworkshop.asciidoc
//
// to DocBook:
// asciidoc -b docbook -dbook -f javaeeworkshop.conf javaeeworkshop.asciidoc
//
// to PDF (using fop):
while (true) {
me = db.currentOp()
conns = me['inprog']
print(conns)
conns.forEach(function(conn){
if (conn['locks'] && conn['locks']['^sm_meta'] == "R") {
print(conn['opid'])
db.killOp(conn['opid'])
}
})