Skip to content

Instantly share code, notes, and snippets.

View ekarudianto's full-sized avatar
💻
Typing ...

Eka Rudianto ekarudianto

💻
Typing ...
View GitHub Profile
@ekarudianto
ekarudianto / set_screen.sh
Created October 5, 2019 12:39
Set a custom screen resolution for ubuntu virtualbox 1920x1080
#!/bin/bash
# Add new mode
xrandr --newmode "1920x1080.00" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync
# Add the mode into registered monitor display
xrandr --addmode Virtual1 "1920x1080.00"
# Apply the resolution to pointed monitor display
xrandr --output Virtual1 --mode 1920x1080.00
@ekarudianto
ekarudianto / bump_version.sh
Created May 27, 2019 13:09 — forked from andyexeter/bump_version.sh
Bash script to increment version numbers in multiple files
#!/usr/bin/env bash
# Usage: ./bump_version.sh <major|minor|patch> - Increments the relevant version part by one.
#
# Usage 2: ./bump_version.sh <version-from> <version-to>
# e.g: ./bump_version.sh 1.1.1 2.0
set -e
# Define which files to update and the pattern to look for
URL="http://stackoverflow.com/"
# store the whole response with the status at the and
HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X POST $URL)
# extract the body
HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g')
# extract the status
HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
/**
* @message {String}
*/
function myFunction(message) {
// Need the index counter which I'll mention
// the reason on below comment
var printString = function(str, i) {
if(i === 0) return;
@ekarudianto
ekarudianto / Main.java
Created May 6, 2017 16:58
Codility lesson - Odd occurrences in array
/*
A non-empty zero-indexed array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired.
For example, in array A such that:
A[0] = 9 A[1] = 3 A[2] = 9
A[3] = 3 A[4] = 9 A[5] = 7
A[6] = 9
the elements at indexes 0 and 2 have value 9,
the elements at indexes 1 and 3 have value 3,
@ekarudianto
ekarudianto / Main.java
Last active May 6, 2017 16:52
Codility lesson - Binnary Gap (java)
public class Main {
private String BINARY_SPLITTER = "1";
public static int binaryGap(int N) {
String binary = Integer.toBinaryString(N);
if (binary.indexOf(BINARY_SPLITTER) != -1) {
String[] gap = binary.split(BINARY_SPLITTER);