Skip to content

Instantly share code, notes, and snippets.

Bulding fun-project

Ardian Bahtiarsyah absyah

Bulding fun-project
Block or report user

Report or block absyah

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
absyah / whiteboard1
Last active Oct 2, 2019
Whiteboard Coding Test
View whiteboard1
cari kata “forstok” dari sebuah kata:
-ffffforrrrrrstookkkk answer YES
-forastok answer YES
-forlikesvrtyeok answer YES
-dhkortfsuhuahjdhsjhdjshs answer NO
function forstokString(s) {
absyah / cURL
Created Sep 5, 2019
curl with measures
View cURL
curl -H "User-Agent: Forstok-System" -H "Authorization: Bearer MmxH1sWGSeuqvbtP2N3NRg" -H "Content-type: application/json" "" -w "@curl-format" -o /dev/null -s
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
View A helpful ActiveRecord setting only 1 person has ever used
A memory-saving ActiveRecord setting has been used by just one application ever, according to GitHub
There's a common performance problem in many Rails background jobs.
Background jobs often do operations across large sets of data. Basically, they do silly things like User.all.each(&:send_daily_newsletter).
So, there's a problem with that query. In development and test environments, User.all will probably return a few rows, maybe a dozen at most. Most developers have extremely limited seed data on their local machines.
In production, however, User.all will probably return quite a few rows. Depending on the app you work on, maybe a few hundred thousand.
There's a tiiiiiny issue with a result set that returns 100,000 rows, and it's not just that the SQL query will take a long time to return. It will have irreversible effects on your Ruby app too!
View Docker Commands
# show containers
docker ps
# Logging to container
docker logs -f <container_id>
# ssh to container
docker exec -it <container_id> /bin/bash
# build container
absyah / samples.txt
Created Feb 21, 2019
Apisentris API Examples
View samples.txt
Apisentris API endpoints
table name: programmers
### Get Programmers
curl -H "client_id: 141000"\
-H "access_token: 3zov2Syn0ahUfqwuFYw0VQ"\
absyah / base.rb
Created Dec 28, 2018 — forked from sunny/base.rb
Rails utility class for objets to act like ActiveRecord::Base
View base.rb
# encoding: utf-8
# Base class to inherit from for objects to act like ActiveRecord::Base
# without using a database. Lets you use validations, errors, forms, routes.
# Example:
# class Exporter < Base
# attributes_accessor :email, :data
# end
class Base
extend ActiveModel::Naming
absyah / index.html
Last active Nov 26, 2018
iframe widget
View index.html
(function(d, h, m){
var js, fjs = d.getElementsByTagName(h)[0];
if (d.getElementById(m)){return;}
js = d.createElement(h); = m;
js.onload = function(){
position: "left", // left || right
emailhash: "e5507bee9e0bb54a1c5ea5df164c74a1", // your md5 encoded email address
View gist:c9cc9e0ddc8ad54af52f47f252a59523
# Video:
Hi everyone, I'm Chris Wanstrath.
When Jeremy asked me to come talk, I said yes. Hell yes. Immediately. But
then I took a few moments and thought, Wait, why? Why me? What am I supposed
to say that's interesting? Something about Ruby, perhaps. Maybe the
future of it. The future of something, at least. That sounds
absyah / execute
Last active Apr 16, 2018
mass linking script
View execute
csv_text ='/home/ardian/Downloads/mass_link.csv')
csv = CSV.parse(csv_text, :headers => true)
csv.each do |row|
hash = row.to_hash
hash['SKU Elevenia']
hash['Master SKU Forstok']['Master SKU Forstok'], hash['SKU Elevenia']).link
You can’t perform that action at this time.