Skip to content

Instantly share code, notes, and snippets.

View itsNikolay's full-sized avatar
📈
Better then yesterday

Nikolay Ponomarev itsNikolay

📈
Better then yesterday
View GitHub Profile
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem 'rails', '5.2.4.5'
gem 'sqlite3'
end
#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)
@itsNikolay
itsNikolay / zsh.md
Last active August 29, 2015 14:19 — forked from tsabat/zsh.md
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})/
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?
#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)
# for more info: https://gist.github.com/1120938
=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')
#!/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", {}
@itsNikolay
itsNikolay / application.css
Created March 11, 2013 10:51
application.css
/*
*= require_self
*= require_tree .
*/
@import "bootstrap";
html, body {
height: 100%;
}