- Text Content Generator - http://www.lipsum.com
- Favicon Generator - http://tools.dynamicdrive.com/favicon
- Data Generator - https://mockaroo.com/
- Mobile Mockup Generator - https://mockuphone.com
- Logo Generator - https://www.logaster.com
- UUID Generator - https://www.uuidgenerator.net/
- Hash Generator - https://passwordsgenerator.net/sha256-hash-generator/
- Ultimate Code Generator - https://webcode.tools/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################### | |
# | |
# 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. | |
# |