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 DataListHelper | |
def list_headers(args=[]) | |
args = Array.new(args) | |
columns = [] | |
args.map { |o| columns << content_tag(:li, o.split(":").first, :style=>"width:#{o.split(":").second}px;") } | |
content_tag(:ul, columns.join(" ").html_safe, :class=>"list-headers") | |
end | |
def data_list_for(object, headers=[], &block) | |
if object.is_a? Array |
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
In some cases you need to set the default_url of paper clip base on some condition. e.g. You want to set default image on basis of gender of user. For this purpose this gist can make it possible to use a method as default_url. Just copy paper_clip_default_url_fix.rb to initializers folder, and use default_url as mentioned in model.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 Devise | |
module Encryptors | |
class Sha1 | |
def self.digest(password, user_salt) | |
string_to_hash = password + "abcdefgh" + user_salt | |
Digest::SHA1.hexdigest(string_to_hash) | |
end | |
def self.salt(username) | |
self.object_id.to_s + rand.to_s |
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 SimpleForm | |
class FormBuilder | |
def collection_check_boxes_with_hints(attribute, collection, value_method, text_method, options={}, html_options={}) | |
rendered_collection = render_collection( | |
collection, value_method, text_method, options.merge({:item_wrapper_tag => nil}), html_options | |
) do |item, value, text, default_html_options| | |
default_html_options[:multiple] = true | |
builder = instantiate_builder(SimpleForm::ActionViewExtensions::CheckBoxBuilder, attribute, item, value, text, default_html_options) | |
label = builder.label(:class => 'inline checkbox checkbox_with_hints').split("</") | |
[ |
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
#!/bin/bash | |
# Author: Chmouel Boudjnah <[email protected]> | |
# Not officially supported by Rackspace only as a best effort basis :) | |
# Define yes to make it to copy to url to clipboard (via a shortened url | |
# service) You need to have the software xclip installed in your system. | |
COPY_URL_TO_CLIPBOARD=yes | |
# Containers to ignore in the list | |
CONTAINERS_TO_IGNORE=".CDN_ACCESS_LOGS" |
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
@-webkit-keyframes inprogress{0%{opacity:1}50%{opacity:.1}100%{opacity:1}}@-moz-keyframes inprogress{0%{opacity:1}50%{opacity:.1}100%{opacity:1}}Keyframes inprogress{0%{opacity:1}50%{opacity:.1}100%{opacity:1}}img[src$="blue.png"],img[src$="blue.gif"],img[src$="blue_anime.gif"],img[src$="yellow.png"],img[src$="yellow.gif"],img[src$="yellow_anime.gif"],img[src$="red.png"],img[src$="red.gif"],img[src$="red_anime.gif"],img[src$="grey.png"],img[src$="grey.gif"],img[src$="grey_anime.gif"],img[src$="disabled.png"],img[src$="disabled.gif"],img[src$="disabled_anime.gif"],img[src$="nobuilt.png"],img[src$="nobuilt.gif"],img[src$="nobuilt_anime.gif"],img[src$="aborted.png"],img[src$="aborted.gif"],img[src$="aborted_anime.gif"]{content:url('data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==');-webkit-border-radius:50%;-moz-border-radius:50%;padding:0;border-radius:50%;background:rgba(0,0,0,.1)}img[src*="blue.png"],img[src*="blue_anime.gif"]{background:#56a556!important}img[src*="yellow.png"],img[s |
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
var HTTPParser = process.binding('http_parser').HTTPParser; | |
var parser = require("http").parsers.alloc(); | |
parser.reinitialize(HTTPParser.RESPONSE); | |
parser.onBody = function(body) { | |
console.log(body.toString()); | |
} | |
parser.onIncoming = function(response) { | |
console.log(response.headers); | |
console.log(response.statusCode); |
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
require 'set' | |
require 'json' | |
if ARGV.length != 2 | |
puts "Usage: detect_leaks [FIRST.json] [SECOND.json]" | |
exit 1 | |
end | |
first_addrs = Set.new | |
second_addrs = Set.new |
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
swagger: '2.0' | |
info: | |
description: This is a sample server Petstore server. | |
version: 1.0.0 | |
title: Swagger Petstore | |
host: virtserver.swaggerhub.com | |
basePath: /nazarhussain/Swagger2/1.0.0 | |
schemes: |
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
# app/admin/email_previews.rb | |
ActiveAdmin.register_page 'Email Previews' do | |
content do | |
div '.' | |
end | |
sidebar 'Mail Previews' do | |
Dir['app/mailer_previews/*_preview.rb'].each do |preview_path| | |
preview_mailer = File.basename(preview_path, '.rb') |
OlderNewer