Skip to content

Instantly share code, notes, and snippets.

View rakauchuk's full-sized avatar
🦄
Champ champ!

Kirill Rakauchuk rakauchuk

🦄
Champ champ!
View GitHub Profile
@rakauchuk
rakauchuk / gist:5955897
Created July 9, 2013 09:13
CentOS Web Server to a SQL Server
rpm -ivh http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
cd /etc/yum.repos.d/
wget http://rpms.famillecollet.com/enterprise/remi.repo
yum install freetds
yum install freetds-devel
yum install --enablerepo=remi php-mssql
@rakauchuk
rakauchuk / CORS.php
Created September 6, 2013 07:15
Cross-Origin Resource Sharing
<?php
// Allow from any origin
if (isset($_SERVER['HTTP_ORIGIN'])) {
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400');
}
// Access-Control headers are received during OPTIONS requests
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
@rakauchuk
rakauchuk / twitterHashTags.php
Created September 16, 2013 15:28
Regex to conditionally replace Twitter hashtags with hyperlinks
<?
// (^|\s)#(\w*[a-zA-Z_]+\w*)
$str = preg_replace('/(^|\s)#(\w*[a-zA-Z_]+\w*)/', '\1#<a href="http://search.twitter.com/search?q=%23\2">\2</a>', $str);
// ...
?>
@rakauchuk
rakauchuk / Gruntfile.js
Created November 25, 2013 05:48
Example... with Jekull
// This is the main application configuration file. It is a Grunt
// configuration file, which you can learn more about here:
// https://github.com/cowboy/grunt/blob/master/docs/configuring.md
/*jslint nomen: true*/
'use strict';
module.exports = function (grunt) {
'use strict';
grunt.initConfig({
// The clean task ensures the entire XXX folder is removed
clean: {
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
#!/bin/bash
for i in `brew list -1`
do
if [[ "$i" == python.* ]] || [[ "$i" == ruby.* ]]
then
continue
fi
brew rm $i && brew install $i
done
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
@rakauchuk
rakauchuk / nbrb.php
Created January 16, 2015 21:21
nbrb rates converted from xml to json (w/ mapping symbols)
<?php
try
{
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json');
$ex = 'http://www.nbrb.by/Services/XmlExRates.aspx?ondate=' . date("m/d/Y");
@rakauchuk
rakauchuk / chrome_ajax_1.js
Created January 19, 2015 12:39
handle ajaxComlete in chrome ext (jquery)
var main = function () {
var myEvent = document.createEvent('Event');
myEvent.initEvent('CustomEvent', true, true);
function fireCustomEvent() {
document.body.dispatchEvent(myEvent);
};
jQuery(document).ajaxComplete(function (event, request, settings) {
@rakauchuk
rakauchuk / chrome_ajax_2.js
Created January 19, 2015 12:40
handle ajaxComlete in chrome ext (jquery) v2
var actualCode = '(' + function () {
$(document).ajaxComplete(function () {
console.log('ajaxComplete');
});
} + ')();';
var script = document.createElement('script');
script.textContent = actualCode;
(document.head || document.documentElement).appendChild(script);