Skip to content

Instantly share code, notes, and snippets.

@ragulka
ragulka / functions.php
Created March 10, 2017 07:19
Add custom fields to PDF Product Vouchers
<?php
// add custom voucher fields - see: https://cl.ly/323U011F0C2u
add_filter( 'wc_pdf_product_vouchers_voucher_fields', 'my_voucher_fields' );
function my_voucher_fields( $fields ) {
$fields['my_property'] = array(
'data_type' => 'property',
'label' => __( 'My property', 'my-plugin' ),
@ragulka
ragulka / convert.php
Created September 5, 2016 07:44
Convert Dashlane Export CSV to a 1Password compatible CSV
<?php
// Place this file in th same directory with your Dashlane Export.csv
// and run using the following command in your Terminal:
//
// php convert.php
//
// This will create a file named fixed.csv, which should work for
// 1Password 6 import. In addition to moving fields into correct places,
// this will also try to remove hashed lines {...}, as well as lines where
@ragulka
ragulka / index.html
Last active August 29, 2015 13:59
Log browser javascript errors in Selenium tests with camme/webdriverjs
<!-- In your HTML
We need to catch errors globally.
This example shows how to do it on test environment only, in EJS on node.js.
The principle remains the same regardless of backend or templating language
-->
<% if (env === 'test') { %>
<!-- Error logging for selenium -->
<script type="text/javascript">
"use strict";
@ragulka
ragulka / gist:10458018
Last active August 29, 2015 13:59
Injecting and executing Javascript in Selenium tests using camme/webdriverjs
// This snippets shows how you can inject and execute Javascript in your Selenium tests using camme/debriverjs.
// This particular example uses jQuery to get the count of list-item elements on the page and returns it.
// In the callback you can then access the returned value as `result.value`
it('must have 4 list-item elements', function (done) {
client
.execute(function() {
return $('ul li').length;
}, [], function (err, result) {
result.value.must.eql(4);
@ragulka
ragulka / gist:6412932
Created September 2, 2013 13:36
Use CSS Specifity calculator (https://github.com/keeganstreet/specificity) to get the applied CSS rule for an element. Based on http://jsfiddle.net/markcoleman/TKHpV/5/ and http://jsfiddle.net/5Cyy3/ Basically, this is window.getMatchedCSSStyles for all browsers, plus the extra benefit of actually getting the applied rule. For example, you can d…
/**
* Calculates the specificity of CSS selectors
* http://www.w3.org/TR/css3-selectors/#specificity
*
* Returns an array of objects with the following properties:
* - selector: the input
* - specificity: e.g. 0,1,0,0
* - parts: array with details about each part of the selector that counts towards the specificity
*/
var SPECIFICITY = (function() {
.twitter-typeahead .tt-hint {
border: 0;
padding: 0;
}
.tt-dropdown-menu {
min-width: 160px;
margin-top: 2px;
padding: 5px 0;
background-color: #fff;
@ragulka
ragulka / jquery.ui.popover.js
Created March 26, 2012 18:37
Popover widget for jQuery UI
(function($, undefined) {
var uiPopoverClasses = 'ui-popover ';
var openPopover = null;
$.widget("ui.popover", {
// Default options
options: {
offsetX: 0,