# app/grape/api.rb
###
# http://intridea.github.io/grape/docs/index.html
# http://blog.brunoscopelliti.com/authentication-to-a-restful-web-service-in-an-angularjs-web-app
# http://stackoverflow.com/questions/21255203/angularjs-clientside-routing-and-token-authentication-with-webapi
###
class API < Grape::API
# prefix "api"
# version 'v1'
A great way to get introduced to AngularJS is to work through this tutorial, which walks you through the construction of an AngularJS web app. The app you will build is a catalog that displays a list of Android devices, lets you filter the list to see only devices that interest you, and then view details for any device.
Follow the tutorial to see how Angular makes browsers smarter — without the use of native extensions or plug-ins:
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
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl https://www.npmjs.org/install.sh | sh |
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
!function($, wysi) { | |
"use strict"; | |
var tpl = { | |
"font-styles": function(locale, options) { | |
var size = (options && options.size) ? ' btn-'+options.size : ''; | |
return "<li class='dropdown'>" + | |
"<a class='btn dropdown-toggle" + size + "' data-toggle='dropdown' href='#'>" + | |
"<i class='icon-font'></i> <span class='current-font'>" + locale.font_styles.normal + "</span> <b class='caret'></b>" + | |
"</a>" + |
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 WxUser < ActiveRecord::Base | |
has_many :orders, -> { order('id DESC') } | |
acts_as_follower | |
has_many :shop_wx_user_maps | |
belongs_to :shop | |
def orders_in_shop(shop_id) | |
orders.where(shop_id: shop_id) | |
end |
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
#!/usr/bin/env ruby | |
# Author : Emad Elsaid (https://github.com/blazeeboy) | |
require "selenium-webdriver" # gem install selenium-webdriver | |
require "highline/import" # gem install highline | |
def coderwall github_email, github_password, title, content, tags | |
driver = Selenium::WebDriver.for :firefox | |
driver.navigate.to "https://coderwall.com/auth/github" |
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
#!/usr/bin/env ruby | |
# Author : Emad Elsaid (https://github.com/blazeeboy) | |
require 'sinatra' | |
set :port, 3000 | |
set :environment, :production | |
get '/' do | |
<<-EOT | |
<html><head> |
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
#!/usr/bin/env ruby | |
# Author : Emad Elsaid (https://github.com/blazeeboy) | |
require 'gosu' | |
include Gosu | |
DIMENSION, SPLITS, COLOR = 200, 50, Color::GREEN | |
# credits to: http://en.wikipedia.org/wiki/Maze_generation_algorithm | |
class GameWindow < Window | |
def initialize | |
super DIMENSION, DIMENSION, false, 1000 | |
self.caption = "Maze" |
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
# simple ruby code example for running python script | |
path_to_script = File.dirname(__FILE__) | |
puts "It's a ruby script" | |
puts "Run python script with backticks" | |
puts "Result is available in caller.ru" | |
puts `python #{path_to_script}/processing.py UserName 37` |
resources:
- http://www.elabs.se/blog/36-working-with-time-zones-in-ruby-on-rails
- http://guides.rubyonrails.org/configuring.html
# Set `Time.zone` default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is `UTC`.