Skip to content

Instantly share code, notes, and snippets.

View adamscybot's full-sized avatar

adamscybot adamscybot

  • Informatica
  • London
View GitHub Profile
@adamscybot
adamscybot / 3-layer-resource-api.py
Created February 14, 2012 16:29
Bug when posting 3-layer resource
class ServiceResource(ModelResource):
manager = fields.ToOneField(UserResource, 'manager',full=True)
area = fields.ToOneField(AreaResource, 'area',full=True)
specification = fields.ToManyField('services.api.ServiceSpecResource','servicespec_set',full=True)
class Meta:
queryset = Service.objects.all()
resource_name = 'service'
class ServiceSpecResource(ModelResource):
service = fields.ToOneField(ServiceResource,'service')
@adamscybot
adamscybot / get-balance.js
Created June 30, 2014 20:29
Retrieve total balance of student loan from student finance direct pages
// First go to https://secure.studentfinance.direct.gov.uk/ and log in.
// Now go to https://secure.studentfinance.direct.gov.uk/customer/payments/view?service=direct/1/Home/listPayments_TablePages.pages_linkPage&sp=AHome%2FlistPayments_TableView&sp=1
// Now open the console and put in:
//
// var jq = document.createElement('script');
// jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js";
// document.getElementsByTagName('head')[0].appendChild(jq);
// jQuery.noConflict();
//
// Press enter.
@adamscybot
adamscybot / usePercentageColumns.js
Created August 18, 2020 11:36
Reac table v6 percentage column width plugin hook
/**
* This plugin hook for React table provides the ability for percentage
* widths to be provided in the column definitions, whilst maintaining the
* ability to resize those columns.
*/
export const usePercentageColumns = hooks => {
hooks.useInstance.push(useInstance)
hooks.getRowProps.push(getRowStyles)
hooks.getHeaderProps.push(getHeaderProps)
hooks.getCellProps.push(getCellProps)
@adamscybot
adamscybot / Cypress isEqualNode.ts
Last active November 2, 2024 00:11
Cypress example to check if a set of elements changed in a meaningful way via `isEqualNode`. Useful for detecting a change in a list of elements (positionally) according to each of their defining characteristics. Avoids detecting recreated/change elements that are really the same (e.g. ignore attr order, like for like replacements)
// This method of detecting changes in a list of elements is a sledgehammer and probably memory intense if your DOM is already memory intense.
// But leaning on the semantics of the web platforms `isEqualNode` is useful if those semantics are what you are after.
//
// The semantics are much closer to a "meaningful change" than comparing element references. But dont go all the way to
// a "user visible change" guarantee since that depends if things like certain possible attribute changes amount
// to a visible change in your app.
//
// It differs from the usual way of detecting changes (which should remain the usual, this gist is for edge cases). The
// usual way being targetted comparison of some individual aspects of the elements, e.g. visible text. The difference is
// that this is a good middle ground for detecting "any characteristic change" of an element in cases where perhaps you need