Skip to content

Instantly share code, notes, and snippets.

@amitittyerah
amitittyerah / gist:9a0408ddf5e5f4a48008d788ea536291
Created December 13, 2016 04:46
Fix mysql brew installation
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
rm -r /usr/local/var/mysql/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
unset TMPDIR
mysqld --initialize
mysql.server start
@amitittyerah
amitittyerah / gist:bd916538fb56cd62b9a8
Created August 29, 2014 20:16
Restart networking
sudo ifdown --exclude=lo -a && sudo ifup --exclude=lo -a
@amitittyerah
amitittyerah / throws_error.rb
Created August 2, 2014 05:56
throws_error.rb Concern
require 'active_support/concern'
module ThrowsError
extend ActiveSupport::Concern
included do
define_method 'errors_as_json' do |*args|
{
errors: errors
@amitittyerah
amitittyerah / dev_fixtures.rake
Created August 2, 2014 03:40
Rake task to create dev database fixtures
namespace :test do
namespace :db do
namespace :fixtures do
desc 'Create YAML test fixtures from data in an existing database.
Defaults to development database. Set RAILS_ENV to override.'
task :dump => :environment do
sql = "SELECT * FROM %s"
skip_tables = ["schema_migrations"]
ActiveRecord::Base.establish_connection(:development)
(ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|
@amitittyerah
amitittyerah / evl.rb
Created July 30, 2014 22:20
class_eval
class Manager
def self.make_available(klass, user)
klass.class_eval do
define_method("for_#{user}") do
end
end
end
end
@amitittyerah
amitittyerah / audit.rb
Last active August 29, 2015 14:04
Audit logging
class AuditableMethodLogger
def log(klass, method_name)
# Extend the class
klass.class_eval do
# WARNING - this method will get overritten everytime!
alias_method :method, method_name
# WARNING - this method is a new method to alias the passed
alias_method "#{method_name}_passed", method_name
# Dyanmically define a method name or in this case, override
define_method method_name do |*args, &block|
#!/bin/bash
pear upgrade pear
## Install Phing #######################################
pear channel-discover pear.phing.info
pear install --alldeps phing/phing
## Install PHPUnit #####################################
yum install php-xml
@amitittyerah
amitittyerah / index.html
Last active August 29, 2015 14:03
Two-way binding and watching the bound value
<!DOCTYPE>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/angular.min.js"></script>
<script>
// Create a parent app
var app = angular.module('app', []);
// A single controller to rule them all
app.controller('ParentController', ['$scope', function ($scope){
@amitittyerah
amitittyerah / build.xml
Created June 29, 2014 02:11
PHP build.xml file. Jenkins needs orders. Unfortunately setting up is a problem.
<?xml version="1.0" encoding="UTF-8"?>
<project name="YourProject" default="build" basedir=".">
<target name="build"
depends="build-common,phploc,pdepend,phpmd-ci,phpcs-ci,phpcpd,phpcb" />
<target name="build-clean"
depends="clean,build-common,phploc,pdepend,phpmd-ci,phpcs-ci,phpcpd,phpcb" />
@amitittyerah
amitittyerah / config.xml
Created June 29, 2014 02:10
PHP config.xml. Place this in /var/lib/jenkins/jobs/job-name/config.xml
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description>&lt;img type=&quot;image/svg+xml&quot; height=&quot;300&quot; src=&quot;ws/build/pdepend/overview-pyramid.svg&quot; width=&quot;500&quot;&gt;&lt;/img&gt;&#xd;
&lt;img type=&quot;image/svg+xml&quot; height=&quot;300&quot; src=&quot;ws/build/pdepend/dependencies.svg&quot; width=&quot;500&quot;&gt;&lt;/img&gt;</description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<canRoam>true</canRoam>
<disabled>true</disabled>