Skip to content

Instantly share code, notes, and snippets.

View mul14's full-sized avatar
:octocat:
Preparing for big things...

Mulia Nasution mul14

:octocat:
Preparing for big things...
View GitHub Profile
@mul14
mul14 / 00_etc-hosts.md
Last active May 9, 2024 19:43
/etc/hosts for Vimeo, Reddit, Imgur, GitHub, DigitalOcean, dll

Unblock Steam, Vimeo, Reddit, Imgur, GitHub, DigitalOcean, NPM, PayPal, dll

Saya support Internet Positif untuk memblokir porn, situs judi, dan hal-hal ilegal lainnya. Tapi pemerintah dan ISP sangat konyol karena tidak mengizinkan akses ke Vimeo, Reddit, Imgur, Netflix--yang mana bukanlah situs dengan konten utama ilegal.

Linux / BSD / macOS

Tambahkan list di bawah ke /etc/hosts.

Windows

@mul14
mul14 / command.php
Last active April 7, 2024 16:42
Send signal to a process with PHP https://youtu.be/H2lp_jcfmu0
#!/usr/bin/env php
<?php
define('PID_PATH', '/tmp/myapp.pid');
define ('PID', (int) file_get_contents(PID_PATH));
if (empty($argv[1])) {
echo <<<INFO
@mul14
mul14 / profile.md
Created October 26, 2018 00:35 — forked from ezekg/profile.md
iTerm key bindings

Open the iTerm preferences ⌘+, and navigate to the Profiles tab (the Keys tab can be used, but adding keybinding to your profile allows you to save your profile and sync it to multiple computers) and keys sub-tab and enter the following:

Delete all characters left of the cursor

⌘+←Delete Send Hex Codes:

  • 0x18 0x7f – Less compatible, doesn't work in node and won't work in zsh by default, see below to fix zsh (bash/irb/pry should be fine), performs desired functionality when it does work.
  • 0x15 – More compatible, but typical functionality is to delete the entire line rather than just the characters to the left of the cursor.

Delete all characters right of the cursor

⌘+fn+←Delete or ⌘+Delete→ Send Hex Codes:

  • 0x0b
@mul14
mul14 / index.js
Created July 25, 2018 14:29
JavaScript DocBlock Cheat Sheet
/**
* Description of this function.
*
* @param {string} name
* @param {Date} birthday
* @param {boolean=} isMarried Optional parameter.
* @param {string|null} [bloodType]
* @param {number=} [weight=0] Optional parameter with default value.
* @param {string[]} favoriteFoods Array of String.
*
@mul14
mul14 / ApproachingFibonacci.js
Last active March 1, 2024 01:12
Someone give me some coding test on CoderByte. Here are the questions and my answers.
/*
Have the function
ArithGeo(arr)
take the array of numbers stored in
arr
and return the string
"Arithmetic"
if the sequence follows an arithmetic pattern or return
"Geometric"
if it follows a geometric pattern. If the sequence doesn't follow either pattern return
@mul14
mul14 / README.md
Last active January 4, 2024 12:34
Replace Laravel String and Array Helpers to Facade with regex
@mul14
mul14 / README.md
Last active February 10, 2023 00:55
Simple Laravel Search Trait

Usage

Put SearchTrait.php in app directory. Then use SearchTrait in your model, like so

use App\SearchTrait;
use Illuminate\Database\Eloquent\Model;

class Article extends Model 
{
@mul14
mul14 / README.md
Created March 24, 2021 04:17 — forked from danbst/README.md
[Linux] [Firefox] Open link in browser, which is in current workspace

I use separate Firefox profiles for work and personal stuff. To distinguish those I place them on different workspaces.

  • Workspace 0: firefox --no-remote -P MyJob
  • Workspace 1: firefox --no-remote -P default

I have also company Slack on Workspace 0. Which usually contains links to some work stuff.

The problem

@mul14
mul14 / encrypto.js
Created October 15, 2018 17:05
Node.js v10 - crypto.createDecipheriv()
// This is example of using crypto.createCipheriv(), because
// crypto.createCipher() is deprecated since Node.js v10
const crypto = require('crypto')
const encrypto = {
encrypt(text, password) {
const key = password.repeat(32).substr(0, 32)
const iv = password.repeat(16).substr(0, 16)
@mul14
mul14 / smooth-animated-scrolling.js
Created September 10, 2016 23:29
Smooth animated scrolling with JavaScript
// URL: https://css-tricks.com/snippets/jquery/smooth-scrolling/#comment-1599892
$(document).on('click', 'a[href*="#"]:not([href="#"])', function(e) {
if (location.pathname.replace(/^\//,'') === this.pathname.replace(/^\//,'') && location.hostname === this.hostname) {
let target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');