Skip to content

Instantly share code, notes, and snippets.

View adis-io's full-sized avatar

Adis Osmonov adis-io

View GitHub Profile
@adis-io
adis-io / install.md
Last active September 11, 2015 06:34
Install rabbitmq-server
  • Add the following line to your /etc/apt/sources.list:
deb http://www.rabbitmq.com/debian/ testing main
deb http://packages.erlang-solutions.com/ubuntu precise contrib
  • Run these commands:
wget https://www.rabbitmq.com/rabbitmq-signing-key-public.asc
sudo apt-key add rabbitmq-signing-key-public.asc
wget http://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc
class User < ActiveRecord::Base
before_create :check_email_existence
private
def check_email_existence
return true if !user = User.find_by_email(self.email)
if !is_imported_user && !user.muo_id
user.muo_id = self.muo_id
@adis-io
adis-io / sendmail
Last active August 29, 2015 14:12 — forked from ScreamingDev/sendmail
#!/usr/bin/php
<?php
$input = file_get_contents('php://stdin');
preg_match('|^To: (.*)|', $input, $matches);
$filename = tempnam('/var/log/mail', date('ymd-his-') . $matches[1] . '.');
file_put_contents($filename, $input);
// originally by Camden Ross. Thanks
/* bypass wordpress are you sure you want to logout screen when logging out of an already logged out account. */
function smart_logout() {
if (!is_user_logged_in()) {
$smart_redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '/';
wp_safe_redirect( $smart_redirect_to );
exit();
} else {
check_admin_referer('log-out');
@adis-io
adis-io / README.md
Last active August 29, 2015 14:06
Hosts file changer

##Description This bash script is changes /etc/hosts file with predefined environment.

##Usage Just open script, change domain and IPs NOTE: you should escape dot with backslash

##Requirements

  • perl

##TODO

@adis-io
adis-io / webhook.js
Last active August 8, 2017 02:20
Github's webhook handling with nodejs + restify
var restify = require('restify'),
crypto = require('crypto');
var secret = "my-app-secret";
function payload(req, res, next) {
getRawBody(req, {
length: req.headers['content-length'],
limit: '2mb',
encoding: 'utf-8'
@adis-io
adis-io / 0_reuse_code.js
Created August 15, 2014 11:25
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@adis-io
adis-io / cesarcipher.php
Created August 19, 2013 04:45
Решение задачи Шифра Цезаря на PHP
<?php
class CesarCipher {
private $alphabet;
private $shift;
public function setAlphabet($alphabet)
{
$this->alphabet = $alphabet;
}
@adis-io
adis-io / background.js
Created May 15, 2013 17:13
Отрывок из extension'a для Google Chrome. Diesel Upper
var requestTimerId;
var pollIntervalMin = 1000 * 60; // 1 minute
var pollIntervalMax = 1000 * 60 * 60; // 1 hour
var requestFailureCount = 0; // used for exponential backoff
var PostMsg = "Dup";
function init() {
console.log('Поехали!');
startRequest();
}
<!DOCTYPE html>
<html>
<head>
<title>{{ $title }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{{ Asset::styles() }}
{{ Asset::scripts() }}
</head>
<body>
@include('nav')