Skip to content

Instantly share code, notes, and snippets.

View ssv445's full-sized avatar

Shyam Verma ssv445

View GitHub Profile
@ssv445
ssv445 / gist:3609373
Created September 3, 2012 13:35
PayPlans MySQL Query app : how to avoid few events during upgrades
class PayplansAppMysqlPeter extends PayplansAppMysqlquery
{
protected $_location = __FILE__;
public function onPayplansSubscriptionBeforeSave($prev, $new)
{
if(
!($prev && $prev->getStatus() == PayplansStatus::SUBSCRIPTION_ACTIVE) // it was not a previously active subs
&& $new->getStatus() == PayplansStatus::SUBSCRIPTION_ACTIVE // we are activating it
&& $new->getOrder()->getParam('upgrading_from',0) // its a upgrade
@ssv445
ssv445 / vhost.py
Created October 26, 2013 04:49 — forked from fideloper/vhost.py
#! /usr/bin/python
from sys import argv
from os.path import exists
from os import makedirs
from os import symlink
import getopt
#
# Show Usage, Output to STDERR
@ssv445
ssv445 / create-db-user.sh
Created November 8, 2013 07:04
This script creates a database 'db' and a user as 'username' with given password 'pass'. It also grant 'username' ALL access to 'db'. Works on any linux.
#!/bin/bash
# A shell script to add mysql database, username and password.
# -------------------------------------------------------------------------
_db="$1"
_user="$2"
_pass="$3"
## Mysql root settings ##
_madminuser='root'
_madminpwd='mysql-root-password'
@ssv445
ssv445 / change-timezone.sh
Created November 8, 2013 16:16
bash command to change timezone on your linux machine
echo "Asia/Kolkata" | sudo tee /etc/timezone
sudo dpkg-reconfigure --frontend noninteractive tzdata
@ssv445
ssv445 / update-joomla-config.php
Last active December 27, 2015 18:59
PHP CLI script to update Joomla configuration file
<?php
//
$joomlaroot = isset($argv[1]) ? $argv[1] : die("First argument required and it should be absolute-joomla-root-path");
$i=2;
$args = array();
while($i <= $argc){
@ssv445
ssv445 / setperm.sh
Created April 23, 2014 06:09
Setup file permission in Joomla CMS
#!/bin/bash
pwd=${PWD}
[[ $pwd =~ ^/var/www* ]] || exit 0
echo 'PWD is subdirectory of /var/www, applying permissions ...'
find . -exec chown www-data:www-data {} \;
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
@ssv445
ssv445 / cron-commit.sh
Created July 17, 2014 09:39
auto commit folder with changed file as commit message
#!/bin/bash
# move to www folder
cd /var/www
rm -f commit.msg
# add files
git add .
# build commit message
@ssv445
ssv445 / index.js
Last active September 2, 2015 11:05 — forked from MoOx/index.js
Export/import github labels
// go on you labels pages
// eg https://github.com/cssnext/cssnext/labels
// paste this script in your console
// copy the output and now you can import it using https://github.com/popomore/github-labels !
var labels = [];
[].slice.call(document.querySelectorAll(".label-link"))
.forEach(function(element) {
labels.push({
name: element.textContent.trim(),
@ssv445
ssv445 / README.md
Created November 24, 2015 18:58 — forked from oodavid/README.md
Backup MySQL to Amazon S3

Backup MySQL to Amazon S3

This is a simple way to backup your MySQL tables to Amazon S3 for a nightly backup - this is all to be done on your server :-)

Sister Document - Restore MySQL from Amazon S3 - read that next

1 - Install s3cmd

this is for Centos 5.6, see http://s3tools.org/repositories for other systems like ubuntu etc

# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->