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
<select2
v-model="something"
:options="[{ id: 1, text: '', selected: true }]"
multiple
placeholder
></select2>
@mul14
mul14 / Logger.ts
Last active April 5, 2018 12:42
Adapter pattern implementation on JavaScript
import { EOL } from 'os';
interface LoggerInterface {
error(message: string): string
info(message: string): string
}
class Logger implements LoggerInterface {
adapter = null
@mul14
mul14 / http.js
Created March 24, 2017 13:02
Example http request code
class Http {
static send(method, url) {
const request = new Request(url, {method})
return fetch(request)
.then(response => response.json())
.then(json => json)
}
@mul14
mul14 / steam-case-sensitive-fixer.sh
Created March 19, 2017 17:10
Steam client issue when using "case sensitive file system on macOS"
#!/bin/sh
#----------------------------------------------------------------------------------------
# It works!
# https://steamcommunity.com/discussions/forum/2/282992646978253149/#c282992646985999495
#----------------------------------------------------------------------------------------
USER=$(whoami)
cd /Users/${USER}/Library/Application\ Support/Steam/Steam.AppBundle/Steam/Contents/MacOS/public; ls *.res | while read line ; do file=$(echo $line | tr '[:upper:]' '[:lower:]'); mv $line $file; done
cd /Users/${USER}/Library/Application\ Support/Steam/Steam.AppBundle/Steam/Contents/MacOS/steam/cached/; ls *.res | while read line ; do file=$(echo $line | tr '[:upper:]' '[:lower:]'); mv $line $file; done
@mul14
mul14 / init.lua
Created December 22, 2016 00:56 — forked from prenagha/init.lua
Hammerspoon Config File, Hyper Key, Karabiner-Elements
-- hattip https://github.com/lodestone/hyper-hacks
-- hattip https://gist.github.com/ttscoff/cce98a711b5476166792d5e6f1ac5907
-- A global variable for the sub-key Hyper Mode
k = hs.hotkey.modal.new({}, 'F18')
-- Hyper+key for all the below are setup somewhere
-- The handler already exists, usually in Keyboard Maestro
-- we just have to get the right keystroke sent
@mul14
mul14 / init.lua
Created December 22, 2016 00:55 — forked from ttscoff/init.lua
Hammerspoon config examples for hyper key
-- A global variable for the Hyper Mode
k = hs.hotkey.modal.new({}, "F17")
-- Trigger existing hyper key shortcuts
k:bind({}, 'm', nil, function() hs.eventtap.keyStroke({"cmd","alt","shift","ctrl"}, 'm') end)
-- OR build your own
launch = function(appname)
@mul14
mul14 / homesteak.sh
Last active December 18, 2016 11:10
Laravel Homesteak
#!/usr/bin/env sh
# Laravel Homestead v3 and v4 are sucks!
# They removes useful commands like "homestead up" or "homestead ssh" from v2.
# Here is "homesteak", simple script to bring back those commands.
# Set composer directory.
if [ ! $COMPOSER_HOME = '' ]; then
COMPOSER_DIRECTORY="$COMPOSER_HOME";
elif [ ! $XDG_CONFIG_HOME = '' ]; then
@mul14
mul14 / selenium_curl.sh
Created December 4, 2016 02:27 — forked from prashanthrajagopal/selenium_curl.sh
Run Selenium test via curl
s_id=`curl -X POST http://127.0.0.1:4444/wd/hub/session -d '{"desiredCapabilities":{"browserName":"firefox","platform":"MAC"}}'|awk -F'"' '{print $6}'`
curl -X POST http://127.0.0.1:4444/wd/hub/session/$s_id/url -d '{"url":"http://www.google.com"}'
curl -X POST http://127.0.0.1:4444/wd/hub/session/$s_id/element -d '{"using":"id","value":"gbqfq"}'
curl -X POST http://127.0.0.1:4444/wd/hub/session/$s_id/element/0/value -d {"value":["selenium"]}
curl -X POST http://127.0.0.1:4444/wd/hub/session/$s_id/element -d '{"using":"id","value":"gbqfb"}'
curl -X POST http://127.0.0.1:4444/wd/hub/session/$s_id/element/1/click
curl -X DELETE http://127.0.0.1:4444/wd/hub/session/$s_id/window
@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 / nginx.conf
Created November 14, 2016 14:06
Nginx, PHP and CORS.
server {
listen 80;
server_name mydomain.com www.mydomain.com;
location / {
rewrite ^(.*)$ https://$server_name$1 permanent;
}
}