Skip to content

Instantly share code, notes, and snippets.

@DraganDanicic
DraganDanicic / Vibration.cs
Created July 30, 2020 21:00 — forked from aVolpe/Vibration.cs
Vibration for Unity3d with Android native Call, with fallback to Handlheld.Vibrate()
using UnityEngine;
using System.Collections;
public static class Vibration
{
#if UNITY_ANDROID && !UNITY_EDITOR
public static AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
public static AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
public static AndroidJavaObject vibrator = currentActivity.Call<AndroidJavaObject>("getSystemService", "vibrator");
@DraganDanicic
DraganDanicic / codility.js
Created October 26, 2019 06:09
Codility tasks, JS
//===========================================================++++++*..
// PermCheck JS solution, all grades 100%.
// function solution(A) {
function permCheck(A) {
// write your code in JavaScript (Node.js 8.9.4)
const indexMap = {};
const sum = A.reduce((a, e, i) => {
indexMap[e] = true;
return a - e + i + 1;
}, 0);