Skip to content

Instantly share code, notes, and snippets.

@Joseph-N
Joseph-N / status_codes.txt
Created July 18, 2014 17:15
Rails status codes and their symbols
100 = :continue
101 = :switching_protocols
102 = :processing
200 = :ok
201 = :created
202 = :accepted
203 = :non_authoritative_information
204 = :no_content
205 = :reset_content
206 = :partial_content
gem 'faker', github: 'stympy/faker'
gem 'rack-contrib'
gem 'soulmate', :require => 'soulmate/server'
@Joseph-N
Joseph-N / addthis.js
Last active April 25, 2018 07:03
How to configure AddThis to work with Turbolinks - Rails 4
// turbolinks addthis
var initAdthis;
initAdthis = function(){
// Remove all global properties set by addthis, otherwise it won't reinitialize
for (var i in window) {
if (/^addthis/.test(i) || /^_at/.test(i)) {
delete window[i];
}
}
@Joseph-N
Joseph-N / modems.conf
Last active August 29, 2015 14:01
code snippets for sms messages with rails
# Modems configuration
#
# Example and default values
#
# group = modems
# id = "my-id"
# name = "my-name"
# detect-string = "MODEM"
# detect-string2 = "" [Default]
# init-string = "AT+CNMI=1,2,0,0,0" [Default]
@Joseph-N
Joseph-N / Gemfile
Last active July 7, 2022 16:53
File upload using dropzone.js, paperclip in rails. Tutorial link http://josephndungu.com/tutorials/ajax-file-upload-with-dropezonejs-and-paperclip-rails
source 'https://rubygems.org'
# default gems here
#---------------------------
# add paperclip and bootstrap
gem "paperclip", "~> 4.1"
gem 'bootstrap-sass', '~> 3.1.1'
@Joseph-N
Joseph-N / application.css
Last active August 28, 2021 10:33
Gists for autocomplete tutorial - foxycomplete rails. Tutorial link http://josephndungu.com/tutorials/autocomplete-search-with-images-in-rails
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
@Joseph-N
Joseph-N / Gemfile
Last active August 29, 2015 13:58
How to implement revision control in rails app using paperclip and vestal versions - Tutorial link:- http://josephndungu.com/tutorials/revision-control-with-paperclip-rails
# add paperclip
gem 'paperclip', '~>3.4.2'
# add vestal versions
gem 'vestal_versions', :git => 'git://github.com/laserlemon/vestal_versions'
@Joseph-N
Joseph-N / example.html
Last active August 29, 2015 13:58
Code snippets on how to load Github embedded gists with turbolinks - Tutorial link http://josephndungu.com/tutorials/using-github-embedded-gists-with-turbolinks
<!-- before -->
<script src="https://gist.github.com/username/gist_id.js"></script>
<script src="https://gist.github.com/username/gist_id.js?file=file_name"></script>
<!-- after -->
<div class="gist" data-src="https://gist.github.com/username/gist_id.json"></div>
<div class="gist" data-src="https://gist.github.com/username/gist_id.json" data-file="file_name"></div>
@Joseph-N
Joseph-N / _user.html.erb
Last active April 19, 2019 12:50
Rails - Load more with jQuery and Ajax Code snippets - Tutorial link http://josephndungu.com/tutorials/rails-load-more-results-using-jquery-ajax
<div class="record" data-id="<%= user.id %>">
<p><b>ID: </b> <%= user.id %></p>
<p><b>Name: </b> <%= user.name %></p>
<p><b>Location: </b> <%= user.location %> </p>
<p><%= link_to 'Show', user %> | <%= link_to 'Edit', edit_user_path(user) %> | <%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %> </p>
</div>
@Joseph-N
Joseph-N / example.js
Last active August 29, 2015 13:57
With this jquery snippet you will be able to animate to an anchor from a url. If for example you follow a link from page A (e.g http://mywebsite.com/products/1#tomato) it will scroll smoothly to the element with id of tomato in page B
// animate scroll put this on (PAGE B)
var elementClick = window.location.hash
var destination = $(elementClick).offset().top;
$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 1100, function() {
window.location.hash = elementClick
});