Skip to content

Instantly share code, notes, and snippets.

View ronisaha's full-sized avatar

Roni Saha ronisaha

View GitHub Profile
@ronisaha
ronisaha / pskill
Created June 17, 2014 10:07
bash script - kills all pids matching the search term of "PROCESS".
#! /bin/bash
if [ 0 == $# ]; then
echo -n "Provide Process String:"
read PROCESS
else
PROCESS="$1"
fi
if [[ -z $PROCESS ]]; then
@ronisaha
ronisaha / git.sh
Created July 14, 2014 06:05
GIT_SSH Wrapper Script
#!/bin/bash
# The MIT License (MIT)
# Copyright (c) 2013 Alvin Abad
if [ $# -eq 0 ]; then
echo "Git wrapper script that can specify an ssh-key file
Usage:
git.sh -i ssh-key-file git-command
"
@ronisaha
ronisaha / vhost
Last active May 11, 2021 09:58
Create vHost Ubuntu Lamp-Server (bash and python)
#! /bin/bash
# The MIT License (MIT)
# Copyright (c) 2014 Roni Saha<roni.cse@gmail.com>
# May need to run this as sudo!
# Copy it in global path (like /usr/local/bin) and run command 'vhost' from anywhere, using sudo.
#
# Show Usage, Output to STDERR
@ronisaha
ronisaha / permission.sh
Last active January 15, 2017 04:36
Set folder permision to web-server user
#!/bin/bash
E_BAD_ARGS=85
E_BAD_PATH=-1
if [ ! -n "$1" ]
then
echo "Usage: $0 dir1 dir2 etc."
exit ${E_BAD_ARGS}
fi
@ronisaha
ronisaha / git-update.sh
Last active August 29, 2015 14:05
Update git repository if your system does not ask for git password
#!/bin/bash
echo -n "Enter github Username: "
read USER_NAME
echo -n "Enter github repository name: "
read REPO_NAME
echo -n "Enter Password:"
read -s PASSWORD
@ronisaha
ronisaha / sf.php
Created February 17, 2015 06:39
Symfony2 Console from anywhere in project directory
#!/usr/bin/env php
<?php
function fileLocator($file =null, $maxDepth = 10, $currentDir = ".")
{
if(empty($file)){
return false;
}elseif(file_exists($currentDir . "/$file")){
return $currentDir;
}elseif(--$maxDepth){
return fileLocator($file, $maxDepth, $currentDir . "/..");
@ronisaha
ronisaha / EasyCSVIterator.php
Created October 11, 2015 10:36
EasyCSVIterator
<?php
class EasyCSVIterator implements \Iterator {
protected $file;
protected $key = 0;
protected $current;
protected $header;
protected $hasHeader;
public function __construct($file, $hasHeader = false) {
@ronisaha
ronisaha / EntityEventResolver.php
Last active November 23, 2017 01:24
EasyAuditBundle Custom Entity event resolver example
<?php
namespace MyProject\Bundle\MyBundle\Resolver;
use Symfony\Component\EventDispatcher\Event;
use Xiidea\EasyAuditBundle\Events\DoctrineEntityEvent;
use Xiidea\EasyAuditBundle\Resolver\EntityEventResolver as BaseResolver;
class EntityEventResolver extends BaseResolver
{
@ronisaha
ronisaha / FK_constrain.sql
Created April 20, 2016 04:18
ORACLE DDL GENERATOR
-- `Enable` script generator.
-- Must be run before disable. This will ensure you donot enable any already disabled key while restoring
SELECT
'ALTER TABLE ' || OWNER || '.' || table_name || ' enable CONSTRAINT ' || constraint_name || ';'
FROM dba_constraints WHERE constraint_type = 'R' and status = 'ENABLED' AND OWNER='__OWNER_NAME__';
--`Disable` script generator
select
'ALTER TABLE ' || OWNER || '.' || table_name || ' disable CONSTRAINT ' || constraint_name || ';'
@ronisaha
ronisaha / sample.js
Created June 4, 2016 03:33
Ckeditor Replace and focus on last/ alternatte http://ckeditor.com/addon/autocorrect
CKEDITOR.on('instanceReady', function(ev) {
var editor = ev.editor;
editor.on('key', function (event) {
setTimeout(function () {
var edata = editor.getData();
var replaced_text = edata.replace("#1", "one"); // you could also use a regex in the replace