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
| # select user where id not in and where translator category is | |
| def search | |
| User.includes(:levels, :translator_categories).where('levels.name = ? AND translator_categories.name = ?', 'translator', 'Umum').where('users.id NOT IN (?)', [1,5,3,2]).references(:levels, :translator_categories) | |
| 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
| module RedisProjectHelper | |
| # set hash | |
| def set_project!(sample_store_id, sample_store_name) | |
| $redis.multi do | |
| $redis.hset(self.redis_new_project_key(), 'sample_id', sample_store_id) | |
| $redis.hset(self.redis_new_project_key(), 'sample_name', sample_store_name) | |
| 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
| case @obat | |
| when "sering sakit" | |
| "puasa sunnah" | |
| when "wajah terlihat murung tidak bercahaya" | |
| "shalat malam tahajud" | |
| when "hati sempit" | |
| "baca Al-Quran dan maknanya" | |
| when "tidak bahagia" | |
| "shalat diawal waktu" |
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
| source 'http://rubygems.org' | |
| # main gems | |
| gem 'sinatra' | |
| gem 'mysql2' |
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
| require './app' | |
| run App |
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
| require "mysql2" | |
| class MyDatabase | |
| def initialize | |
| @client = Mysql2::Client.new( | |
| :host => "localhost", | |
| :username => "root", | |
| :password => "yourpassword", | |
| :database => "sinatra" |
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
| require "sinatra" | |
| require_relative "my_db" | |
| class App < Sinatra::Base | |
| get '/' do | |
| return "Hello from Sinatra.rb" | |
| end | |
| get '/show_komedian' do | |
| content_type :json |
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 TextProcessingHelper | |
| MAIN_ARR = [ | |
| ['dr', 'dari'], | |
| ['dl', 'dalam'], | |
| ['dng', 'dengan'], | |
| ['dsb', 'dan sebagainya'], | |
| ['dp', 'dari pada'], | |
| ['dst', 'dan seterusnya'], | |
| ['krn', 'karna'], |
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
| # Array | |
| ## Manipulating element of string using squish (remove last whitespace) within array | |
| Array.collect{|a| a.squish || a } | |
| ## Return an array values by key of hash | |
| Hash.pluck(:your_key) | |
| ## Return an array keys from key of Hash | |
| Hash.keys |
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
| var ar = ["5", "3", "jhj", "opp", "tyt", "hkl", "aji", "6", "3", "kak", "lop", "gyt", "uyt", "ert", "wqa", "2", "3", "hhh", "bbb", "2", "5", "jonru", "bando"]; | |
| var i = 0; | |
| var x = 0; | |
| var reschild = []; | |
| var resparent = []; | |
| var m = 0; | |
| while (i < ar.length) { | |
| count_row = parseInt(ar[i]); | |
| length_text = parseInt(ar[i+1]); | |
| if(count_row > 0){ |