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 / 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 / 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

// 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 / 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);
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 / 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
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://image.torrent.kg/images/U8x5261.png', false);
xhr.responseType = 'arraybuffer';
xhr.send();
var blob = new WebKitBlobBuilder();
blob.append(xhr.response);
var file = blob.getBlob('image/png');
console.log(file)
var fd = new FormData();
fd.append("image[0]", file);
@adis-io
adis-io / uploader.js
Created November 26, 2011 16:07
SYNC
function upload(image){
var xhr = new XMLHttpRequest();
xhr.open('GET', image.srcUrl, false);
xhr.responseType = 'arraybuffer';
xhr.send();
var mime = xhr.getResponseHeader('Content-type');
var blob = new WebKitBlobBuilder();
blob.append(xhr.response);
var file = blob.getBlob(mime);
var fd = new FormData();
@adis-io
adis-io / uploader.js
Created November 26, 2011 16:05
ASYNC
function upload(image){
var xhr = new XMLHttpRequest();
xhr.open('GET', image.srcUrl, true);
xhr.responseType = 'arraybuffer';
xhr.onload = function(e) {
if (this.status == 200) {
var mime = xhr.getResponseHeader('Content-type');
var blob = new WebKitBlobBuilder();
blob.append(xhr.response);
var file = blob.getBlob(mime);
@adis-io
adis-io / perviy.js
Created March 25, 2012 18:26
perviy
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://diesel.elcat.kg/index.php?showtopic=10954635', true);
xhr.onload = function(e) {
if (this.status == 200) {
console.log(xhr.response);
}
};
xhr.send();