Skip to content

Instantly share code, notes, and snippets.

@primozcigler
primozcigler / libela-elsi-g-325-weight.py
Created Dec 19, 2020
Sample code for serial (RS-232) connection between computer and Libela Elsi G 325 retail scale/weight
View libela-elsi-g-325-weight.py
import serial
"""
Tehtnica: Libela Elsi G 325 (https://www.libela-elsi.si/en/retail-scales/retail-scales-without-printer/)
Protokol: TISA-4 (0)
https://pypi.org/project/pyserial/
https://pyserial.readthedocs.io/en/latest/shortintro.html
Podatki za povezavo s tehtnice: 9600 8 N 1
@primozcigler
primozcigler / sum-templatemonster-sales-chrome-snippet.js
Last active Mar 2, 2018
Sum billing report values from templatemonster chrome snippet
View sum-templatemonster-sales-chrome-snippet.js
// Go to https://account.templatemonster.com/#/billing and scroll down to show enough BILLING HISTORY items
// Then run the script
{
const dateRegex = /aug \d+, 2017/i
// startDate = new Date('2017-8-1 00:00:00'),
// endDate = new Date('2017-9-1 00:00:00'),
allRows = Array.from($$( '.billing-history-operation' ));
@primozcigler
primozcigler / show_releases_from_to.sh
Last active Feb 3, 2017
Show all theme releases from the last month. The script should be placed in wp-content/themes/ and your themes should have .git/ in root.
View show_releases_from_to.sh
#!/bin/bash
#
# Gist: https://gist.github.com/primozcigler/e816919feea345ca393dc4ae90a872fd
# How to use it: https://primoz.blog/simple-bash-script-can-tell-releases-given-date-period/
if [[ $# -ne 2 ]]; then
echo "usage: $0 <start date> <end date>"
echo "<date> in format 'YYYY-MM-DD'"
exit
fi
@primozcigler
primozcigler / actions.php:513
Last active Dec 9, 2016
proposed change for edd-vat wp plugin
View actions.php:513
// https://support.cloudflare.com/hc/en-us/articles/200168236-What-does-CloudFlare-IP-Geolocation-do-
if ( apply_filters( 'edd_vat_use_cf_ip_header', false ) && ! empty( $_SERVER['HTTP_CF_IPCOUNTRY'] ) && 'XX' !== $_SERVER['HTTP_CF_IPCOUNTRY'] )
{
$this->ip_address_country = $_SERVER['HTTP_CF_IPCOUNTRY'];
return $this->ip_address_country;
}
@primozcigler
primozcigler / hightligh-day.js
Created Nov 30, 2015
highlight current day
View hightligh-day.js
// ==========
// = Highlight current date =
// ==========
(function() {
var
timeTable = $('.js--timetable'),
date = new Date();
if(timeTable.length > 0) {
date = date.getDay();
timeTable.children('[data-day="'+date+'"]').addClass('today');
@primozcigler
primozcigler / trello-changelog.js
Last active Nov 22, 2018
Trello changelog in console
View trello-changelog.js
(function() {
'use strict';
var changelog = [];
var date = new Date();
var padLeft = function ( str ) {
var pad = '00';
return pad.substring(0, pad.length - str.length) + str;
};
@primozcigler
primozcigler / http2hosting-specs.md
Last active Aug 29, 2015
http2hosting.com specs
View http2hosting-specs.md

Overview

HTTP2hosting.com is a website where users can find a list of all the providers (hosting companies) which provide hosting on a new HTTP/2 protocol.

This spec is not, by any stretch of the imagination, complete. All of the wording will need to be revised several times before it is finalized. The graphics and layout of the screens is shown here merely to illustrate the underlying functionality. The actual look and feel will be developed over time with the input of graphics designers and iterative user feedback.

This spec simply discusses what the user sees when they interact with HTTP2hosting.com.

Scenarios

@primozcigler
primozcigler / pt-working-hours.html
Last active Oct 31, 2016
ProteusThemes support working hours widget. Made with moment.js
View pt-working-hours.html
<html>
<head>
<title>support opening time</title>
<!-- deps: jquery, underscore.js, moment.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.4.0/moment.min.js"></script>
<script>
jQuery( document ).ready( function ( $ ) {
/**
@primozcigler
primozcigler / zendesk-api-script.js
Last active Aug 29, 2015
Using Zendesk API for article in multiple sections
View zendesk-api-script.js
// fix to display general questions in themes' sections
// using Zendesk API
// @link https://developer.zendesk.com/rest_api/docs/help_center/articles#list-articles
(function() {
if ( $( '.breadcrumbs a[href*="200506781"]' ).length ) { // 200506781 is ID of the section for general questions
var config = {
$articleList: $( 'ul.article-list' ),
tmpl: _.template( '<li><a href="<%= url %>"><%- title %></a></li>' ),
apiUrl: 'https://proteusthemes.zendesk.com/api/v2/help_center/sections/200132421/articles.json',
};
@primozcigler
primozcigler / class-pt-customize-control-range.php
Created Mar 17, 2015
Footer widgets layout customizer control.
View class-pt-customize-control-range.php
<?php
/**
* Range Control Class
*/
class WP_Customize_Range_Control extends WP_Customize_Control {
/**
* @access public
* @var string