Skip to content

Instantly share code, notes, and snippets.

View midhunkrishna's full-sized avatar

Midhun Krishna midhunkrishna

View GitHub Profile
postgres=# \c nominatim;
You are now connected to database "nominatim" as user "postgres".
nominatim=# \di
List of relations
Schema | Name | Type | Owne
r | Table
--------+-------------------------------------------------------+-------+-------
----+---------------------------
public | idx_country_name_country_code | index | nomina
tim | country_name
# ..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
# -*- 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.
module ConcurrentExecutor
class Error < StandardError
def initialize(exceptions)
@exceptions = exceptions
super
end
def message
@exceptions.map { | e | e.message }.join "\n"
end
# from_cte_sql = ::Namespace::From.where_clause
# ..
from_table = Arel::Table.new(:from_lane)
to_table = Arel::Table.new(:to_lane)
rates_table = Arel::Table.new(:rates)
rates_table
.join(from_table).on(rates_table[:from_id].eq(from_table[:id]))
#!/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
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
@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
@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 / 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