Skip to content

Instantly share code, notes, and snippets.

View agungyuliaji's full-sized avatar
🏠
Working from home

Agung Yuliaji agungyuliaji

🏠
Working from home
View GitHub Profile
@agungyuliaji
agungyuliaji / activerecord-find-by-year-day-or-month-on-a-date-field.rb
Last active September 12, 2023 00:13
ActiveRecord Find By Year, Day or Month on a Date field
Model.where(:date_column => date)
Model.where('extract(year from date_column) = ?', desired_year)
Model.where('extract(month from date_column) = ?', desired_month)
Model.where('extract(day from date_column) = ?', desired_day_of_month)
user_gain = {}
transactions.each do |t|
# bere persenan user ke 1 yg diatas
user_gain[user_gain_id_1] = [] if user_gain[user_gain_id_1].blank?
user_gain[user_gain_id_1] << nilai transaksi * 0.2%
# bere persenan user ke 2 yg diatas
# get: user_gain_id_2

Activities

  • coding frontend + test
  • problem solving
  • showcase logic, features, styles, etc
  • ngopi

Endpoints:

List

Aptitude::Calculation.new({:R=>[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5], :I=>[2, 4, 4, 2, 2, 1, 1, 3, 1, 1, 3, 3, 2, 2, 3], :A=>[4, 2, 2, 1, 4, 2, 2, 2, 2, 1, 1, 3, 4, 2, 2, 4, 1, 4], :S=>[3, 2, 3, 3, 3, 1, 1, 4, 4, 2, 2, 3, 2, 1, 4, 4, 1, 1], :E=>[3, 4, 4, 2, 3, 4, 1, 4, 1, 3, 4, 3, 4, 4, 4, 3, 4], :C=>[3, 3, 2, 4, 1, 2, 3, 1, 1, 1, 3, 4, 4, 1, 4, 4], :EI=>[1, 1, 3, 2, 4, 3, 4, 1, 2, 1], :SN=>[3, 2, 2, 2, 2, 4, 2, 4], :TF=>[1, 4, 2, 2, 2, 2, 4, 4, 3, 1, 2], :KE=>[1, 3, 1, 3, 1, 2, 4, 3, 3, 1]})
namespace :routes do
desc 'Print out all defined routes in match order, with names, per constraint class. Target specific constraint class with CONSTRAINT=x. Target specific controller with CONTROLLER=x.'
task constrained: :environment do
Rails.application.reload_routes!
constraints_routes = Hash.new
Rails.application.routes.routes.each do |route|
group = (route.app.class == ActionDispatch::Routing::Mapper::Constraints ? route.app.send( :constraints ).first.to_s : 'No constraint class')
constraints_routes[group] ||= []
server {
listen 5500;
server_name localhost;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://localhost:5000;
}
openssl req \
-newkey rsa:2048 \
-x509 \
-nodes \
-keyout localsite.key \
-new \
-out localsite.crt \
-subj /CN=\*.localsite.dev \
-reqexts SAN \
-extensions SAN \
{"Lorem": "ipsum2"}
{"dolor": "sit"}
{"amet": "consectetur"}
{"adipiscing": "elit"}
{"Sed": "mattis"}
{"justo": "at"}
{"purus": "pulvinar"}
{"varius": "Nullam"}
{"eget": "magna"}
{"eget": "lorem"}
var schedulesControllers = angular.module('schedulesControllers', []);
schedulesControllers.controller('weekControllers', function($scope, $ionicHistory, $ionicLoading, schedulesService, $ionicSlideBoxDelegate, $interval, $filter, $state) {
$ionicLoading.show({
content: 'Loading',
animation: 'fade-in',
showBackdrop: true,
maxWidth: 200,
showDelay: 0
});
@agungyuliaji
agungyuliaji / download_and_compress_rails_api
Last active December 26, 2015 12:09 — forked from guzart/download
Download and Compress Rails API
#!/bin/bash
rm -rf api.rubyonrails.org/
wget -r -k -p http://api.rubyonrails.org/
rm rails_api.rar
rar a -r rails_api.rar api.rubyonrails.org/