Skip to content

Instantly share code, notes, and snippets.

@artemave
artemave / index.js
Last active August 29, 2015 14:20
requirebin sketch
sinon = require('sinon');
sinon.spy(window, 'WebSocket')
// throws an error (see console)
new window.WebSocket("ws://example.com")
var a = {
b: function() {}
}
// works
@artemave
artemave / carrierwave.rb
Last active February 10, 2023 21:08
minimagick carrierwave round image (with white border)
# config/initializers/carrierwave.rb
require 'mini_magick'
module CarrierWave
module MiniMagick
# round _square_ image
def round
manipulate! do |img|
img.format 'png'
@artemave
artemave / index.html
Last active August 29, 2015 14:07
This is a programming test for u_n_b_o_x_e_d. I am not telling you what it is doing, so that other candidates can't google it out.
<!DOCTYPE html>
<html>
<head>
<title>Unboxed test</title>
<meta charset="utf-8" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js"></script>
<style type="text/css" media="screen">
body {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
@artemave
artemave / gist:a1e454a1900f105196e8
Last active August 29, 2015 14:04
ruby threads and io
require 'benchmark'
def do_stuff
`sleep 0.1`
end
Benchmark.bm(10) do |x|
x.report("sequential") do
10.times { do_stuff }
end
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>text to music</title>
<script type="text/javascript" charset="utf-8" src="./zepto.min.js"></script>
</head>
<body>
<textarea name="" id= rows="40" cols="80"></textarea>
<button type="submit">Muse</button>
source 'https://rubygems.org'
gem 'capybara'
gem 'poltergeist'
@artemave
artemave / gist:8714861
Last active August 29, 2015 13:55
css only spinner
//
// Spinner
// --------------------------------------------------
@import "variables";
@import "mixins";
.transform-mix (@deg, @delay) {
-webkit-transform: rotate(@deg) translate(0, -142%);
-webkit-animation-delay: @delay;
@artemave
artemave / bundler_defaults.md
Created December 5, 2013 10:20
Faster bundler

Requires bundler >= 1.4. gem install bundler --pre if your latest stable is still 1.3.X

Then set global bundler config:

# osx
number_of_cores=`sysctl -n hw.ncpu`

# linux
number_of_cores=`nproc`
@artemave
artemave / .vimrc
Last active December 24, 2015 03:19
Google selected text in vim
function! GoogleSearch()
normal gv"xy
let query = 'http://google.com/search?q=' .
\ system('perl -MURI::Escape -e "print uri_escape(q#'. escape(@x, '#"') .'#)"')
silent execute "! open " .
\ shellescape(query, 'yes_please_escape_vim_special_characters_too_thank_you')
endfunction
vnoremap <Leader>s :call GoogleSearch()<cr>

Integrating shopa with OpenCart

shopa's integration with OpenCart is in the form of a model class, ModelShopaButton. This contains methods for building the button on the product page, and for the HTML on the success page.

The Code

button.php is to be placed in catalog/model/shopa/button.php

Configuration