Skip to content

Instantly share code, notes, and snippets.

View fredrike's full-sized avatar

Fredrik Erlandsson fredrike

View GitHub Profile
@fredrike
fredrike / _readme.md
Last active March 19, 2018 13:22
Scratchpad for editing influxdb series.

Initial config :)

influxdb="influxdb"
db="homeassistant"

Show measurement tags:

@fredrike
fredrike / _readme.md
Last active June 26, 2018 11:20
Let's encrypt for Apache vhost running on FreeBSD.

The following is a quick scratch down of how I have configured Let's encrypt on one of the FreeBSD jails I'm hosting (running Apache24).

All of the commands below have been run as root.

  1. Start with installing https://github.com/Neilpang/acme.sh using the command
curl https://get.acme.sh | sh

1.1 Set HOST to your current hostname

# Automation section
automation:
- alias: "heater ak minus 10"
initial_state: True
trigger:
- platform: time
minutes: '/5'
seconds: 2
condition:
condition: and
@fredrike
fredrike / gist:0f6862737e27c69d3fa61fe1d5f8c59d
Created March 31, 2017 15:08
graph_tool bugg, can't use vertex_average on an empty graph.
...........................................................................
/home/fer/miniconda3/lib/python3.5/site-packages/graph_tool/stats/__init__.py in vertex_average(g=<GraphView object, undirected, with 0 vertices a...Graph 0x7f5f5a9be400, at 0x7f5f5a9bef28>, False)>, deg='total')
241 try:
242 a = array(a.a)
243 aa = array(aa.a)
244 except AttributeError:
245 pass
--> 246 a /= count
a = 0.0
count = 0
@fredrike
fredrike / VoteRank.ipynb
Last active April 20, 2023 01:19
voteRank.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/sh
$TARGET = $1
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
cd /var/packages
for F in *; do sudo ${F}/scripts/start-stop-status stop; done
% BibTeX `apalike-refs' bibliography style which displays different IDs like DOI, ISBN, ISSN, but also the URL.
% It uses \href and \url, so be sure to use the package hyperref for it to work.
% It is based on the `apalike-doi' of Jan Even Øie Nilsen:
% http://web.nersc.no/~even/tex/apalike-doi.bst
%
% MODIFICATIONS:
% - Add ISBN, ISSN, and URL functions (format.xxx)
% - Centralise all the IDs functions into format.refs
% - Call format.refs in all types (book, article, etc.)
% - Make a URL for DOI based on dx.doi.org
#include <application.h>
#include "SunRiseLamp.h"
#include "neopixel/neopixel.h"
SunRiseLamp::SunRiseLamp(int totalTime, int pixelCount, int pixelPin, int pixelType) {
colorInterval = (totalTime * 1000) / 1500;
sunRiseTemp = 0;
brightness = 0;
neoPixelPtr = new Adafruit_NeoPixel(pixelCount, pixelPin, pixelType);
neoPixelPtr->begin();
<?php
$id = "889307941125736_999866820069847";
$file= "889307941125736_2015-10-16T23_889307941125736_999866820069847#1466641440.779.json";
$file= $argv[1];
preg_match("/.*_(.*_.*)#.*/", $file, $output_array);
$id = trim($output_array[1]);
$out = array();
$out[$id] = ['id'=> $id, 'status'=> 'done','exec_time' => 0, 'type'=> 'post'];
@fredrike
fredrike / Turn off leds on ASUS AC68u.sh
Created March 8, 2016 20:27
Commands to turn off all leds on an ASUS ac68 running the tomato firmware.
/sbin/gpio enable 4 #white led at the back
/sbin/gpio enable 3 #power led
/usr/sbin/wl -i eth2 leddc 1 #5Ghz
/usr/sbin/wl -i eth1 leddc 1 #2.4Ghz
/usr/sbin/et robowr 0x00 0x1a 0x1e0; /usr/sbin/et robowr 0x00 0x18 0x1e0 #ethernet off