Skip to content

Instantly share code, notes, and snippets.

chars = ('a'..'z').to_a*2 + ('A'..'Z').to_a*2
n = gets
s = gets.strip
k = gets.to_i%26
s.each_char.with_index do |char, index|
s[index] = (chars.index(char).nil? ? char : chars[chars.index(char)+k])
end
puts s

http://guides.rubyonrails.org/getting_started.html

Rails Guides Getting Started Notes

rails new -h see all app builder switches

File/Folder Purpose

app/ Contains the controllers, models, views and assets for your application. You'll focus on this folder for the remainder of this guide.
config/ Configure your application's runtime rules, routes, database, and more. This is covered in more detail in Configuring Rails Applications
config.ru Rack configuration for Rack based servers used to start the application.

@emad-elsaid
emad-elsaid / README.md
Created August 9, 2015 16:29
Learning Ruby/RoR guide

About

the following document suggests a learning guide for the Ruby language and ruby on rails framework, you can fork, comment, edit this document as you wish, this document is under GPL license.

Who is this document for

Developers interested in Ruby/RoR, this documetn assumes that you already know both programming concepts and web development concepts, the only thing you need to learn is both ruby/ror.

The learning guide

@emad-elsaid
emad-elsaid / gist:2e199bccb5ff85a5a7ee
Created June 22, 2015 17:28
Email Content for OP.GOV.EG
Delivered-To: [email protected]
Received: by 10.28.31.71 with SMTP id f68csp1035492wmf;
Sat, 20 Jun 2015 06:31:23 -0700 (PDT)
X-Received: by 10.180.23.8 with SMTP id i8mr15731965wif.39.1434807083138;
Sat, 20 Jun 2015 06:31:23 -0700 (PDT)
Return-Path: <[email protected]>
Received: from crypt01.op.gov.eg (mx.op.gov.eg. [41.128.1.229])
by mx.google.com with ESMTPS id x18si25205951wjw.179.2015.06.20.06.31.22
for <[email protected]>
import Ember from 'ember';
export default Ember.Route.extend({
activate: function(){
this.set('testing', location.href.search('localhost:') >= 0 );
this.set('appId', (this.get('testing'))? '587357574736994' : '389763374496416');
return this.loadFBSDK().then(this.fbInit);
},
@emad-elsaid
emad-elsaid / database_clear.rake
Created June 3, 2015 13:44
A Collection of rails Rake Tasks
namespace :db do
desc "Erase all tables"
task :clear => :environment do
conn = ActiveRecord::Base.connection
tables = conn.tables
tables.each do |table|
puts "Deleting #{table}"
conn.drop_table(table)
end
end
#include <map>
using namespace std;
class Solution {
public:
bool isIsomorphic(string s, string t) {
map<char, char> convert;
map<char, char> rconvert;
for(int i=0; i<s.length(); i++){
if(convert.find(s[i])==convert.end() && rconvert.find(t[i])==rconvert.end() ){
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
#include <stack>
# @param {Integer} n
# @return {Boolean}
def is_happy(n)
iterated = []
found = false
loop do
found = iterated.include? n
iterated << n
nxt = 0
while n>0 do
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
int remov(struct ListNode* current, int n);
int remov(struct ListNode* current, int n){