Skip to content

Instantly share code, notes, and snippets.

View imtiaz-emu's full-sized avatar
Patience is the key

Imtiaz Hossain Emu imtiaz-emu

Patience is the key
  • Ørsted
  • Kuala Lumpur, Malaysia
View GitHub Profile
@imtiaz-emu
imtiaz-emu / Gemfile
Last active August 2, 2023 09:14
Gist about capistrano deployment
group :development, :test do
gem 'capistrano', '~> 3.2.1'
gem 'capistrano-ext', '~> 1.2.1'
gem 'capistrano-rails', '~> 1.1.2'
gem 'rvm1-capistrano3', require: false
gem 'capistrano-file-permissions', '~> 0.1.0'
end
@imtiaz-emu
imtiaz-emu / Angular2 Subject
Created October 26, 2016 10:58
Angular2 subject not subscribing in the parent component
Folder sturcture:
- Datapanel
- datapanel.component.ts
- datapanel.html
- datapanel.module.ts
- DataConnector
- dataconnector.component.ts
- database-information.service.ts
{
"name": "median-client",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "http-server",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
{
"name": "median-client",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "http-server",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
@imtiaz-emu
imtiaz-emu / palindrome.rb
Created October 28, 2018 05:07
Inside the file "http://tech2.bumbung.net/questions/words.txt" is a list of words that we would like to test whether each word is a palindrome.
# I/O file location
file_path = "/home/emu/RubyProjects/Bumbung/words.txt" # words.txt file downloaded from the question link
output_path = "/home/emu/RubyProjects/Bumbung/palindrome.txt"
# read words from file
File.open(file_path, "r") do |f|
f.each_line do |line|
# remove punctuations from word, then downcase word to ignore case
str = line.gsub(/[^a-zA-Z0-9\-]/,"").downcase
@imtiaz-emu
imtiaz-emu / word_count.rb
Created October 28, 2018 05:09
Inside the file "http://tech2.bumbung.net/questions/article.txt" is an article that we would like to know the number of times each word has been shown.
str = gets.chomp # Take text input from console
# scan the text to remove punctuations and split
str = str.scan(/[\w']+/)
# create a Hash for storing the word count
words = Hash[str.uniq.map{ |i| [i, str.count(i)] }]
# print the number of times each word has been shown
for word, count in words
puts("#{word} = #{count}")
end
@imtiaz-emu
imtiaz-emu / prime_sum_with_consecutive_prime_sum.rb
Created January 17, 2019 17:03
Finology challenge: Sum of primes below 2 million and sum of consecutive prime below 1 million to be a prime.
'''
Problem 1
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17
Find the sum of all the primes below 2 million.
Problem 2
Which prime, below one million, can be written as the sum of the
most consecutive primes?
'''
defmodule Stats.Repo.Migrations.AddFeatureImageClickEventTrigger do
use Ecto.Migration
def up do
execute "DROP FUNCTION IF EXISTS ad_unit_current_reports_update() CASCADE;"
execute """
CREATE OR REPLACE FUNCTION ad_unit_current_reports_update() returns trigger as $$
declare
category varchar(20);
@imtiaz-emu
imtiaz-emu / smartApiAdGenRules.md
Last active January 5, 2021 05:21
SmartApi with Ad Generation Rules

SmartAPI: Let's say we already configured SmartAPI for fetching data from any weather API. Now we've two configurations:

Config 1:

Now we uploaded the feed inside smartTag and Add Filters:

  • AND Logic, selectors_data[city] contains 'Rome'
  • AND Logic, selectors_data[city] contains 'Singapore'

That means only 'Rome' and 'Singapore' city weather will be fetch from the API.

@imtiaz-emu
imtiaz-emu / data_extractor.rb
Last active February 16, 2021 05:15
Extract Data from a JSON (Ruby)
require 'active_support/core_ext/hash'
# Input: 'extra:[1:main:[5:provider]]'
# Output: ['extra', 1, 'main', 5, 'provider']
def macro_key_parser(str, keys = [])
first_key = str
first_key, second_key = str.split(':', 2) if first_key[0] != '['
if first_key[0] != '['
keys << first_key.strip
macro_key_parser(second_key, keys)