Skip to content

Instantly share code, notes, and snippets.

View asabirov's full-sized avatar

Artur Sabrov asabirov

  • Apliteni.com
  • Spain
View GitHub Profile
@asabirov
asabirov / DashboardLayout.java
Created May 5, 2011 07:40 — forked from romannurik/DashboardLayout.java
A custom Android layout class that arranges children in a grid-like manner, optimizing for even horizontal and vertical whitespace.
/*
* Copyright 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package
{
import flash.display.Loader;
import flash.net.URLRequest;
import flash.net.URLStream;
import flash.events.IOErrorEvent;
import flash.events.SecurityErrorEvent;
import flash.events.Event;
import flash.utils.ByteArray;
import flash.utils.Endian;
@asabirov
asabirov / YoutubeIframe.php
Created August 29, 2011 17:08
HTMLPurifier Youtube iframe-embed filter. Делаем поддержку iframe кодов от Youtube в HTMLPurifier
<?php
#HTMLPurifier/Filter/YoutubeIframe.php
class HTMLPurifier_Filter_YoutubeIframe extends HTMLPurifier_Filter
{
public $name = 'YouTubeIframe';
public function preFilter($html, $config, $context) {
if (strstr($html, '<iframe')) {
$html = str_ireplace("</iframe>", "", $html);
@asabirov
asabirov / haproxy.cnf
Created September 21, 2011 16:13
Nginx, Faye, Node.js on 80 port
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
maxconn 4096
nbproc 1
pidfile /var/run/haproxy.pid
user haproxy
group haproxy
@asabirov
asabirov / recompile.watchr
Created December 20, 2011 05:23
Перекомпиляция sass и coffeescript файлов при именении. Нужен gem watchr.
def w(name, str = nil, &block)
block ||= proc { |m| sys(str % m[0])}
watch('^' << name.gsub('.', '\.').gsub('*', '.*')) do |m|
puts "-"*80, "#{Time.now.strftime("%H:%M:%S")} - file changed: \033[1;34m#{m[0]}\033[0m"
block[m]
end
end
def sys(cmd)
puts "\033[0;33m>>> \033[1;33m#{cmd}\033[0m"
@asabirov
asabirov / php
Created March 9, 2012 15:24
brew php extended formula
require 'formula'
def mysql_installed?
`which mysql_config`.length > 0
end
class Php <Formula
url 'http://www.php.net/get/php-5.3.10.tar.bz2/from/this/mirror'
homepage 'http://php.net/'
md5 '816259e5ca7d0a7e943e56a3bb32b17f'
@asabirov
asabirov / hack.sh
Created March 31, 2012 12:48 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@asabirov
asabirov / readme.markdown
Created September 7, 2012 14:21 — forked from jonah-williams/readme.markdown
Readme template

Project

Description: What does this project do and who does it serve?

Project Setup

How do I, as a developer, start working on the project?

  1. What dependencies does it have (where are they expressed) and how do I install them?
  2. How can I see the project working before I change anything?
@asabirov
asabirov / deep_hash.rb
Created November 15, 2012 10:06
Использование любой вложенности хеша без предварительного создания вложенных
deep_hash = Hash.new {|hash, key| hash[key] = Hash.new(&hash.default_proc) }
deep_hash[:a][:b][:c] = 23
p deep # => {:a => {:b => {:c => 23}}}
@asabirov
asabirov / str_regexp_replace.rb
Created November 15, 2012 10:35
Замена в строках черех regexp
str = "$24.99 per seat"
str[/\$\d+(?:\.\d+)/] = "$9.99"
p str # "$9.99 per seat"
str[/\$\d+(?:\.\d+)(\b)/, 1] = " USD"
p str # "$9.99 USD per seat"