Skip to content

Instantly share code, notes, and snippets.

@tkanov
tkanov / monit-redis.txt
Created July 2, 2017 10:26 — forked from cyx/gist:3690597
Monit Redis
check process redis-server
with pidfile "/var/run/redis.pid"
start program = "/etc/init.d/redis-server start"
stop program = "/etc/init.d/redis-server stop"
if 2 restarts within 3 cycles then timeout
if totalmem > 100 Mb then alert
if children > 255 for 5 cycles then stop
if cpu usage > 95% for 3 cycles then restart
if failed host 127.0.0.1 port 6379 then restart
if 5 restarts within 5 cycles then timeout
# ...
json_response = JSON.parse(response.body)
# Look only at 'attributes' part of both arrays (expected and actual)
assert_same_elements json_response['attributes'], expected['attributes']
# Compare for equality excluding 'attributes' from both arrays
assert_equal json_response.except('attributes'), expected.except('attributes')
1) Failure:
Test#test_should_get_something [.../..._controller_test.rb:101]:
--- expected
+++ actual
@@ -1 +1 @@
-{"something"=>"anything", "index"=>"1", "attributes"=>[{"name"=>"guns", "value"=>"roses"}, {"name"=>"carpet", "value"=>"sofa"}, {"name"=>"sys", "value"=>"log"}, {"name"=>"red", "value"=>"hot"}], "where"=>"am_i"}
+{"something"=>"anything", "index"=>"1", "attributes"=>[{"name"=>"sys", "value"=>"log"}, {"name"=>"guns", "value"=>"roses"}, {"name"=>"carpet", "value"=>"sofa"}, {"name"=>"red", "value"=>"hot"}], "where"=>"am_i"}
one:
name: "guns"
value: "roses"
two:
name: "red"
value: "hot"
three:
name: "carpet"
def test_should_get_something
get :show, id: 1114, format: 'json'
expected = {
'something' => 'anything',
'index' => '1',
'attributes' => [
{ 'name' => 'guns', 'value' => 'roses' },
{ 'name' => 'red', 'value' => 'hot' },
{ 'name' => 'carpet', 'value' => 'sofa' },
@tkanov
tkanov / git_email_address.sh
Last active April 10, 2023 23:41
git: get user's email address by commit hash
git --no-pager show -s --format='%an <%ae> on %cd' --date=short 4f340aex43508c86xxxxxx69f4803114cxca2ae7
Username <address@gmail.com> on 2016-04-04
@tkanov
tkanov / getUserPicture.m
Created February 14, 2016 13:26 — forked from 1905/getUserPicture.m
get actual user photo (profile picture) by user id from Vkontakte, Twitter, Facebook
// get actual user picture from VKONTAKTE by UID
- (void)getUserPictureVK:(NSString*)uid
{
NSString *requestURLstring = [NSString stringWithFormat:@"https://api.vkontakte.ru/method/getProfiles?uid=%@&fields=photo", uid];
NSURL *requestURL = [NSURL URLWithString:requestURLstring];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:requestURL];
[request setTimeoutInterval:10];
AFJSONRequestOperation *operation = [AFJSONRequestOperation operationWithRequest:request
success:^(id JSON) {
gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions with: '--with-mysql-config=/usr/local/mysql/bin/mysql_config'
This could take a while...
Successfully installed mysql-2.9.1
Parsing documentation for mysql-2.9.1
Installing ri documentation for mysql-2.9.1
Done installing documentation for mysql after 0 seconds
1 gem installed
gem install mysql
Fetching: mysql-2.9.1.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
...
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
@tkanov
tkanov / banned_sum.ci.py
Created April 16, 2015 13:55
banned_sum.ci.py
def checkio(data, r=0):
if len(data) == 0:
return r
r += data.pop()
return checkio(data, r)