Skip to content

Instantly share code, notes, and snippets.

@slawekkolodziej
slawekkolodziej / file2data
Created August 20, 2011 18:54
Command line ruby script that converts binary files to html5 data uri (requires ruby 1.9)
#!/usr/bin/env ruby
require 'Base64'
require 'mime/types'
ARGV.each do |file|
puts ['File: ', file].join
puts [(MIME::Types.of file)[0], ';base64,', (Base64::encode64 (File.read file)).gsub("\n", "") ].join if FileTest::exist? file
puts "\n"
end
@slawekkolodziej
slawekkolodziej / touch-tooltip-fix.js
Created June 24, 2012 14:26
Highcharts tracker now don't prevent default behavior (like scrolling on touch devices).
Highcharts.Chart.prototype.callbacks.push(function(chart) {
var hasTouch = document.documentElement.ontouchstart !== undefined,
mouseTracker = chart.tracker,
container = chart.container,
mouseMove;
mouseMove = function (e) {
// let the system handle multitouch operations like two finger scroll
// and pinching
if (e && e.touches && e.touches.length > 1) {
@slawekkolodziej
slawekkolodziej / negative-column.js
Created August 21, 2012 15:51
color negative columns in Highstock
(function () {
var originalGetAttribs = Highcharts.seriesTypes.column.prototype.getAttribs;
Highcharts.seriesTypes.column.prototype.getAttribs = function () {
var merge = Highcharts.merge,
series = this,
points = series.points,
stateOptions = series.options.states,
negativeColor = series.options.negativeColor,
@slawekkolodziej
slawekkolodziej / connected-series.js
Created November 12, 2012 11:13
Connect multiple series visibility in Highcharts
Highcharts.Series.prototype.toggleConnected = function(visible) {
var visibility = visible || !this.visible,
series = this.options.connectedSeries,
l = series.length,
serie;
while (l--) {
serie = this.chart.get(series[l]);
serie.setVisible(visibility, false);
serie.checkbox && (serie.checkbox.checked = visibility);
@slawekkolodziej
slawekkolodziej / upcolor-fix.js
Created November 28, 2012 12:41
Fix bug with upColor in highcharts candlesticks
(function(HC){
var seriesTypes = Highcharts.seriesTypes;
seriesTypes.candlestick.prototype.getAttribs = function () {
seriesTypes.column.prototype.getAttribs.apply(this, arguments);
var series = this,
options = series.options,
stateOptions = options.states,
@slawekkolodziej
slawekkolodziej / reverse-flag-stacking.js
Created December 27, 2012 21:45
highcharts reverse flag stacking
(function (HC) {
var drawPoints = HC.seriesTypes.flags.prototype.drawPoints;
HC.seriesTypes.flags.prototype.drawPoints = function () {
drawPoints.call(this);
var points = this.points,
l, i;
for (i = 0, l = points.length; i < l; i++) {
@slawekkolodziej
slawekkolodziej / hackkrk.go
Last active December 16, 2015 15:19
hackkrk 4/2013 image upload
package main
import (
"encoding/json"
"fmt"
"image"
"image/color"
"image/draw"
"image/png"
"io/ioutil"
setInterval(function() {
var time = ((countdownTimestamp * 1000) - new Date()) / 1000,
h = Math.floor(time / 60),
s = Math.floor(time % 60),
title = h + ":" + s;
document.getElementsByTagName("title")[0].textContent = title;
}, 1000);
// ==UserScript==
// @name New ING Login Helper
// @description Creates a password input field for password managers
// @author Slawek Kolodziej
// @namespace slawekkolodziej
// @include https://login.ingbank.pl/mojeing/app/*
// @run-at document-end
// @version 1.2.0
// @grant none
// ==/UserScript==
@slawekkolodziej
slawekkolodziej / user-data.sh
Created May 18, 2016 11:04
AWS user data script for setting up a consul cluster using all instances in a given ECS
#!/bin/bash -xe
S3_BUCKET=foo
EXPECTED_SERVERS=2
yum install -y aws-cli
aws s3 cp s3://$S3_BUCKET/ecs.config /etc/ecs/ecs.config
aws s3 cp s3://$S3_BUCKET/docker.config /etc/sysconfig/docker
run_consul_agent() {
peers=""