Skip to content

Instantly share code, notes, and snippets.

View midhunkrishna's full-sized avatar

Midhun Krishna midhunkrishna

View GitHub Profile
@midhunkrishna
midhunkrishna / steps to install mysql
Created February 17, 2014 05:25
A gist to configure mysql on mac machine for Rails
brew install mysql #install mysql using home brew
mysql_install_db --verbose --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/mysql/<mysql dist version you have>/<the plist file you have in this dir>.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/<the plist file you have in this dir>.plist
#try
mysql -uroot; #if it works: yayyyy !!!
@midhunkrishna
midhunkrishna / filter_criterion.md
Created October 8, 2015 07:07
filter_criterion.md
  class FileUploadPolicy < ApplicationPolicy
  def create?
    can_create = false
    FileUploadPolicy.creator_roles.each do |role|
      can_create = can_create || @user.send("#{role}?".to_sym)
    end
    can_create
  end
{
"clinicHours": {
"Monday": {
"wake_up": ["08:00"],
"sleep": ["12:00"]
},
"Tuesday": {
"wake_up": ["08:00"],
"sleep": ["12:00"]
},
@midhunkrishna
midhunkrishna / ceaser_cipher.md
Last active January 4, 2016 12:03
Caeser Cipher

Caeser Cipher

  • Read about Caeser Cipher
  • Program should read from file and convert the entire text data, no need to convert special character
  • The program should write to a file

Points

  • Should be object oriented

  • Program should be designed rather than written

  • Finish on or before 9PM today

@midhunkrishna
midhunkrishna / resume.md
Created January 7, 2016 05:58
Resume problem

The resume problem

  • Write program which read following details from termial
    • Name
    • Age
    • Qualification
  • Write these details to a text file

Notes:

  • Use KISS principle
SELECT DISTINCT(each_attribute ->> 'reference_number_field')
AS reference_number
FROM deliveries
CROSS JOIN json_array_elements(reference_numbers)
AS each_attribute
WHERE (each_attribute -> 'reference_number_field')
IS NOT NULL
#!/bin/bash
set -e
if ! grep -q xenial /etc/lsb-release
then
echo "Adding PPA for up-to-date Node.js runtime. Give your password when asked."
# sudo add-apt-repository ppa:chris-lea/node.js
sudo add-apt-repository ppa:chris-lea/redis-server
else
module ConcurrentExecutor
class Error < StandardError
def initialize(exceptions)
@exceptions = exceptions
super
end
def message
@exceptions.map { | e | e.message }.join "\n"
end
# -*- encoding: binary -*-
# This is the process manager of Unicorn. This manages worker
# processes which in turn handle the I/O and application process.
# Listener sockets are started in the master process and shared with
# forked worker children.
#
# Users do not need to know the internals of this class, but reading the
# {source}[https://bogomips.org/unicorn.git/tree/lib/unicorn/http_server.rb]
# is education for programmers wishing to learn how unicorn works.
# ..in general,
require 'rails'
require File.expand_path("../config/application.rb", __FILE__)
Rails.application.initialize!
# fork fork fork
ENV['UNICORN_WORKERS'].times do
fork do
# child