Skip to content

Instantly share code, notes, and snippets.

View acfatah's full-sized avatar
🚀
Looking for a new opportunity

Achmad F. Ibrahim acfatah

🚀
Looking for a new opportunity
View GitHub Profile
The MIT License (MIT)
Copyright (c) 2013 Jamar Parris
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE S
@acfatah
acfatah / node-sample.js
Created May 13, 2022 00:36 — forked from gus3inov/node-sample.js
get battery info with node.js
const http = require('http');
const PORT = Number(process.argv[2]) || 8080;
const child_process = require('child_process');
const Routes = {
BATTERY: /\/battery\/?/
};
const Status = {
NOT_FOUND: 404,
@acfatah
acfatah / install
Last active July 10, 2021 16:24
Bash command to install Brave browser on linux
#!/usr/bin/env bash
# https://brave.com/linux/#debian-9-ubuntu-1604-and-mint-18
sudo apt install -y apt-transport-https curl &&
sudo curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg &&
echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg arch=amd64] https://brave-browser-apt-release.s3.brave.com/ stable main"|sudo tee /etc/apt/sources.list.d/brave-browser-release.list &&
sudo apt update && sudo apt install -y brave-browser
@acfatah
acfatah / vim-shortcuts.md
Created June 17, 2021 09:16 — forked from tuxfight3r/vim-shortcuts.md
VIM SHORTCUTS

VIM KEYBOARD SHORTCUTS

MOVEMENT

h        -   Move left
j        -   Move down
k        -   Move up
l        -   Move right
$        -   Move to end of line
0        -   Move to beginning of line (including whitespace)
@acfatah
acfatah / 01.md
Last active March 18, 2024 04:50
How to set up Rails 6 production on Digital Ocean One Click Ruby on Rails Droplet

How to set up Rails 6 production on Digital Ocean One Click Ruby on Rails Droplet

1. Clone The Source

Clone the source repository.

2. Generate Secret Key

Run rails secret to generate secret key and set SECRET_KEY_BASE to the value later in ~/.profile.

@acfatah
acfatah / github markdown syntax.md
Last active September 23, 2020 00:35 — forked from MinhasKamal/github markdown syntax.md
Markdown Syntax for GitHub.
/**
* Checks whether two numbers are approximately equal to each other, with a small difference
* @param {number} alpha
* @param {number} beta
* @param {number} [epsilon=0.001]
* @returns {boolean}
*/
export default (alpha, beta, epsilon = 0.001) => Math.abs(alpha - beta) < epsilon
@acfatah
acfatah / rubyrails.rb
Created May 2, 2020 16:45
Gravatar link generator. Please refer: https://en.gravatar.com/site/implement
# require 'digest/md5'
def gravatar_link(email, size=80)
valid_email = /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/
raise 'Invalid email address' unless !!email.match(valid_email)
raise 'Invalid gravatar image size' unless size.positive? && size < 2048
hash = Digest::MD5.hexdigest(email.downcase)
"https://www.gravatar.com/avatar/#{hash}?s=#{size}"
end
@acfatah
acfatah / parseToken.js
Created September 25, 2019 01:25
Authorization Bearer Token Parser Function For Express
export default request => {
let parts = request.headers.authorization.split(' ')
if (request.headers.authorization && parts[0] === 'Bearer') {
return parts[1]
} else if (request.query && request.query.token) {
return request.query.token
}
}
@acfatah
acfatah / index.js
Last active May 26, 2024 10:59
Quasar Vue Router Middleware Pipeline Example
// router/index.js
import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'
import middlewarePipeline from './middleware-pipeline'
Vue.use(VueRouter)