Skip to content

Instantly share code, notes, and snippets.

Oleg Obre

  • Berlin
Block or report user

Report or block Obre

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Obre
Obre / keycloak-defaults
Created Jun 4, 2019 — forked from markusleh/keycloak-defaults
Keycloak service script and default file for init.d
View keycloak-defaults
# General configuration for the init.d scripts,
# not necessarily for JBoss AS itself.
# default location: /etc/default/keycloak
## Location of JDK
# JAVA_HOME="/usr/lib/jvm/default-java"
## Location of WildFly
# JBOSS_HOME="/opt/keycloak"
View simpleEvenNumber.js
function isEven(n) {
if (n == 0)
return true;
else if (n == 1)
return false;
else if (n < 0)
return isEven(-n);
else
return isEven(n-2);
}
View reverseStrings.js
function reverseStringBuiltIn(str) {
return str.split("").reverse().join("");
}
console.log(reverseStringBuiltIn("himeinnameistundichbin"));
function reverStringForLoop(stri) {
var newString = "";
for (i = stri.length-1; i>=0; i--) {
newString += stri[i];
View removeAllMatchingInts.js
function solution(myArr) {
var myArr = [9, 3, 9, 3, 9, 7, 9, 4, 5, 6, 8, 3, 4, 1, 2, 5, 6, 7, 7, 4, 2];
var sortedArray = myArr.slice().sort();
var pairedArray = [];
var leftUnpaired = [];
console.log(sortedArray);
var i;
for (i = 0; i < sortedArray.length - 1; i++) {
if (sortedArray[i + 1] == sortedArray[i] || sortedArray[i - 1] == sortedArray[i]) {
View keepOnlyUniques.js
function solution(myArr) {
var myArr = [9, 3, 9, 3, 9, 7, 9];
var leng = myArr.length;
var result = [];
var leftObj = {};
var i;
for (i = 0; i < leng; i++) {
leftObj[myArr[i]] = 0;
}
View exponent.js
// looping variant
var power = function(base, exponent) {
var result = 1;
for (var count = 0; count < exponent; count++)
result *= base;
return result;
};
console.log(power(2, 10));
// recursive way (MUCH MUCH slower)
View recursiveFactorial.js
function fac(n) {
if (n == 0)
return 1;
else
return fac(n - 1) * n;
}
fac(10);
View upsideDownTriangle.js
// UPSIDE DOWN TRIANGLE
function asterisk(n) {
for (i = n - 1; i >= 0; i--) {
for (j = 0; j < n - i; j++) {
document.write("...");
}
for (k = 0; k < i * 2 + 1; k++) {
document.write(" * ");
View printTriangles.js
// NORMAL TRIANGLE left side
function triangle(n) {
for (i = 0; i < n; i++) {
for (j = 0; j < i + 1; j++) {
document.write(" * ");
}
document.write("</br>");
}
View printFibonacci.js
// first approach
function fibonacci(n) {
a = 0;
b = 1;
while (a <= n) {
console.log(a);
c = a + b;
a = b;
b = c;
}
You can’t perform that action at this time.