Skip to content

Instantly share code, notes, and snippets.

View rokkit's full-sized avatar

Maxim Ohs rokkit

  • Saint-Petersburg
View GitHub Profile
@rokkit
rokkit / gist:ebed09c2dcc0e0243eb832a5c396ebf6
Last active September 27, 2023 18:13
C++ pointers example
#include <iostream> // подключаем заголовочный файл iostream
using namespace std;
void eatFood(string &food) {
food = food + " съедена :-)";
}
int main() // определяем функцию main
{ // начало функции
cout << "Привет!" << "\n"; // выводим строку на консоль
@rokkit
rokkit / gist:8a9af4f7b8cc9b2d38e404c0cfb6b121
Created March 4, 2023 13:59
Slack emoji to native symbols 🌞
:bowtie:
:smile: 😄
:simple_smile:
:laughing: 😆
:blush: 😊
:smiley: 😃
:relaxed: ☺
:smirk: 😏
:heart_eyes: 😍
:kissing_heart: 😘
@rokkit
rokkit / gist:08c5f1f96476075f5ae5bbc993e9dc61
Created December 20, 2021 17:45
Install mysql2 gem on macOS Monterey
gem install mysql2 -- \
--with-mysql-lib=/opt/homebrew/Cellar/mysql/8.0.27/lib \
--with-mysql-dir=/opt/homebrew/Cellar/mysql/8.0.27 \
--with-mysql-config=/opt/homebrew/Cellar/mysql/8.0.27/bin/mysql_config \
--with-mysql-include=/opt/homebrew/Cellar/mysql/8.0.27/include
whenever /var/spool/cron/: mkstemp: Permission denied
I ended up adding all the users to the crontab group, and setting the group ownership of all needed files to that crontab group.
A lot of permissions were messed up. Changing the group ownership to something else first "resets" those permissions.
The crontab executable:
sudo chgrp crontab /usr/bin/crontab
sudo chmod g+s /usr/bin/crontab
Result: -rwxrwsr-x 1 root crontab 37K 2010-04-15 08:51 /usr/bin/crontab
Faker generate duplicate data with FactoryGirl
Use brackets!
FactoryGirl.define do
factory :user do
name { Faker::Name.name }
email { Faker::Internet.email }
provider "google_oauth2"
uid { Faker::Lorem.word }
end
@rokkit
rokkit / gist:6306648
Created August 22, 2013 12:42
Get only domain from uri
Get only domain from uri
"http://example.com".replace('http://','').replace('https://','').split(/[/?#]/)[0]
/*
* File: demo_table_jui.css
* CVS: $Id$
* Description: CSS descriptions for DataTables demo pages
* Author: Allan Jardine
* Created: Tue May 12 06:47:22 BST 2009
* Modified: $Date$ by $Author$
* Language: CSS
* Project: DataTables
*
@rokkit
rokkit / gist:5774032
Created June 13, 2013 14:18
passenger post install message
The Apache 2 module was successfully installed.
Please edit your Apache configuration file, and add these lines:
LoadModule passenger_module /root/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/passenger-4.0.5/libout/apache2/mod_passenger.so
PassengerRoot /root/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/passenger-4.0.5
PassengerDefaultRuby /root/.rbenv/versions/2.0.0-p195/bin/ruby
After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
class Promo < ActiveRecord::Base
attr_accessible :count_items, :description, :end_at, :name, :short_description,
:start_at, :promo_images_attributes, :category_id, :employe_ids, :point_ids
belongs_to :company
belongs_to :category
has_many :promo_images #photos of promo, display on devise
has_many :coupons
has_and_belongs_to_many :employes
has_and_belongs_to_many :points
accepts_nested_attributes_for :promo_images, allow_destroy: true #need for working nested form
@rokkit
rokkit / gist:5425199
Created April 20, 2013 08:06
ответы
13:14:15 Начало тестирования
13:14:15 Задан вопрос "Какой будет результат выполнения следующего кода на PHP:
class A {
static public $i = 1;
static public function get_i() {
return self::$i;
}
static public function print_i() {
echo static::get_i();