Skip to content

Instantly share code, notes, and snippets.

View nplusp's full-sized avatar

Mikita Pridorozhko nplusp

View GitHub Profile
ssh -C app@IP_ADDRESS 'cat /var/www/apps/WEBSITE/backups/dump.sql.bz2' | bunzip2 -dc | rails db
def self.search(employee_params, query_options_params, checked_fields)
sql = ''
date_of_employement_from = ''
date_of_employement_to = ''
date_of_birth_from = ''
date_of_birth_to = ''
employee_params.each do |key, value|
if (key.start_with?('employee_') && is_checked(key, checked_fields))
column = key.gsub('employee_','')
@nplusp
nplusp / institutions_controller.rb
Last active March 14, 2016 21:13
InstitutionsController
class InstitutionsController < ApplicationController
load_and_authorize_resource :only => [:destroy,:edit,:new,:create,:update]
before_filter :authenticate_user!, :except => [:student_registration, :show, :validate_registration_pin, :result, :admission, :buy_registration_pin,:paygate_callback_failure, :paygate_cancel, :paygate_pending, :paygate_callback_success, :pin_transaction_info_print]
before_filter :find_institution, :except => [:show,:index, :new, :create, :semesters_for_institute_type, :start_end_date_for_assessment_period, :courses_for_batch, :paygate_callback_failure, :paygate_cancel, :paygate_pending, :paygate_callback_success, :pin_transaction_info_print]
before_filter :add_bread_crumb,:except => [:show]
# layout 'print', :only => [:pin_transaction_info_print]
# add_breadcrumb "Dashboard", :root_path
# layout "schoolit", :only => [:dashboard]
#layout 'print', :only => [:pin_transaction_info_print]
def add_bread_crumb
require 'file_size_validator'
require 'my_file_util'
class Student < ActiveRecord::Base
attr_accessible :marital_status, :community, :date_of_birth, :email, :first_name, :gender, :photo, :photo_cache, :fee_receipt_no, :program_ids, :fee_amount,
:last_attended_school_name, :surname, :lga, :middle_name, :mobile, :nationality, :phone, :registration_id, :status, :registration_number,
:registration_pin, :program_id, :attachments_attributes, :score, :admission_remark, :offered_program_id, :jamb_score, :jamb_registration_number, :batch_id, :admission_no,
:admission_date, :blood_group, :birth_place, :language, :religion, :address_attributes, :next_of_kin_attributes, :course_ids, :carry_over_course_ids, :academic_session,
:student_category_id, :country_id, :state_id, :lga_id, :answers_attributes, :user_id, :second_next_of_kin_attributes, :previous_attended_school_attributes
@nplusp
nplusp / gist:0520094210667a120dd0
Created November 11, 2015 12:07 — forked from yuri-zubov/gist:91bf6e4d5a75a63c5790
template for init.d
#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
@nplusp
nplusp / regex.pl
Last active May 6, 2019 15:45
Kill Perl
# http://swtch.com/~rsc/regexp/regexp1.html
$_ = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
if ( m/a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ ) {
print "hello";
}
@nplusp
nplusp / vimrc.vim
Last active March 14, 2016 21:20
Vimrc
" This must be first, because it changes other options as a side effect.
set nocompatible
filetype off
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
@nplusp
nplusp / workaround.php
Created December 29, 2015 06:39 — forked from aspyct/workaround.php
The most undebuggable PHP snippet ever
<?php
define("true ", false);
function doIt() {
define(" false", true);
define("maybe", rand() & 1);
}
function  ($stupid="clever") {
if (assert_value($stupid)) {
@nplusp
nplusp / counter_cache_migration.rb
Created February 18, 2016 09:27
Counter cache migration hack
class AddCommentsCountToPosts < ActiveRecord::Migration
def change
change_table :posts do |t|
t.integer :comments_count, default: 0
end
reversible do |dir|
dir.up { data }
end
end
ru:
i18n:
transliterate:
rule:
ё: 'yo'
№: '#'
є: 'e'
ї: 'yi'
а: 'a'
б: 'b'