Skip to content

Instantly share code, notes, and snippets.

@illarionvk
illarionvk / get-subscriptions.sh
Last active October 7, 2021 07:08
ReCharge API Curl requests
#! /bin/bash
set -euxo pipefail
TOKEN=INSERT_YOUR_TOKEN
# Get subscription count
curl -i -H "X-Recharge-Access-Token: ${TOKEN}" \
-X GET 'https://api.rechargeapps.com/subscriptions/count?created_at_min=2017-09-01T00:00:00'
@illarionvk
illarionvk / waypoint-instances.js
Created May 22, 2017 19:22
Find Waypoint instances by DOM element
'use strict';
/*
* Find Waypoint instances by DOM element
*/
var compact = require('lodash/fp/compact');
var filter = require('lodash/fp/filter');
var flatten = require('lodash/fp/flatten');
var forEach = require('lodash/fp/forEach');
@illarionvk
illarionvk / sprite.sh
Created April 13, 2015 08:54
Create a vertical image sprite
montage *.png -tile 1x10 -geometry 128x128+0+2 -background transparent sprite.png
@illarionvk
illarionvk / convert-video.sh
Created April 2, 2015 09:03
Convert video file for website with poster image
#!/bin/bash
for files in *.wmv
do
avconv -y -i "$files" -ss 0 -vframes 1 "${files%.wmv}_poster.jpg"
avconv -y -i "$files" -vcodec libtheora -acodec libvorbis -b:v 500k "${files%.wmv}.ogv"
avconv -y -i "$files" -pix_fmt yuv420p -c:v libx264 -b:v 500k -crf 30 -preset slower -profile:v Main -level 31 -c:a aac -b:a 192k -strict experimental "${files%.wmv}.mp4"
done
@illarionvk
illarionvk / add-range-to-dropdown.js
Created September 30, 2014 09:01
Automate adding numeric range to dropdown - Bold Apps Product Options app for Shopify
// Run the code in developer console, done best through Chrome's Javascript snippets
// First add LoDash
$('body').append('<script src="//cdn.jsdelivr.net/lodash/2.4.1/lodash.min.js"></script>');
// Add range of steps to Bold Apps Product Option dropdown
(function() {
var valueRange = _.range(-5, 5.25, 0.25);
function addNewValue(value) {
@illarionvk
illarionvk / gulpfile.coffee
Created July 9, 2014 14:00
Using child_process.exec to launch Sass on file change
exec = require('child_process').exec
_ = require('lodash')
autoprefix = require('gulp-autoprefixer')
chalk = require('chalk')
concat = require('gulp-concat')
es = require('event-stream')
gulp = require('gulp')
gutil = require('gulp-util')
order = require('gulp-order')
plumber = require('gulp-plumber')
@illarionvk
illarionvk / _clearfix.scss
Created April 4, 2014 14:17
Clearfix mixin to do clear floats
@mixin clearfix {
*zoom:1;
&:before, &:after { content: " "; display: table; }
&:after { clear: both; }
}
@illarionvk
illarionvk / deprecation-warning-trigger
Created March 28, 2014 20:57
Sass 3.3 deprecation warning trigger
//************************************************************************//
// Generate a variable ($all-text-inputs) with a list of all html5
// input types that have a text-based input, excluding textarea.
// http://diveintohtml5.org/forms.html
//************************************************************************//
$inputs-list: 'input[type="email"]',
'input[type="number"]',
'input[type="password"]',
'input[type="search"]',
'input[type="tel"]',
@illarionvk
illarionvk / extract_data.js
Created January 13, 2014 09:04
Find elements in 50 HTML files, extract data and create Jekyll post files with YAML metadata using Node.js
// 1. Get list of files
// 2. For each file:
// 2.1 Read a file
// 2.2 Find required data
// 2.3 Put the information in a JSON object
// 3. Convert JSON object to YAML
// 4. Write new Markdown file in _posts folder
var fs = require('fs')
@illarionvk
illarionvk / hide-vertical-scrollbar-in-code-example.js
Created November 30, 2013 10:48
Remove vertical scrollbars from Jekyll syntax-highlighted code examples by adding 1px to the wrapper div height.
var codeblocks = document.getElementsByClassName('highlight');
for (var i = 0; i < codeblocks.length; ++i) {
var item = codeblocks[i];
// console.log("Old height:" + " " + item.offsetHeight);
item.style.height = item.offsetHeight + 1 + 'px';
// console.log("New height:" + " " + item.offsetHeight);
}