Skip to content

Instantly share code, notes, and snippets.

View ekyfauzi's full-sized avatar

Eky Fauzi ekyfauzi

View GitHub Profile
@ekyfauzi
ekyfauzi / rails-postgres-backbone-bootstrap-bootswatch
Created July 31, 2016 08:40 — forked from sionc/rails-postgres-backbone-bootstrap-bootswatch
Instructions on creating a new app using Ruby on Rails, Postgresql, Backbone.js, Twitter Boostrap, Bootstwatch
- 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
@ekyfauzi
ekyfauzi / react-app-scrapping.js
Created October 18, 2017 07:24 — forked from juanbrujo/react-app-scrapping.js
Scrapping a React App using PhantomJS and Cheerio
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 => {
<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">
@ekyfauzi
ekyfauzi / sql_views.rake
Created May 7, 2018 03:57 — forked from rietta/sql_views.rake
SQL Views rake task implementing `rake db:views`
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.
@ekyfauzi
ekyfauzi / gist:21311b80d0381a03ff844b6fda2058fd
Created August 12, 2019 10:26 — forked from mattetti/gist:1015948
some excel formulas in Ruby
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)
<?php
....
$url = parse_url(getenv("DATABASE_URL"));
$host = $url["host"];
$username = $url["user"];
$password = $url["pass"];
$database = substr($url["path"], 1);
@ekyfauzi
ekyfauzi / user_password_django_pbkdf2_sha256.go
Created January 17, 2022 04:01 — forked from mununki/user_password_django_pbkdf2_sha256.go
[Go] Implementation Django default password hashing PBKDF2_SHA256 with Go
import (
"crypto/rand"
"crypto/sha256"
"crypto/subtle"
"encoding/base64"
"strconv"
"strings"
"time"
"golang.org/x/crypto/pbkdf2"