Skip to content

Instantly share code, notes, and snippets.

@gb1
gb1 / gist:6bc6e8fa213aeaa624c5
Created March 16, 2015 17:35
Patch to Fiori Reference Library
//add new item to filter
var filterTemplate = new sap.m.ViewSettingsItem({key: "releaseName___EQ___{externalName}", text: "{externalName}"});
var filterItem = new sap.m.ViewSettingsFilterItem("F7", {text: "Release"});
filterItem.bindAggregation("items", {path: "/Releases_EV" , template: filterTemplate});
this._oFilterDialog.addFilterItem(filterItem);
//fix bug where filters are not being reset
this.oldFunction = this.onFilterPressed;
var newFunction = function(oEvent){ this.oldFunction(oEvent);this.getList().getBinding('items').aFilters = []; };
this.onFilterPressed = newFunction;
@gb1
gb1 / index.html
Created May 29, 2015 09:28
JS Bin XML View // source http://jsbin.com/hekubohura
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="XML View">
<script src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js" id="sap-ui-bootstrap" data-sap-ui-theme="sap_bluecrystal" data-sap-ui-libs="sap.m"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<!-- XML-based view definition -->
@gb1
gb1 / day1.js
Last active December 4, 2015 14:43
Solution for day1 of http://adventofcode.com/
/**
* Solution for day1 of http://adventofcode.com/
*/
var fs = require('fs');
fs.readFile('day1input.txt', 'utf8', function (err,data) {
if (err) {
return console.log(err);
}
@gb1
gb1 / server.js
Created December 9, 2015 17:37
Proxy an OData service
var app = require('express')();
var request = require('request');
app.get('/', function (req, res) {
res.send('Hello World');
});
app.get('/nw*', function(req, res){
//get request url and strip off the /nw/
@gb1
gb1 / Piggy.sol
Created September 7, 2017 09:30
Ethereum piggy bank
pragma solidity ^0.4.0;
contract Piggy {
uint target = 1000000000000000000;
event Msg( string msg);
mapping(address => uint) balances;
@gb1
gb1 / day24.ex
Created November 26, 2018 11:17
defmodule Aoc.Day24 do
def read_input(file) do
# File.read!("./input/day24_sample.txt")
File.read!(file)
|> String.split("\r\n", trim: true)
|> Enum.map(fn x ->
[a, b] = String.split(x, "/")
{String.to_integer(a), String.to_integer(b)}
end)
end
defmodule Aoc.Day24 do
def go do
g = read_input() |> create_graph()
dfs([{0,30}], [], g, [])
end
def read_input(file \\ "./input/day24.txt") do
File.read!(file)
|> String.split("\r\n", trim: true)
@gb1
gb1 / day8.ex
Created November 5, 2019 20:49
Advent of Code 2018 Day 8
defmodule Day8 do
def part1 do
{tree, _} =
File.read!("./lib/input.txt")
# "2 3 0 3 10 11 12 1 1 0 1 99 2 1 1 2" example input
|> String.split()
|> Enum.map(&String.to_integer(&1))
|> create_tree
sum_metadata(tree) + Enum.sum(tree.metadata)