Skip to content

Instantly share code, notes, and snippets.

View tadas-s's full-sized avatar
🍍
( ⚆ _ ⚆ ) ┬───────┬

Tadas Sasnauskas tadas-s

🍍
( ⚆ _ ⚆ ) ┬───────┬
View GitHub Profile
@tadas-s
tadas-s / www-data-writeable.sh
Last active August 29, 2015 13:58
www-data-writeable
#!/bin/bash
#
# Sets-up ACL for current + www-data users to allow writing to folder by both and deleting files created by each other.
# This simplifies some Symfony2 dev tasks
#
# *** NOT TO BE USED IN PRODUCTION SERVERS IN ANY WAY ***.
#
if [ -z "$1" ]; then
if Rails.env.test?
module ActionDispatch
module Routing
module UrlFor
alias_method :original_url_options, :url_options
def url_options
if self.respond_to? :request
original_url_options.merge({:host => request.host, :port => request.port})
else
<?php
$json = array(
'values' => array(
0 => array(
'field' => 'id1',
'value' => 895
),
1 => array(
'field' => 'id2',
@tadas-s
tadas-s / irbify.rb
Created September 12, 2013 13:46
Running local ruby scripts on remote Heroku app instance
#!/usr/bin/env ruby
#
# Usage:
# irbify.rb script.rb | heroku run rails console --app=my-app
#
# Why eval and not piping directly? Piping directly would run all lines even if previous line was an invalid statement.
#
script_name = ARGV[0]
@tadas-s
tadas-s / dirty_git.sh
Created September 5, 2013 11:13
A small bash script function to check if local git repository copy has changes. I use it for some deployment automation scripts.
#!/bin/bash
#
# Checks if git repository at $1 does not have modified files
#
function is_dirty {
GIT_DIR="$1/.git" GIT_WORK_TREE="$1" git diff --quiet
if [[ $? == 0 ]]; then
return 1
else
@tadas-s
tadas-s / gist:6316807
Last active December 21, 2015 13:59
average apache process size
# approx apache process count
ps -eLf | grep httpd | wc -l
# total and average memory stats
ps -ylC httpd --sort:rss | awk '{sum+=$8; ++n} END {print "Tot="sum"("n")";print "Avg="sum"/"n"="sum/n/1024"MB"}'
backend default {
.host = "127.0.0.2";
.port = "80";
}
sub vcl_recv {
set req.backend = default;
return(lookup);
}
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶
@tadas-s
tadas-s / gearman.md
Last active October 18, 2017 00:55
Compiling Gearman 1.1.6 + PHP module on Centos 5.9

Gearman 1.1.6 on Centos 5.9 + PHP

Please note that this is not a complete-step-by-step solution but rather a set of notes that might help to build Gearman 1.1.6 on Centos 5.9.

Some other helpful notes can be found here: http://gearman.info/build/centos5-8.html

Building Gearman

@tadas-s
tadas-s / mysql-rename-db.sh
Created April 18, 2013 08:58
MySQL database rename script
#!/bin/bash
# Disclaimer - make backups, use at your own risk.
#
# Based on this comment: http://stackoverflow.com/a/13944924/843067
# Views and stored procedures have to be done separately.
OLDDB="old_db_name"
NEWDB="new_db_name"
MYSQL="mysql -u root -pyour_password "