Skip to content

Instantly share code, notes, and snippets.

View ekyfauzi's full-sized avatar

Eky Fauzi ekyfauzi

View GitHub Profile
@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"
<?php
....
$url = parse_url(getenv("DATABASE_URL"));
$host = $url["host"];
$username = $url["user"];
$password = $url["pass"];
$database = substr($url["path"], 1);
@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)
@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.
<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 / 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 => {
@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 / NERDTree.mkd
Created November 26, 2015 12:12 — forked from m3nd3s/NERDTree.mkd
My Vim Cheat Sheet

NERDTree

o.......Open files, directories and bookmarks....................|NERDTree-o|
go......Open selected file, but leave cursor in the NERDTree.....|NERDTree-go|
t.......Open selected node/bookmark in a new tab.................|NERDTree-t|
T.......Same as 't' but keep the focus on the current tab........|NERDTree-T|
i.......Open selected file in a split window.....................|NERDTree-i|
gi......Same as i, but leave the cursor on the NERDTree..........|NERDTree-gi|
s.......Open selected file in a new vsplit.......................|NERDTree-s|
gs......Same as s, but leave the cursor on the NERDTree..........|NERDTree-gs|

O.......Recursively open the selected directory..................|NERDTree-O|

@ekyfauzi
ekyfauzi / rspec_model_testing_template.rb
Last active September 5, 2015 16:45 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
# app/models/image.rb
class Image < ActiveRecord::Base
include Commentable
end