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
module Searchable | |
extend ActiveSupport::Concern | |
included do | |
## | |
# A simple search method | |
def self.search text | |
columns = self::SearchableColumns | |
words = text.downcase.gsub(/[^a-z0-9\s]/i, ' ').split(/\s+/) | |
query_array_2 = [] |
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
console.log("Hello World!\n"); | |
function sort_by_price(a, b){ | |
return a.price > b.price; | |
} | |
array = [{price: 100}, {price: 50}, {price: 70}]; | |
console.log(array); | |
sorted_array = array.sort(sort_by_price); |
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
class Fixnum | |
def prime? | |
return true if self == 1 | |
2.upto(self) do |num| | |
if self % num == 0 | |
return self == num | |
1.upto(100) do |num| | |
puts num if num.prime? |
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
def prime(num): | |
if num == 1: | |
return True | |
for i in range(num): | |
if (num % (i + 2)) == 0: | |
if num == (i + 2): | |
return True | |
else: | |
return False |
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
class Fixnum | |
def prime? | |
return true if self == 1 | |
2.upto(self) do |num| | |
if self % num == 0 | |
return self == num | |
end | |
end | |
end | |
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
$ pip install pyftpdlib | |
$ python -m pyftpdlib | |
# Temporary FTP server |
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
class User < ActiveRecord::Base | |
def status time = Time.now | |
statuses.where("statuses.created_at <= '#{time.to_s(:db)}'"). | |
order("statuses.created_at desc").first | |
end | |
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
class User < ActiveRecord::Base | |
def status time = Time.now | |
statuses.where("created_at <= '#{time.to_s(:db)}'"). | |
order("created_at desc").first | |
end | |
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> | |
int main(){ | |
printf("Hello World!\n"); | |
return 0; | |
} |
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
def ist(time) | |
time.in_time_zone(TZInfo::Timezone.get('Asia/Kolkata')) | |
end |
OlderNewer