Skip to content

Instantly share code, notes, and snippets.

@geekdreamzz
geekdreamzz / javascript-ForLoop.html
Last active December 22, 2015 20:59
If given integer N and computing from 0 to N, and counting the number of times an integer appears containing a "5". What would be your best solution? Here's what I got. Included in this html document is a web form and some javascript.
<HTML>
<HEAD>
<SCRIPT language=Javascript>
//only accept numeric values in input box
function isNumeric(num)
{
var charCode = (num.which) ? num.which : event.keyCode;
if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) return false;
@geekdreamzz
geekdreamzz / email_settings.yml
Created September 12, 2013 04:36
Have you ever needed to set different SMTP settings for Action Mailer in your different environments? Perhaps yes perhaps no, but here's an easy to implement solution. Do you agree with this solution? 1. add mailer_settings.rb to the /initializers directory in your Rails app 2. edit the email_settings.yml with your specific SMTP settings and sav…
#Action Mailer SMTP settings
#Visit http://guides.rubyonrails.org/configuring.html#configuring-action-mailer
#For all possible configurations
development:
:address:
:port:
:authentication:
:user_name:
:password:
@geekdreamzz
geekdreamzz / database.example.yml
Last active December 22, 2015 21:29
Is there a legitimate use case where a system may contain multiple database? What if you have many applications but want a centralized user database that is accessible to your numerous apps that also have a hefty database schema of its own? Here's a possible solution that is very easy to implement, what do you think? 1. Add new database connecti…
#Add multiple databases to a Rails App
#given you have other database connections you'd like to define inside the rails app
#Here's a possible solution to define multiple databases
#do not copy this template over your current configuration
#just add/name the connection and add _staging or _production (whichever environment the DB is for)
#to the current database.yml
#imagine we have a seperate database that manages members
#these members have access to this app, and 10 other apps you / your start-up ;) has developed.
#so the members database is separate and here we make members accessible to this app.
@geekdreamzz
geekdreamzz / tokenizer
Last active January 18, 2019 16:10
wip tokenizing word phrases - planning to develop a tokenizer that can pluck entities outside of a phrase, like topics, citations, jurisdictions, companies, people etc. also detect things like intent, "is a question"? statement .... for now the purpose of this is to tokenize each subphrase permutation like a tree. example. "this test phrase" get…
#!/usr/bin/env ruby
require 'pry'
module Phrase
class Tokenizer
def initialize(phrase)
@phrase = phrase
end
def phrase
<!DOCTYPE html>
<html>
<head>
<title>Multi Stock Analyzer</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
</head>
<body>