Skip to content

Instantly share code, notes, and snippets.

😉

Nikolay Ponomarev itsNikolay

😉
View GitHub Profile
View main.c
#include <stdio.h>
#include <stdlib.h>
int *initArray(int n) {
int i;
int *array;
array = malloc(n * sizeof(*array));
/* you should always check malloc success */
if (array == NULL)
View zsh.md

Prereq:

apt-get install zsh
apt-get install git-core

Getting zsh to work in ubuntu is weird, since sh does not understand the source command. So, you do this to install zsh

wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh
View test16.rb
require 'active_record'
class Person < ActiveRecord::Base
establish_connection adapter: 'sqlite3', database: 'foobar.db'
connection.create_table table_name, force: true do |t|
t.string :mobile_no
end
validate do
regexp = /^(07[\d]{9})/
View test.rb
require 'active_record'
require "active_support"
class Person < ActiveRecord::Base
establish_connection adapter: 'sqlite3', database: 'foobar.db'
connection.create_table table_name, force: true do |t|
t.date :date
end
validate :is_date?
View rspec_rails_cheetsheet.rb
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
View Ubuntu rbenv
# for more info: https://gist.github.com/1120938
View capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
View Cheffile
#!/usr/bin/env ruby
#^syntax detection
site 'http://community.opscode.com/api/v1'
cookbook "apt"
cookbook "build-essential", {}
cookbook "rvm", {:github=>"fnichol/chef-rvm", :ref=>"v0.9.0"}
cookbook "git", {}
cookbook "postgresql", {}
View application.css
/*
*= require_self
*= require_tree .
*/
@import "bootstrap";
html, body {
height: 100%;
}
View cap deploy
* 2013-03-10 23:26:23 executing `deploy'
* 2013-03-10 23:26:23 executing `deploy:update'
** transaction: start
* 2013-03-10 23:26:23 executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote ssh://user@198.211.125.210:2912/home/user/repos/wood-awesome.git master"
command finished in 1041ms
* executing "if [ -d /home/user/projects/wood-awesome/shared/cached-copy ]; then cd /home/user/projects/wood-awesome/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 74acf135a2f939174bf1a791e12390672d59761b && git clean -q -d -x -f; else git clone -q ssh://user@198.211.125.210:2912/home/user/repos/wood-awesome.git /home/user/projects/wood-awesome/shared/cached-copy && cd /home/user/projects/wood-awesome/shared/cached-copy && git checkout -q -b deploy 74acf135a2f939174bf1a791e12390672d59761b; fi"
servers: ["198.211.125.210"]
[198.211.125.210] executing command
You can’t perform that action at this time.