Skip to content

Instantly share code, notes, and snippets.

View bobagold's full-sized avatar
💁‍♂️
Working with dart+flutter

Vladimir Goldobin bobagold

💁‍♂️
Working with dart+flutter
View GitHub Profile
@bobagold
bobagold / Happy debugging.sql
Created June 23, 2011 08:28
Happy debugging
CREATE FUNCTION fup_department_del() RETURNS TRIGGER AS '
BEGIN
IF NEW.f_deleted=1 THEN
DELETE FROM department WHERE id=NEW.id;
END IF;
RETURN NEW;
END;
' LANGUAGE 'plpgsql';
CREATE TRIGGER tup_department AFTER UPDATE ON department
@bobagold
bobagold / code.sh
Created August 31, 2011 17:07
bash couchdb client
#! /bin/bash
url=http://localhost:5984
rev() {
php -R '$a = json_decode($argn, true); echo $a[$argv[1]];' rev
}
curly() {
echo curl "$@"
curl -sS "$@"
}
curly $url
@bobagold
bobagold / gist:1703572
Created January 30, 2012 09:37
why i hate python
$ python
Python 2.7.2+ (default, Oct 4 2011, 20:03:08)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> help
Type help() for interactive help, or help(object) for help about object.
>>> help()
Welcome to Python 2.7! This is the online help utility.
@bobagold
bobagold / tweet.php
Created February 1, 2012 11:02
Simple command-line twitter read-only client in php
<?php
$tmhOAuth = __DIR__.'/tmhOAuth';
if (!is_dir($tmhOAuth)) die("please run git clone https://github.com/themattharris/tmhOAuth.git $tmhOAuth\n");
require $tmhOAuth . '/tmhOAuth.php';
require $tmhOAuth . '/tmhUtilities.php';
$config = array(
'consumer_key' => '',
'consumer_secret' => '',
'user_token' => '',
'user_secret' => '',
@bobagold
bobagold / chrome_memory.sh
Created February 7, 2012 05:05
как узнать, что Гугл хром сожрал 20% оперативки
top -b -n 1 | grep chrome | cut -c 46-50 | php -B '$sum=0;' -R '$sum += (float)$argn;' -E 'echo "sum=$sum\n";'
@bobagold
bobagold / gist:3748384
Created September 19, 2012 08:22
linux virtual webcam
Если надо протестировать работу сайта с вебкамерой, а вебкамеру использовать не катит (у меня она с флешем не дружит), можно установить ws4gl (
WebcamStudio For GNU/Linux), запустить его, выбрать там предустановленную анимашку и наслаждаться.
Дополнительно, если флеш умирает после отображения диалога "разрешить сайту использовать камеру", можно добавить постоянное разрешение тут http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager09.html
@bobagold
bobagold / gist:3774732
Created September 24, 2012 07:17
how to checkout dev branch, if you have dev folder
git checkout -b dev origin/dev
@bobagold
bobagold / gist:3870607
Created October 11, 2012 06:36
javascript-style closure scope in php
call_user_func(function() { ... });
@bobagold
bobagold / app.php
Created November 27, 2012 07:41
Oppa js style (silex-based skeleton without unintended global variables
<?php
return call_user_func(function() {
$app = new \Silex\Application();
$routes = require(__DIR__ . '/routes.php');
$routes($app);
return $app;
});
@bobagold
bobagold / PHPUnitTest.php
Created August 18, 2014 07:47
PHPUnit makes me crazy
<?php
class PHPUnitTest extends \PHPUnit_Framework_TestCase
{
/**
* output of this test would be
* <cite>
* Failed asserting that 'cat does not have black fur' does not contain "cat does not have black fur".
* </cite>
* this is due to bad usage of PHPUnit_Framework_Constraint_Not::negate()