Skip to content

Instantly share code, notes, and snippets.

View sabril's full-sized avatar

Muhammad Syaiful Sabril sabril

View GitHub Profile
require File.join(File.dirname(__FILE__), "../lib/diffie_hellman")
curve = Ecc::Curve.new 324, 1287, 3851
point = Ecc::Point.new 920, 303
server = Ecc::DiffieHellman.new curve, point, 1194
client = Ecc::DiffieHellman.new curve, point, 1759
server_pub = server.computePublicKey()
puts "Server Public Key: #{server_pub}"
@sabril
sabril / ecdh.rb
Last active February 5, 2018 06:22
#openssl
require 'openssl'
require 'base64'
require "digest"
include OpenSSL
def aes256_encrypt(key, data)
key = Digest::SHA256.digest(key) if(key.kind_of?(String) && 32 != key.bytesize)
aes = OpenSSL::Cipher.new('AES-256-CBC')
aes.encrypt
@sabril
sabril / user.rb
Created October 21, 2014 22:52
How to refresh Google token
require 'google/api_client'
require 'google/api_client/client_secrets'
require 'google/api_client/auth/installed_app'
class User < ActiveRecord::Base
def save_google_credentials(omniauth, params)
if omniauth["credentials"]["refresh_token"]
self.google_access_token = omniauth["credentials"]["token"]
@sabril
sabril / hello.rb
Last active January 16, 2016 16:32
test code
puts "hello ruby :-)"
ls -lah hello.rb
require 'mobile/mobile_helper'
describe 'TaskOperations', type: :request, focus: false do
before(:each) do
@account = FactoryGirl.create(:account_with_admin)
@location = @account.locations.first
@admin = FactoryGirl.create(:admin, loc_id: @location.id, account_id: @account.id)
param = FactoryGirl.attributes_for(:patient, loc_id: @location.id, account: @account, email: '[email protected]')
@patient = create_user(param, @account, @admin, 'Patient')
sudo apt-get update
\curl -sSL https://get.rvm.io | bash -s stable
sudo apt-get -y install postgresql postgresql-contrib libpq-dev
touch ~/.gemrc
echo 'install: --no-rdoc --no-ri' >> ~/.gemrc
gem install bundler --prerelease
gem install rails
rails new . -d postgresql
@sabril
sabril / show.html.erb
Created July 14, 2017 17:01
Task Show view
<div class="row">
<div class="col m8 offset-m2">
<% if @task.video_url.present? %>
<div class="card z-depth-2">
<div class="card-image waves-effect waves-block waves-light">
<div class="center">
<iframe width="100%" height="315" src="<%= @task.video_url %>" frameborder="0" allowfullscreen></iframe>
</div>
</div>
</div>
@sabril
sabril / index.html.erb
Created August 3, 2017 23:42
Halaman Index
<div class="row">
<br/>
<% @courses.each do |course| %>
<%= link_to course do %>
<div class="col s12 m6">
<div class="card">
<div class="card-image waves-effect waves-block waves-light">
<%= image_tag course.image.url %>
</div>
<div class="card-content">
@sabril
sabril / config.yml
Last active September 6, 2017 00:26
version: 2
jobs:
build:
working_directory: ~/circleci-demo-ruby-rails
docker:
- image: circleci/ruby:2.4.1-node
environment:
RAILS_ENV: test
PGHOST: 127.0.0.1
PGUSER: root