Skip to content

Instantly share code, notes, and snippets.

View storuky's full-sized avatar

Kononenko Pavel storuky

View GitHub Profile
app.directive('clickOutside', ['$document', function ($document) {
return {
restrict: 'A',
scope: {
clickOutside: '&'
},
link: function (scope, el, attr) {
var handler = function (e) {
if (el !== e.target && !el[0].contains(e.target) && document.body.contains(e.target)) {
scope.$apply(function () {
module Cacheable
extend ActiveSupport::Concern
included do
after_commit :clear_cache
private
def clear_cache
Rails.cache.delete_matched(/#{self.class.to_s}\.cache\.all/)
Rails.cache.delete_matched(/#{self.class.to_s}\.cache\.find\(#{self.id}\)/)
module Sidekiq::Middleware::DefaultUrlOptions
class Client
def call(worker_class, msg, queue, redis_pool)
msg['default_url_options'] = ActionMailer::Base.default_url_options
yield
end
end
class Server
def call(worker, msg, queue)
@storuky
storuky / gist:73e202707d3c7e402ad2
Last active March 22, 2016 11:41
Flickity lightbox
app.directive('lightbox', ['$compile', '$timeout', '$rootScope', 'Image', function($compile, $timeout, $rootScope, Image) {
// Runs during compile
return {
// name: '',
// priority: 1,
// terminal: true,
scope: {
images: "=",
allowDestroy: "=",
upload: "="
GIT
remote: [email protected]:storuky/carrierwave-crop.git
revision: 8c5a446eda9eeedc20a7a6668744e7f41db4f0cd
branch: master
specs:
carrierwave-crop (0.1.2)
carrierwave
jquery-rails
rails (>= 3.2)
// api.js
export const GetAllProjects = () => Vue.http.get('/swage/v1/projects')
// resources/Project.js
import Vue from 'vue';
export default Vue.resource(
"v1/projects{/id}",
@storuky
storuky / example.js
Last active December 27, 2018 10:29
// api.js
export const GetAllProjects = () => Vue.http.get('/swage/v1/projects')
// resources/Project.js
import Vue from 'vue';
export default Vue.resource(
"swage/v1/projects{/id}",
@storuky
storuky / transform.js
Last active February 10, 2019 11:27
transform
spread(value) {
return (Math.random() - 0.5) * value * 2
},
transformGeneratePersonObjects(){
// we could do something much smarter with object layout, but let's keep it simple
const { x, y } = this.baseObject.position;
// iterate over our Shareholders array
this.shareholders.forEach(shareholder => {
const position = {
const { log } = console;
const foo = word => {
const bar = word => setTimeout(() => log(word), word.length)
bar(word);
return bar;
}
const operation = a => b => c => a * b + c;
operation('2')(3)('4')