View Tez
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I am attesting that this GitHub handle basgys is linked to the Tezos account tz1LvHJjweC8ARpHfATq16ToiXZDAvsNBDNM for tzprofiles | |
sig:edsigtw5NpWReH1QoSUnWH9fMq9cdpSqNY643GvCxjnFmDf8UfGMD3V24xyPizGR1sjhUQifNhiMquu6Y9wvfrYdiNcEDuWqoKe |
View clustering.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math" | |
"sort" | |
"strings" | |
"github.com/pbnjay/clustering" | |
) |
View gist:7098697
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UberRelation | |
include Enumerable | |
def initialize(scopes) | |
scopes.kind_of?(Array) or raise ArgumentError.new("Argument scopes is not an array!") | |
@scopes = scopes | |
end | |
def each(&block) | |
block_given? ? load.each{|scope| block.call(scope)} : load |
View soft_deletable.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SoftDeletable | |
extend ActiveSupport::Concern | |
def soft_delete! | |
find_each do |record| | |
record.soft_delete! | |
end | |
end | |
included do |
View aggregate_field.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# = AggregateField | |
# | |
# This module allows to create a virtual field from multiple fields | |
# | |
# Example: | |
# | |
# class DummyClass | |
# include AggregateField | |
# | |
# attr_accessor :first_name, :last_name |
View gist:5728380
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This core extension aims to manage Deadlocks | |
# with a proper ActiveRecord exception. | |
# | |
# It only works for mysql2 | |
# | |
# Example: | |
# | |
# MyModel.transaction do | |
# begin | |
# record1 = MyModel.find(:id, lock: true) |
View simple_paperclip.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# == Paperclip without ActiveRecord | |
# | |
# Simple and lightweight object that can use Paperclip | |
# | |
# | |
# Customized part can be extracted in another class which | |
# would inherit from SimplePaperclip. | |
# | |
# class MyClass < SimplePaperclip | |
# attr_accessor :image_file_name # :<atached_file_name>_file_name |
View paperclip_background_upload.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# has_attached_file :image, configuration | |
# background_upload_for :image | |
module PaperclipBackgroundUpload | |
extend ActiveSupport::Concern | |
included do | |
def background | |
@background || false | |
end |
View gist:5356952
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ch.hegarc.ig.clientscomptes.configuration; | |
import java.io.File; | |
import java.io.FileReader; | |
import java.io.IOException; | |
import java.util.Properties; | |
import java.util.logging.Level; | |
import java.util.logging.Logger; | |
import org.apache.commons.lang3.StringUtils; |
View gist:4443808
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reload images on failure every x seconds | |
$("img").error(function() { | |
var path = $(this).data('src'); | |
var img = $(this); | |
// Put back mock image | |
$(img).attr('src', 'http://placehold.it/56x56'); | |
// Increment loading counter | |
var attempt = ($(img).data('attempt') || 0); |
NewerOlder