Skip to content

Instantly share code, notes, and snippets.

View assimovt's full-sized avatar
🧠
something new...

Tair Asim assimovt

🧠
something new...
View GitHub Profile
# bundle_mongo_template.rb
#
# fork of Ben Scofield's Rails MongoMapper Template (http://gist.github.com/181842)
#
# This template:
# - Adds Bundler support
# - Adds MongoDB support
# - Removes default files and javascript
# - Installs common gems via bundler: mocha, shoulda, factory-girl, shoulda_generator, haml, mongrel
#
# Using custom set_form_data and urlencode
# Ruby NET/HTTP does not support duplicate parameter names
# File net/http.rb, line 1426
def set_form_data(request, params, sep = '&')
request.body = params.map {|k,v|
if v.instance_of?(Array)
v.map {|e| "#{urlencode(k.to_s)}=#{urlencode(e.to_s)}"}.join(sep)
else
"#{urlencode(k.to_s)}=#{urlencode(v.to_s)}"
end
@assimovt
assimovt / user.rb
Created November 21, 2010 10:07
Railscast #236 extension with Fb_graph
# app/models/user.rb
def apply_omniauth(omniauth)
case omniauth['provider']
when 'facebook'
self.apply_facebook(omniauth)
end
authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'], :token =>(omniauth['credentials']['token'] rescue nil))
end
@assimovt
assimovt / user.rb
Created December 18, 2010 09:56
Railscast #236 extension with Fb_graph and Twitter
# app/models/user.rb
def apply_omniauth(omniauth)
case omniauth['provider']
when 'facebook'
self.apply_facebook(omniauth)
when 'twitter'
self.apply_twitter(omniauth)
end
authentications.build(hash_from_omniauth(omniauth))
@assimovt
assimovt / _photo.html.haml
Created April 3, 2011 08:27
Carrierwave uploader sample
# app/views/photos/_photo.html.haml
.photo[photo]
= image_tag photo.image_url(:thumb) if photo.image?
= link_to "Delete", property_photo_path(@property, photo), :method => :delete, :confirm => "Are you sure?", :remote => :true
@assimovt
assimovt / new.html
Created August 20, 2011 17:28
Refactor Rails application layout to use HTML5 semantics with HAML
<!DOCTYPE html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset='utf-8'>
@assimovt
assimovt / sphinx.rb
Created February 5, 2012 11:16
Mac homebrew Sphinx 0.9.9 formula
require 'formula'
class Libstemmer < Formula
# upstream is constantly changing the tarball,
# so doing checksum verification here would require
# constant, rapid updates to this formula.
head 'http://snowball.tartarus.org/dist/libstemmer_c.tgz'
homepage 'http://snowball.tartarus.org/'
end
@assimovt
assimovt / README.md
Last active June 19, 2016 19:16
Adds "Daily wisdom about startups" images from http://startupquote.com to your dashboard.

Setup

Add the simple-rss Gem to your Gemfile:

gem 'simple-rss'

Update your bundle:

bundle

Keybase proof

I hereby claim:

  • I am assimovt on github.
  • I am tair (https://keybase.io/tair) on keybase.
  • I have a public key ASA8PQUAvX0Y81EhwSedHmphsaKYac8ZAutT3TMsAAlCTAo

To claim this, I am signing this object:

@assimovt
assimovt / Dockerfile
Created October 21, 2017 05:32
Deploying Elixir applications - Docker image
FROM buildpack-deps:jessie
MAINTAINER The Dockbit Team "team@dockbit.com"
ARG RELEASE=master
ENV HOME /root
ENV MIX_ENV prod
ENV PORT 4000
ENV REPLACE_OS_VARS true