This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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://') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |