Skip to content

Instantly share code, notes, and snippets.

View vitalyrotari's full-sized avatar
🦥
I may be slow to respond.

Vitaly Rotari vitalyrotari

🦥
I may be slow to respond.
  • Everywhere
  • Chisiau, Moldova Republic of
  • 03:31 (UTC +03:00)
View GitHub Profile
@vitalyrotari
vitalyrotari / bootstrap.php
Created February 26, 2014 16:40
Zend Framework 1+ Angular $http.post fix
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
public function _initPostPayload()
{
$headers = getallheaders();
if ('POST' == $_SERVER['REQUEST_METHOD'] && preg_match('/^application\/json/', $headers['Content-Type'])) {
$data = file_get_contents('php://input');
require 'formula'
class UniversalPython < Requirement
satisfy(:build_env => false) { archs_for_command("python").universal? }
def message; <<-EOS.undent
A universal build was requested, but Python is not a universal build
Boost compiles against the Python it finds in the path; if this Python
is not a universal build then linking will likely fail.
#!/usr/bin/env ruby
# Author : Emad Elsaid (https://github.com/blazeeboy)
# Idea of : Thibault (@EyeWriteCode)
require 'Twitter' #gem install twitter
begin
# Create a read application from :
# https://apps.twitter.com
# authenticate it for your account
# fill in the following
config = {
#!/usr/bin/env ruby
require 'pygmentize' # gem install pygmentize
require 'selenium-webdriver' # gem install selenium-webdriver
exit unless code_path = ARGV.shift
file_path = File.absolute_path 'code.html'
image_path = File.absolute_path 'code_image.png'
code = Pygmentize.process File.read(code_path), :ruby
html = <<-EOT
@vitalyrotari
vitalyrotari / rdb.conf
Created April 1, 2014 10:50
RethinkDB Configuration Example
rdb1:
# Give this file the extension .conf and put it in /etc/rethinkdb/instances.d in order to enable it.
# It is generally necessary to run
# rethinkdb create -d /var/lib/rethinkdb/instances.d/default ;
# as the target user before enabling this configuration.
runuser=root
rungroup=root
directory=/var/lib/rethinkdb/instances.d/default
pid-file=/var/run/rethinkdb/instances.d/default.pid
driver-port=28015
@vitalyrotari
vitalyrotari / make-password.sh
Created April 1, 2014 10:52
RethinkDB Admin Panel Security
htpasswd -bc /etc/nginx/.rethinkdb.pass user password
CREATE TABLE IF NOT EXISTS `county` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(124) NOT NULL,
`short_name` varchar(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=11 ;
INSERT INTO `county` (`id`, `name`, `short_name`) VALUES
var moscow = [
[[55.82526701551843,37.87487898420691],
[55.825342,37.87566605844205],
[55.82490198590066,37.876002],
[55.82286899363699,37.86894202090486],
[55.82236197619592,37.869207025558865],
[55.82221,37.868321941252766],
[55.82370199523918,37.867472],
[55.825242976516364,37.874401949797814],
[55.82526701551843,37.87487898420691]],
@vitalyrotari
vitalyrotari / photo.rb
Created May 7, 2014 14:10 — forked from rainchen/photo.rb
Ruby Enum example
class Photo < ActiveRecord::Base
module Statues
QUEUED = 'queued'
NEW = 'new'
def self.values
constants.map(&method(:const_get))
end
# you can define more special methods as you wanted for Statues
end
# The following recipe works with upstream rails proxy for custom 404s and 500s.
# Errors are usually handled via rails except if proxy is really down, in which case
# nginx needs a bit more configration.
server {
# ...
location / {
error_page 404 = @rails; # let rails show a page with suggestions
try_files maintenance.html @rails;