Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@fotinakis
fotinakis / nginx-default-site.conf
Created May 13, 2021 18:33
Percy GitHub Enterprise - example nginx proxy configuration
daemon off;
events {
worker_connections 1024;
}
http {
server {
listen 443 ssl;
location / {
@fotinakis
fotinakis / example.rb
Created September 22, 2020 20:17
Percy Projects API example
# Could also use the low-level ruby API client to make these calls: https://github.com/percy/percy-client
@fotinakis
fotinakis / canvas-to-image.js
Created April 17, 2019 16:38
Convert WebGL canvas to static img in place
function canvasToImage(canvas) {
const {top, left, height, width} = canvas.getBoundingClientRect();
const mapImage = document.createElement('img');
mapImage.setAttribute('src', canvas.toDataURL('image/png'));
mapImage.setAttribute('style', `position: absolute; z-index: 2147483638; top: ${top}px; left: ${left}px; width: ${width}px; height: ${height}px;`);
document.body.appendChild(mapImage);
};
// Convert all canvas elements on the page to images.
document.querySelectorAll('canvas').forEach((canvas) => {
@fotinakis
fotinakis / gist:ea3e315d99b3a3d301fd98b74e5c0728
Created June 6, 2018 04:53
git setup for maximum risk/reward
git config --global push.default current
git config --global pull.default current
@fotinakis
fotinakis / percy_loader.rb
Created October 3, 2017 22:22
Custom Percy::Capybara SprocketsLoader that changes path
class CustomLoader < Percy::Capybara::Loaders::SprocketsLoader
def build_resources
super.map do |resource|
resource.resource_url = resource.resource_url.gsub('//localhost:3000/', '/')
end
end
end
Percy::Capybara.use_loader(CustomLoader)
@fotinakis
fotinakis / circle ci
Last active September 27, 2018 02:34
Percy manual build finalization for Circle 2.0 and other parallel CI workflows.
jobs:
# ...
percy_finalize:
docker:
- image: circleci/node:10
steps:
- run: npm install percy-client
- run: node .circleci/percy-finalize.js
workflows:
@fotinakis
fotinakis / gist:ec5a304286738f7e8f401289f2d6b1d0
Last active May 17, 2017 17:44
percy-capybara manual parallelization setup
# Tell Percy that this is a parallelized build. Because we separately finalize
# Percy builds, this should remain "2" no matter the actual number of nodes.
#
# Set this environment variable:
PERCY_PARALLEL_TOTAL=2
# In your spec_helper, only call `initialize_build` and not finalize:
config.before(:suite) { Percy::Capybara.initialize_build }
# Do not call `finalize_build`.
@fotinakis
fotinakis / native-loader-remote-example.rb
Created April 24, 2017 16:07
Percy native loader remote example
# Example to use Percy against a remote host.
# Requires: poltergeist gem, and phantomjs.
#
# This uses the percy-capybara native loader, which is slower and less accurate
# than other loaders. See:
# https://percy.io/docs/clients/ruby/capybara-other#non-rails-asset-setup
require 'percy/capybara'
require 'capybara/poltergeist'
@fotinakis
fotinakis / zoomTestContainer.js
Created November 29, 2016 19:20
Ember zoomTestContainer
$('#ember-testing-container').css('height', '100%');
$('#ember-testing-container').css('width', '100%');
$('#ember-testing').css('zoom', '100%');
@fotinakis
fotinakis / bash
Created September 30, 2016 18:17
List numbers of connection states with netstat
netstat -nat | awk '{print $6}' | sort | uniq -c | sort -n