Skip to content

Instantly share code, notes, and snippets.

View villelahdenvuo's full-sized avatar
🏠
Working from home

Ville Lahdenvuo villelahdenvuo

🏠
Working from home
View GitHub Profile
@villelahdenvuo
villelahdenvuo / icon.component.scss
Created June 29, 2022 11:19
g-icon alternative to fa-icon
:host {
display: inline-block;
}
svg {
height: 1em;
vertical-align: -0.125em;
}
:host[size='lg'] svg {
@villelahdenvuo
villelahdenvuo / browsersync-scroll-plugin.js
Created September 16, 2016 11:59
BrowserSync restore scroll position
/* eslint-disable */
// Inspired by https://github.com/BrowserSync/browser-sync/issues/273#issuecomment-57427711
(function ($window, $document, bs) {
var socket = bs.socket;
var selector = '[md-scroll-y]';
var PRE = "<<BS_START>>";
var SUF = "<<BS_END>>";
var regex = new RegExp(PRE + "(.+?)" + SUF);
var saved = {};
@villelahdenvuo
villelahdenvuo / jsonb_set_deep.sql
Created June 14, 2016 12:24
PostgreSQL jsonb_set is nice, but it does't create missing objects so I made this little helper.
CREATE OR REPLACE FUNCTION jsonb_set_deep(target jsonb, path text[], val jsonb)
RETURNS jsonb AS $$
DECLARE
k text;
p text[];
BEGIN
-- Create missing objects in the path.
FOREACH k IN ARRAY path LOOP
p := p || k;
IF (target #> p IS NULL) THEN
@villelahdenvuo
villelahdenvuo / controller.ts
Created January 12, 2016 18:15
Koa & TypeScript Example
'use strict';
import Test from './model';
import route from '../../lib/decorator-router';
class TestController {
/**
* List models
*/
@villelahdenvuo
villelahdenvuo / crontab
Last active December 18, 2015 12:39
Crontab contents for Kapsi Irssi restart on reboot
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
SHELL=/bin/bash
LC_CTYPE=en_US.UTF-8
@reboot sleep 256 && screen -dmS irc irssi
@villelahdenvuo
villelahdenvuo / urly.js
Created February 2, 2012 07:57
Urly API for Node.js
var http = require('http');
function urly(url, cb) {
// Options for API call
var options = {
host: 'urly.fi',
port: 80,
path: '/api/shorten/?url=' + url}
, code = '';
// Named functions
///////////// Changelog \\\\\\\\\\\\\
Legend: * = Info-ed (you)
+ = Added
- = Removed
! = Fixed
~ = Changed
# = Todo-ed
--==" 1.0 "==--
* First real release (TM)