Skip to content

Instantly share code, notes, and snippets.

@sadikovi
sadikovi / writeback_for_custom_call.js
Last active August 7, 2016 16:12
That is basically what you have to edit to make OBI Write Back perform custom calls (for update or insert)
if (!('indexOf' in Array.prototype)) {
Array.prototype.indexOf = function(find) {
var i = 0;
for (var n = this.length; i<n; i++) {
if (i in this && this[i] == find) {
return i;
}
}
return -1;
@sadikovi
sadikovi / spinbox_1_1_code.js
Last active August 29, 2015 14:06
OBIEE spin box with decimal values (increment and decrement buttons work now!)
//
var SIT = {
P_GLOBAL_FLOAT_NUM : 2,
P_GLOBAL_FLOAT_DEC : 10,
P_GLOBAL_FLOAT_STEP : 1
}
//
obips.SliderBase.Controller.prototype.incrementAValue = function (a) {
return this.adjust(
@sadikovi
sadikovi / hierarchy_builder.js
Created September 26, 2014 09:30
Nice and simple hierarchy in OBIEE for dashboard (can be used to categorise analyses or documents)
/**
*
* Hierarchy Builder
* hierarchy can be builded via xml-file and json
*
* Methods:
* 1. [not required parameter] opened list level: SIT.listLevelOpen
* (e.g. SIT.listLevelOpen = 2) it means that "systemRoot", 1 level and 2 level will be opened after load
*
* 2. public function for hierarchy builder via XML: SIT.buildHierarchyWithXML(node, XMLUrl, treeModelId, winTarget) {
@sadikovi
sadikovi / Multi_Analysis_AutoRefresh.html
Last active August 29, 2015 14:06
Oracle BI EE Analysis Autorefresh (supports more than one analysis on a dashboard)
<!--> example of div
<div id="_autoref1"></div>
<-->
<script type="text/javascript">
/**
1. Add to analysis "<div id="_autoref1"></div>" with some specified id (f.i. _autoref1) using Static Text or Narrative or something else
2. If you have a lot of analyses, you need to add a div to each of them using unique id (for example, _autoref1, _autoref2, _autoref3 and etc.)
3. Change var "refreshIds" by adding all the ids you have used in analyses to refresh
4. Next step is to add analyses to dashboard and add script below on the dashboard page
*/
@sadikovi
sadikovi / sensor_node_code.ino
Created October 16, 2014 02:31
Sensor node code for the RLCS prototype
const int switchPin = 2; // digital pin for glass reed
const int lightPin = 3; // digital pin for light
const String sensorId = "111A0"; // id of the sensor
int lightValue = 0; // global light value
boolean isAutoChanged = false; // global variable to track changes
void setup() {
pinMode(switchPin, INPUT);
pinMode(lightPin, OUTPUT);
digitalWrite(switchPin, HIGH);
@sadikovi
sadikovi / TransformationCount.java
Created November 6, 2014 22:34
You are given two strings A and B of length n over a fixed alphabet Σ. You want to transform A into B using a number of operations of the following type: Pick a substring of the current string and a symbol σ ∈ Σ, and change every symbol of the substring into σ. Develop a polynomial-time algorithm to compute the minimum number of such operations …
package project1;
public class TransformationCount {
public TransformationCount() {
super();
}
// check if word is an anagram
private static boolean isAnagram(String a) {
if (a.isEmpty() || a.length() == 1)
//
// SVG — hasClass, addClass, removeClass, toggleClass
// Source:
// https://gist.github.com/branneman/8436956
// Taken and adapted from:
// http://toddmotto.com/hacking-svg-traversing-with-ease-addclass-removeclass-toggleclass-functions/
//
if (SVGElement && SVGElement.prototype) {
# Script to fetch Yahoo Finance data and write it back to the spreadsheet
### How to run ###
#
# Save script somewhere on a hard drive (let's say test.py)
# Open a command line (or terminal on Mac OS)
# Assuming that python interactive interpreter is not loaded run:
# > python test.py -u username -p password
# where "username" and "password" is credentials to access Google Sheets spreadsheet
#
### Work Flow ###
@sadikovi
sadikovi / accounts.txt
Created January 23, 2015 05:14
Payfork, easy way to keep records of rent payments
{"admin": {"password": "d63dc919e201d7bc4c825630d2cf25fdc93d4b2f0d46706d29038d01", "level": "admin"}, "sadikovi": {"password": "90a3ed9e32b2aaf4c61c410eb925426119e1a9dc53d4286ade99a809", "level": "user"}}
@sadikovi
sadikovi / buildHierarchy.py
Last active August 29, 2015 14:15
Hierarchy is built from array of elements. Code detects cycles and references to non-existing parents
'#Public - Builds hierarchy in place'
def buildHierarchy(self):
#create dictionary {"parent_id":["child1", "child2",..]}
pmap = {} #map where all the children are mapped to their parent ids
roots = [] #roots - elements with parent "None"
for key in self.keys():
group = self.get(key)
pid = group.getParent() if self.has(group.getParent()) else None
#if pid is None, we know that it is a root element
if pid is None: roots.append(group)