Skip to content

Instantly share code, notes, and snippets.

@yemster
yemster / snapshotter.py
Created Aug 19, 2019 — forked from nguyendangminh/snapshotter.py
AWS EBS snapshotter
View snapshotter.py
#!/usr/bin/env python
# Shameless copy from qwiklab
import boto.ec2, os, datetime
MAX_SNAPSHOTS = 2 # Number of snapshots to keep
# Connect to EC2 in this region
region = os.environ.get('EC2_REGION')
connection = boto.ec2.connect_to_region(region)
View gfonts-preview.html
<!DOCTYPE html>
<html>
<head>
<title>Google Fonts Preview</title>
<style>
#preview {
margin: 0 auto;
text-align: center;
width: 80%;
}
@yemster
yemster / opera-vpn.md
Created Oct 7, 2017 — forked from spaze/opera-vpn.md
Opera VPN behind the curtains is just a proxy, here's how it works
View opera-vpn.md

When setting up (that's immediately when user enables it in settings) Opera VPN sends few API requests to https://api.surfeasy.com to obtain credentials and proxy IPs, see below, also see The Oprah Proxy.

The browser then talks to a proxy de0.opera-proxy.net (when VPN location is set to Germany), it's IP address can only be resolved from within Opera when VPN is on, it's 185.108.219.42 (or similar, see below). It's an HTTP/S proxy which requires auth.

When loading a page with Opera VPN enabled, the browser sends a lot of requests to de0.opera-proxy.net with Proxy-Authorization request header.

The Proxy-Authorization header decoded: CC68FE24C34B5B2414FB1DC116342EADA7D5C46B:9B9BE3FAE674A33D1820315F4CC94372926C8210B6AEC0B662EC7CAD611D86A3 (that's sha1(device_id):device_password, where device_id and device_password come from the POST /v2/register_device API call, please note that this decoded header is from another Opera installation and thus contains

@yemster
yemster / module-boilerplate.js
Created Oct 5, 2017
Snippet / boilerplate or starting new modules / library closures. --// Parked here until I find a better home for it
View module-boilerplate.js
MyModule = MyModule || {}
MyModule.Foo = (function() {
// declare private methods
var _myPrivateMethod = function() {
console.log('\t >>>>> I am a private method call <<<<<<')
}
// expose public methods
return {
myPublicMethod: function(someArgs) {
@yemster
yemster / adequate-template-engine.js
Last active Jan 28, 2021
Adequate template engine - Minimalist but entirely more than adequate Js templating engine
View adequate-template-engine.js
/*****************************************
* Usage:
* engine = Adqt.TemplateEngine
* template = 'My name is <% this.name %>'
* hash = { name: 'Yemi' }
*
* compiled = engine.compile(template) // => "var r=[]; r.push("My name is "); r.push( this.name ); return r.join("");"
* engine.render(compiled, hash) // => My name is Yemi
*
* engine.render(compiled, { name: 'Mike' }) // => My name is Mike
View css-to-select-range-of-children.html
<!DOCTYPE html>
<html>
<head>
<style>
/* How to select a range of children
* (Here, 3rd-7th children, inclusive):
*/
ul li:nth-child(n+3):nth-child(-n+7) {
outline: 1px solid #0f0;
}
View gist:0848c37a6a280eb1b626dcbcff92dc62

Are your Ruby HTTPS API calls secure?

Let's check:

2.0.0-p481 :001 > OpenSSL::SSL::SSLContext::DEFAULT_PARAMS
 => {:ssl_version=>"SSLv23", :verify_mode=>1, :ciphers=>"ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW", :options=>-2147482625}
2.0.0-p481 :002 > rating = JSON.parse(RestClient::Resource.new("https://www.howsmyssl.com/a/check" ).get)['rating']
 => "Bad"
@yemster
yemster / svg-ico-sprite-mixin.scss
Created Mar 1, 2017
Automate SVG Sprite Background Image Variations with a SCSS Mixin
View svg-ico-sprite-mixin.scss
/*
Automate SVG Sprite Background Image Variations with a SCSS Mixin
- see egghead.io video: https://egghead.io/lessons/css-automate-svg-sprite-background-image-variations-with-a-scss-mixin
• This utilises a sass mixing to generate the necessary code for the icons within the sprite
*/
$ico-width-default: 3em;
$ico-width-small: 2em;
$icons: plug, star, umbrella;
@yemster
yemster / fb-open-graph.liquid
Last active Aug 24, 2020 — forked from chrisjhoughton/fb-open-graph.liquid
Facebook Open Graph meta tags for Shopify. Add this as a snippet called "fb-open-graph.liquid" in your theme, and then add `{% render 'fb-open-graph' %}` to your `theme.liquid` file.
View fb-open-graph.liquid
{% if template contains 'product' %}
<meta property="og:type" content="product">
<meta property="og:title" content="{{ product.title | strip_html | escape }}">
<meta property="og:category" content="{{ product.type }}" />
{% for image in product.images limit:3 %}
<meta property="og:image" content="http:{{ image.src | product_img_url: 'master' }}">
<meta property="og:image:secure_url" content="https:{{ image.src | product_img_url: 'master' }}">
{% endfor %}
<meta property="og:price:amount" content="{{ product.price | money_without_currency | stip_html | escape | remove: ',' }}">
<meta property="og:price:currency" content="{{ shop.currency }}">
@yemster
yemster / svg-image-replacer.js
Created Oct 20, 2016
SVG IMG replacer: Replace a given IMG linking to an SVG file with the actual SVG file injected into the page.
View svg-image-replacer.js
// Extract and inject SVG logo into document
$(document).ready(function() {
$('img[src*=".svg"]').each(function() {
var $img = jQuery(this), $svg,
imgURL = $img.attr('src').replace(/\.svg(\?\w+)/,'.svg'), // strip timestaps from img URL
imgAttributes = $img.prop("attributes");
$.get(imgURL, function(data) {
$svg = jQuery(data).find('svg'); // Get the SVG tag, ignore the rest
$svg = $svg.removeAttr('xmlns:a'); // Remove any invalid XML tags