This file contains 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
- Check rails version | |
$ rails -v | |
- To update rails | |
$ gem update rails | |
- Creating a new rails app using postgresql | |
$ mkdir rails_projects | |
$ cd rails_projects | |
$ rails new myapp --database=postgresql |
This file contains 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 phantom = require('phantom'); | |
var Q = require('q'); | |
var cheerio = require('cheerio'); | |
var _ph, _page, _outObj; | |
var url = ABSOLUTE_URL; // change here for your React app site | |
phantom.create().then(ph => { | |
_ph = ph; | |
return _ph.createPage(); | |
}).then(page => { |
This file contains 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
<html> | |
<head> | |
<title>Google Maps Multiple Markers</title> | |
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script> | |
</head> | |
<body> | |
<div id="map" style="height: 400px; width: 500px;"> | |
</div> | |
<script type="text/javascript"> |
This file contains 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
namespace :db do | |
desc "Update and create SQL views" | |
task :views => :environment do | |
Dir["#{Rails.root}/db/sql_views/*.sql"].each do |file_name| | |
STDERR.puts "Applying the SQL view at #{file_name}" | |
source_file = File.new(file_name, 'r') | |
if source_file and (sql_content = source_file.read) | |
ActiveRecord::Base.transaction do | |
# Each statement ends with a semicolon followed by a newline. |
This file contains 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 Excel | |
module Formulas | |
def pmt(rate, nper, pv, fv=0, type=0) | |
((-pv * pvif(rate, nper) - fv ) / ((1.0 + rate * type) * fvifa(rate, nper))) | |
end | |
def ipmt(rate, per, nper, pv, fv=0, type=0) | |
p = pmt(rate, nper, pv, fv, 0); | |
ip = -(pv * pow1p(rate, per - 1) * rate + p * pow1pm1(rate, per - 1)) | |
(type == 0) ? ip : ip / (1 + rate) |
This file contains 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
<?php | |
.... | |
$url = parse_url(getenv("DATABASE_URL")); | |
$host = $url["host"]; | |
$username = $url["user"]; | |
$password = $url["pass"]; | |
$database = substr($url["path"], 1); |
This file contains 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
import ( | |
"crypto/rand" | |
"crypto/sha256" | |
"crypto/subtle" | |
"encoding/base64" | |
"strconv" | |
"strings" | |
"time" | |
"golang.org/x/crypto/pbkdf2" |
OlderNewer