Skip to content

Instantly share code, notes, and snippets.

View syafiqfaiz's full-sized avatar

syafiq faiz syafiqfaiz

View GitHub Profile
{
"info": {
"_postman_id": "86f8898b-d2a7-4c49-acc4-fdbda6d65450",
"name": "Kelas Programming. REST API basics: CRUD",
"description": "# 🚀 Get started here\n\nThis template guides you through CRUD operations (GET, POST, PUT, DELETE), variables, and tests.\n\n## 🔖 **How to use this template**\n\n#### **Step 1: Send requests**\n\nRESTful APIs allow you to perform CRUD operations using the POST, GET, PUT, and DELETE HTTP methods.\n\nThis collection contains each of these [request](https://learning.postman.com/docs/sending-requests/requests/) types. Open each request and click \"Send\" to see what happens.\n\n#### **Step 2: View responses**\n\nObserve the response tab for status code (200 OK), response time, and size.\n\n#### **Step 3: Send new Body data**\n\nUpdate or add new data in \"Body\" in the POST request. Typically, Body data is also used in PUT request.\n\n```\n{\n \"name\": \"Add your name in the body\"\n}\n\n ```\n\n#### **Step 4: Update the variable**\n\nVariables enable you to store and re
@syafiqfaiz
syafiqfaiz / exercise beserta jawapan.js
Last active February 25, 2024 04:12
latihan tambahan
const markah = [80, 99, 57, 40, 88, 39]
// kirakan purata
// // pseudocode
// // tambah semua, bahagi dengan bilangan
// let hasilTambahSemua = 0
// markah.forEach((nombor) => {
// hasilTambahSemua = hasilTambahSemua + nombor
// console.log(hasilTambahSemua)
@syafiqfaiz
syafiqfaiz / 4 fundamentals in programming.js
Created August 30, 2023 15:36
mentorship fundamental JS
// fundamental of any progamming langguage
1) variables
var namaVar = 'fikri'
let namaLet = 'fikri'
const namaConst = 'fikri'
const umur = 20
const biodata = {
tarikh_lahir: '20-10-1999',
@syafiqfaiz
syafiqfaiz / dump.sql
Last active August 23, 2023 12:41
SQL dump for sql introduction class
DROP TABLE IF EXISTS "public"."todo_items";
-- This script only contains the table creation statements and does not fully represent the table in the database. It's still missing: indices, triggers. Do not use it as a backup.
-- Sequence and defined type
CREATE SEQUENCE IF NOT EXISTS todo_items_id_seq;
-- Table Definition
CREATE TABLE "public"."todo_items" (
"id" int4 NOT NULL DEFAULT nextval('todo_items_id_seq'::regclass),
"text" text,
@syafiqfaiz
syafiqfaiz / people.rb
Last active June 27, 2023 02:46
How to use Google People V1 API using service acccount in Ruby.
require 'google/apis/people_v1'
require 'googleauth'
# Set up authorization
scopes = ['https://www.googleapis.com/auth/contacts']
credentials = Google::Auth::ServiceAccountCredentials.make_creds(
json_key_io: File.open('g_suite_service_account.json'),
scope: scopes,
)
credentials.sub = 'the_account_you_want_to_use@email.com'
@syafiqfaiz
syafiqfaiz / Blocking IO
Last active April 9, 2023 08:49
Node blocking and non blocking IO
const fs = require('fs');
console.log('hi 1')
const data = fs.readFileSync('./file.md', 'utf8'); // blocks here until file is read
console.log(data);
console.log('hi 3')
@syafiqfaiz
syafiqfaiz / Node JS Hello World
Created April 9, 2023 08:35
Simple Server with just node js
var http = require('http');
//create a server object:
http.createServer(function (req, res) {
res.write('Hello World!'); //write a response to the client
res.end(); //end the response
}).listen(5000); //the server object listens on port 8080
// Console will print the message
console.log('Server running at 5000');
@syafiqfaiz
syafiqfaiz / contoh github actions
Created May 9, 2021 01:12
contoh github action utk deploy node
name: Deploy Node
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
@syafiqfaiz
syafiqfaiz / Filterable.rb
Created June 14, 2019 03:05
A module to make a clean and simple filtering
module Filterable
extend ActiveSupport::Concern
module ClassMethods
def filter(filtering_params)
results = self.where(nil)
filtering_params.each do |key, value|
results = results.public_send(key, value) if value.present?
end
results
@syafiqfaiz
syafiqfaiz / how-to-copy-aws-rds-to-local.md
Last active February 21, 2024 06:00
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored