Skip to content

Instantly share code, notes, and snippets.

View pnu's full-sized avatar
:octocat:

Panu Ervamaa pnu

:octocat:
View GitHub Profile
@pnu
pnu / curry.js
Last active December 31, 2019 12:26
const curry = (fn, ...args) =>
args.length >= fn.length
? fn(...args)
: (...x) => curry(fn, ...args, ...x);
const uncurry = (fn) => (...args) =>
args.reduce((fn, arg) => fn(arg), fn);
const mul = (a, b) => a * b;
const curriedMul = curry(mul);
@pnu
pnu / prediction.js
Created December 21, 2018 09:43
eg. cloud function for querying the tensorflow model running on cloud ml
import * as functions from 'firebase-functions';
import { google } from 'googleapis';
const ml = google.ml('v1');
export const predictMovie = functions.https.onRequest(async (request, response) => {
const instances = request.body.instances;
const model = request.body.model;
const { credential } = await google.auth.getApplicationDefault();
@pnu
pnu / cf-cognito.js
Created September 21, 2018 09:21
AWS Lambda@Edge function to trigger Cognito login and later validate the grant code after redirect. Just a test, not validated for production.
'use strict';
const url = require('url');
const https = require('https');
const client_id = '…';
const client_secret = '…';
const redirect_uri = '…';
const api_endpoint = '….auth.….amazoncognito.com';
const redirectResponse = {
@pnu
pnu / f-himmeli.ino
Last active November 21, 2017 11:19
#include <FastLED.h>
#include <stdlib.h>
CRGB leds[144*13];
#define OFFSET_33 0 * 144
#define OFFSET_22 1 * 144
#define OFFSET_11 2 * 144
#define OFFSET_A 3 * 144
#define OFFSET_1 4 * 144
#define OFFSET_2 5 * 144
✔ ~/devel/test-rakudo-buildpack [master|✔]
00:01 $ heroku addons:create heroku-postgresql
Creating postgresql-adjacent-61232... done, (free)
Adding postgresql-adjacent-61232 to sleepy-reef-21338... done
Setting HEROKU_POSTGRESQL_ONYX_URL and restarting sleepy-reef-21338... done, v14
Database has been created and is available
! This database is empty. If upgrading, you can transfer
! data from another database with pg:copy
Use `heroku addons:docs heroku-postgresql` to view documentation.
✔ ~/devel/test-rakudo-buildpack [master|✔]
@pnu
pnu / test.pl
Last active October 1, 2015 10:31
!/usr/bin/env perl
use strict;
use Imager;
my $red = Imager::Color->new(255, 0, 0, 255);
my $green = Imager::Color->new(0, 255, 0, 255);
my $blue = Imager::Color->new(0, 0, 255, 255);
my $transparent = Imager::Color->new(255, 255, 255, 0);
my $img = Imager->new(
@pnu
pnu / api.json
Last active August 29, 2015 13:58
ng simple template directive demo
{"head":"otsikko","para":["olipa","kerran"]}
@pnu
pnu / gist:9503985
Last active August 29, 2015 13:57
vendor perl for heroku-buildpack-perl
#!/usr/bin/env bash
git clone git://github.com/tokuhirom/Perl-Build.git perl-build
perl-build/perl-build $PERL_VERSION /app/vendor/perl
tar czf perl-$PERL_VERSION.tgz -C /app/vendor/perl .
git clone https://github.com/s3tools/s3cmd
cd s3cmd
git checkout v1.5.0-beta1
@pnu
pnu / gist:7213308
Created October 29, 2013 11:54
cpanfile
## Requirements from Makefile.PL (as defined in Makefile.PL)
##
requires 'Catalyst::Runtime', '5.90015';
requires 'Catalyst::Plugin::ConfigLoader';
requires 'Catalyst::Plugin::Static::Simple';
requires 'Catalyst::Action::RenderView';
requires 'Moose';
requires 'namespace::autoclean';
requires 'Config::General';