Skip to content

Instantly share code, notes, and snippets.

View zrrrzzt's full-sized avatar

Geir Gåsodden zrrrzzt

View GitHub Profile
Slik lager du linker for å laste ned
http://data.brreg.no/enhetsregisteret/enhet.{filformat}?$filter=startswith(naeringskode1/kode, '{næringskode}')+and+registreringsdatoEnhetsregisteret+gt+datetime'{yyyy-MM-DD}T00:00'
Så om du vil ha ned alle som sysler med produksjon av øl og er registrert etter 1. august 2015 i en .csv-fil blir
filformat = csv
næringskode = 11.050
yyyy-MM-DD = 2015-08-01
@zrrrzzt
zrrrzzt / brreg.import.google.apps.script.gs
Last active March 21, 2016 19:53
Import data from brreg to a google spreadsheet by entering næringskode and registrationdate
/**
*
* Import data from brreg
* @customfunction
**/
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('BRREG')
.addItem('Import from brreg', 'importSetup')
@zrrrzzt
zrrrzzt / sitemap-to-objects.js
Created December 18, 2015 22:30
Quick and dirty node.js module for parsing a sitemap.xml to objects via a streaming interface
var saxStream = require('sax').createStream(true, {trim: true})
var hh = require('http-https')
var streamify = require('streamify')
var stream = streamify()
var url = 'https://raw.githubusercontent.com/zrrrzzt/sitemap-to-array/master/test/data/sitemap.xml'
var list = []
function objectFromArray (arr) {
var obj = {}
@zrrrzzt
zrrrzzt / get-mandater.js
Last active September 12, 2017 04:22
Get mandates for the Norwegian election
'use strict'
const axios = require('axios')
const api = 'https://valgresultat.no/api/2017/st'
const REDS = ['MDG', 'RØDT', 'A', 'SV', 'SP']
module.exports = () => {
return new Promise(async (resolve, reject) => {
try {
const response = await axios.get(api)
@zrrrzzt
zrrrzzt / valglys.js
Created September 11, 2017 19:44
Resten av valglys-koden
'use strict'
const setColor = require('./changecolor')
const getMandater = require('./get-mandater')
const switchColor = async color => {
try {
const result = await setColor(color)
console.log(result)
} catch (error) {
@zrrrzzt
zrrrzzt / gun.restrict.put.server.js
Last active November 24, 2022 16:41
Example code for restricting put on GUN
/* You'll need this on your client
Gun.on('opt', function (ctx) {
if (ctx.once) {
return
}
ctx.on('out', function (msg) {
var to = this.to
// Adds headers for put
msg.headers = {
token: 'thisIsTheTokenForReals'
[
{
"zone": "Stor-Oslo",
"municipality": "Oslo",
"area": "Oslo",
"stations": [
{
"zone": "Stor-Oslo",
"municipality": "Oslo",
"area": "Oslo",
const data = require('./data.json')
function returnHighestColor (list) {
let color = 'ffffff'
if (list.includes('990099')) {
color = '990099'
} else if (list.includes('ff0000')) {
color = 'ff0000'
} else if (list.includes('ff9900')) {
color = 'ff9900'
@zrrrzzt
zrrrzzt / site-validator.js
Created February 12, 2019 12:26
Crawl a site and validate all pages
(async () => {
const siteMap = require('sitemap-crawler')
const validate = require('html-validator')
const url = 'http://www.npmjs.com'
function generateSitemap (url) {
return new Promise(async (resolve, reject) => {
siteMap(url, (error, result) => {
if (error) {
return reject(error)