Skip to content

Instantly share code, notes, and snippets.

View rschildmeijer's full-sized avatar

Roger Schildmeijer rschildmeijer

View GitHub Profile
@rschildmeijer
rschildmeijer / spot_prices.py
Created August 19, 2022 11:38
spot_prices.py
#ex output: [0.02, 0.019, ..., 0.025]
# index = 0, 0.02 = hour 0-1
# index = 1, 0.019 = hour 1-2
# index = 23, 0.025 = hour 23-24
def todays_spot_prices():
return hass.states.get("sensor.nordpool_kwh_se4_sek_3_05_025").as_dict()['attributes']['today']
def get_active_hours(spots):
enumerated_hours = sorted(enumerate(spots), key=lambda entry: entry[1])[0:HOURS_TO_RUN]
@rschildmeijer
rschildmeijer / klang.html
Last active August 20, 2019 20:38
klang
<div id="film_wrapper">
<button id="play_btn">Play</button> <div class="large_still">
<img src="https://emilklang.com/wp-content/uploads/vbo4-1200x675.jpg">
</div>
<div class="video"><iframe id="player1" src="http://player.vimeo.com/video/299710204?autoplay=0&amp;title=0&amp;portrait=0&amp;byline=0&amp;color=e7e0e0" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>
</div>
@rschildmeijer
rschildmeijer / gist:0f98a4840b49ea13d317
Created September 22, 2015 19:56
machine learning
MATRIX / MATLAB
I = v < 0.05 # I contains 1 or 0 depending on logical criteria
v(I) = 0 # element vise assign 0 where I is 1 (True)
A .* B # element wise multiplication
1 . / v # element wise division (1 / element)
v + 1 # element wise
a < 3 # element wise comparision
log(v), exp(v), abs(v) # element wise
sum(a), prod(a), floor(a)
@rschildmeijer
rschildmeijer / gist:7b0a7fff899a6df15be3
Last active August 29, 2015 14:10
PSYoungGen gc log interpretation guideline
# formatted (extra line breaks and spaces) for readability
45.152: [GC
[PSYoungGen: |a|K -> |b|K (|c|K)]
|d|K -> |e|K (|f|K), 0.1083183 secs]
[Times: user=1.83 sys=0.01, real=0.11 secs]
Description:
PSYoungGen: Parallell Scavange Young Generation
a: Occupancy in young gen before minor gc
b: Occupancy in young gen after minor gc. Eden is empty => occupancy in survivor space (ie "survivor space occupancy")
@rschildmeijer
rschildmeijer / keybase.md
Created April 12, 2014 17:48
keybase.md

Keybase proof

I hereby claim:

  • I am rschildmeijer on github.
  • I am roger (https://keybase.io/roger) on keybase.
  • I have a public key whose fingerprint is E250 ECFE 116B 1105 EED9 EC2D C740 6558 A0B0 EED7

To claim this, I am signing this object:

@rschildmeijer
rschildmeijer / keybase.md
Created April 12, 2014 17:47
keybase.md

Keybase proof

I hereby claim:

  • I am schildmeijer on github.
  • I am roger (https://keybase.io/roger) on keybase.
  • I have a public key whose fingerprint is E250 ECFE 116B 1105 EED9 EC2D C740 6558 A0B0 EED7

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am schildmeijer on github.
  • I am roger (https://keybase.io/roger) on keybase.
  • I have a public key whose fingerprint is E250 ECFE 116B 1105 EED9 EC2D C740 6558 A0B0 EED7

To claim this, I am signing this object:

@rschildmeijer
rschildmeijer / Stream.java
Created December 5, 2012 22:13
Stream i/f from jdk8
/**
* A potentially infinite sequence of elements. A stream is a consumable data
* structure. The elements of the stream are available for consumption by either
* iteration or an operation. Once consumed the elements are no longer available
* from the stream.
*
* @param <T> Type of elements.
*
* @author Brian Goetz
*/
@rschildmeijer
rschildmeijer / gist:3813761
Created October 1, 2012 19:08
calculate the swedish capital insurance tax
curl -silent "https://www.riksgalden.se/sv/omriksgalden/statsskulden/aktuella-siffror/statslanerantan/"|grep -i -A2 "Medelv&#228;rde hittills i &#229;r"|tail -n1|awk 'BEGIN{FS="[<|>]"} {gsub(",", "."); printf("%f\n", $7*0.27)}'
@rschildmeijer
rschildmeijer / IntToByteArray.java
Created September 19, 2012 13:22
int -> byte[]
ByteBuffer.allocate(4).putInt(integer).array()