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 / prepare-commit-msg
Last active August 29, 2015 14:01
Git hook which appends current branch name to commit message (.git/hooks/prepare-commit-msg)
#!/bin/sh
BRANCH=$(git rev-parse --abbrev-ref HEAD)
CURRENT=`grep -e "^[^#]" $1`
if [ -z "$CURRENT" ]
then
NEW_MSG=$(echo "$BRANCH"; cat "$1")
echo "$NEW_MSG" > $1
fi
@asabirov
asabirov / spec_helper.rb
Last active August 29, 2015 14:07
Alternative for no-peeping-toms on Rails4
# add it to spec/spec_helper.rb
RSpec.configure do |config|
...
config.include TestObservers
...
end
@asabirov
asabirov / database.example.yml
Last active August 29, 2015 14:07
database.example.yml for postgres
development:
adapter: postgresql
host: localhost
port: 5432
pool: 5
encoding: unicode
database:
username:
password:
@asabirov
asabirov / show-if-ready.directive.coffee
Created June 19, 2015 09:53
Show content if route is ready and xhr is done. (for algular's ui-router)
# <div app-show-if-ready ui-view></div>
appShowIfReady = ($animate, $rootScope, $timeout, cfpLoadingBar) ->
restrict: 'A'
link: ($scope, $element) ->
container = $element.parent()
stateChangeStartOff = $rootScope.$on '$stateChangeStart', ->
container.hide()
stateChangeSuccessOff = $rootScope.$on '$stateChangeSuccess', ->
$timeout ->
@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 / 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
#