Skip to content

Instantly share code, notes, and snippets.

View firhatsungkar's full-sized avatar

Muhamad Firhat firhatsungkar

View GitHub Profile
using namespace System.Management.Automation
using namespace System.Management.Automation.Language
if ($host.Name -eq 'ConsoleHost')
{
Import-Module PSReadLine
}
#Import-Module PSColors
#Import-Module posh-git
Import-Module -Name Terminal-Icons
@firhatsungkar
firhatsungkar / memoizedHandlers.js
Created February 24, 2021 06:37 — forked from kyleshevlin/memoizedHandlers.js
Using React.useMemo to create a `handlers` object
// One of my new favorite React Hook patternms is to create handler
// functions for a custom hook using `React.useMemo` instead of
// `React.useCallback`, like so:
function useBool(initialState = false) {
const [state, setState] = React.useState(initialState)
// Instead of individual React.useCallbacks gathered into an object
// Let's memoize the whole object. Then, we can destructure the
// methods we need in our consuming component.
@firhatsungkar
firhatsungkar / mousemove.ps1
Created March 24, 2020 05:27 — forked from MatthewSteeples/mousemove.ps1
Powershell Script to keep the mouse moving
Add-Type -AssemblyName System.Windows.Forms
while ($true)
{
$Pos = [System.Windows.Forms.Cursor]::Position
$x = ($pos.X % 500) + 1
$y = ($pos.Y % 500) + 1
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($x, $y)
Start-Sleep -Seconds 10
}
@firhatsungkar
firhatsungkar / ssh.md
Created September 26, 2019 22:27 — forked from bradtraversy/ssh.md
SSH & DevOps Crash Course Snippets

SSH Cheat Sheet

This sheet goes along with this SSH YouTube tutorial

Login via SSH with password (LOCAL SERVER)

$ ssh brad@192.168.1.29

Create folder, file, install Apache (Just messing around)

$ mkdir test

$ cd test

@firhatsungkar
firhatsungkar / node_nginx_ssl.md
Created September 26, 2019 22:26 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

Python Cheat Sheet

Dependency in Python

  • virtualenv venv -p /usr/local/bin/python3
  • source ./venv/bin/activate
  • pip freeze > requirements.txt
  • pip install -r requirements.txt
@firhatsungkar
firhatsungkar / 01.js
Created February 20, 2019 08:07
js-array-object-challange
const makanan = [
'Sate dan Nasi',
'Nasi Goreng',
'Mie Rebus',
'Nasi Bakar',
'Tempe Goreng',
'Mie Goreng',
'Ikan Bakar',
'Nasi Uduk',
'Kerupuk',
@firhatsungkar
firhatsungkar / AbstractFactory.js
Last active January 30, 2019 01:05
Javascript Design Pattern
class Vehicle {
constructor(color, wheels, state) {
if(this.constructor == Vehicle) throw new Error('Vehicle is abstarct class')
}
getColor() { throw new Error('getColor must be emplemented')}
getWheels() { throw new Error('getWheels must be emplemented')}
getState() { throw new Error('getState must be emplemented')}
}
class Car extends Vehicle {
<?php
class ThemosisValetDriver extends BasicValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return bool
@firhatsungkar
firhatsungkar / gulpfile.js
Created November 4, 2016 03:42
Gulp-Frontend
'use strict';
/**
* Gulp Requiretment
* @type {[type]}
*/
var gulp = require('gulp');
var pug = require('gulp-pug');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');