Skip to content

Instantly share code, notes, and snippets.

View manojnaidu619's full-sized avatar
🎯
Focusing

Manoj Kumar manojnaidu619

🎯
Focusing
  • Bangalore,India
View GitHub Profile
@manojnaidu619
manojnaidu619 / LCS.c
Last active July 1, 2019 17:28
Finding Longest Common Subsequence in C
#include<stdio.h>
#include<string.h>
int max(int a, int b);
void findLCS(char X[], char Y[], int XLen, int YLen);
int max(int a, int b) {
return (a > b)? a : b;
}
@manojnaidu619
manojnaidu619 / tower_of_hanoi.c
Created May 16, 2019 11:35
Solving Tower of Hanoi in C
#include <stdio.h>
int count=0;
void hanoi(int n,char from,char to,char aux){
if(n>0){
hanoi(n-1,from,aux,to);
++count;
printf("Disk %d from %c -> %c\n",n,from,to);
hanoi(n-1,aux,to,from);
}
}
@manojnaidu619
manojnaidu619 / quick_sort.c
Last active July 1, 2019 17:31
Quick Sort program in C
// Refer to these video tutorials :
// https://www.youtube.com/watch?v=MZaf_9IZCrc
// and
// https://www.youtube.com/watch?v=T3Paafdqcsw
#include <stdio.h>
void quick(int a[], int first, int last){
if(first<last){
@manojnaidu619
manojnaidu619 / atm.rb
Last active July 1, 2019 17:34
Codechef ATM problem in ruby
#problem link : https://www.codechef.com/problems/HS08TEST
$stdin.each do |num|
arr = num.strip.split(/\s+/).map(&:to_f)
final = arr.last - arr.first - 0.50
if (arr.first % 5) == 0 and arr.first < arr.last and arr.first > 0 and final >= 0
puts ('%.2f' % final)
else
puts ('%.2f' % arr.last)
end
@manojnaidu619
manojnaidu619 / binary_search.c
Created November 21, 2018 17:24
Binary search in C
#include<stdio.h>
#include<stdlib.h>
int main(){
int n, a[100], search;
printf("Enter size of array\n");
scanf("%d",&n);
printf("enter %d elements\n",n);
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
@bradtraversy
bradtraversy / webdev_online_resources.md
Last active May 11, 2025 21:13
Online Resources For Web Developers (No Downloading)
@mankind
mankind / rails-jsonb-queries
Last active May 3, 2025 05:37
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@johncip
johncip / rails_eager_load.md
Last active December 28, 2024 15:12
Active Record eager loading strategies

N+1 query problem

  • ORMs make it easy to a query per loop iteration, which we want to avoid

eager_load

  • single query (left outer join)
  • can reference the other table's columns in where

preload

  • a few queries (one per table)
  • typically faster
@jrochkind
jrochkind / gist:59b6330e3f52710cc49e
Last active June 8, 2023 07:47
Monkey patch to ActiveRecord to forbid
######################
#
# Monkey patch to ActiveRecord to prevent 'implicit' checkouts. Currently tested with Rails 4.0.8, prob
# should work fine in Rails 4.1 too.
#
# If you create a thread yourself, if it uses ActiveRecord objects without
# explicitly checking out a connection, one will still be checked out implicitly.
# If it is never checked back in with `ActiveRecord::Base.clear_active_connections!`,
# then it will be leaked.
#
@lancejpollard
lancejpollard / meta-tags.md
Created March 5, 2012 13:54
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta name="keywords" content="your, tags"/>
<meta name="description" content="150 words"/>
<meta name="subject" content="your website's subject">
<meta name="copyright"content="company name">
<meta name="language" content="ES">