Skip to content

Instantly share code, notes, and snippets.

View saevarom's full-sized avatar

Sævar Öfjörð Magnússon saevarom

View GitHub Profile
@saevarom
saevarom / README.md
Last active October 14, 2022 12:53
Elasticsearch config for Icelandic in Wagtail
  1. pip install requests-aws4auth
  2. Add AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, ELASTICSEARCH_INDEX_NAME and ELASTICSEARCH_HOST variables to your environment
  3. Import the variables to your settings file
  4. Add the WAGTAILSEARCH_BACKENDS configuration to your settings file
@saevarom
saevarom / adzone.js
Last active March 3, 2021 09:55
React adzone
import React from 'react';
class Ad extends React.Component {
/*
Usage in React JSX:
<Ad zoneId={'your zone id from Airserve'} />
*/
@saevarom
saevarom / fabfile.py
Created January 23, 2018 14:36
Fabfile template for Overcast Software
from __future__ import with_statement
from fabric.api import *
from fabric.operations import get
from fabric.contrib.files import exists
from contextlib import contextmanager
import os
env.roledefs = {
'web': ['server1.example.com', 'server2.example.com'],
@saevarom
saevarom / .block
Last active May 2, 2019 10:52 — forked from mbostock/.block
Exercise calendar
license: gpl-3.0
height: 435
border: no
@saevarom
saevarom / django_template_escape.sh
Created January 20, 2016 10:20
django template escaping and un-escaping for project template templates
#!/bin/sh
# Convert a regular django template to a project-template template
# Usage: ./django_template_escape.sh filename
# The file is edited in-place.
sed -i '' "s/{%/openblock/g" "$1"
sed -i '' "s/%}/closeblock/g" "$1"
sed -i '' "s/openblock/{% templatetag openblock %}/g" "$1"
sed -i '' "s/closeblock/{% templatetag closeblock %}/g" "$1"
@saevarom
saevarom / jsmodel.sublime-snippet
Created November 26, 2015 13:27
Sublime snippets
<snippet>
<content><![CDATA[var $1 = (function() {
// $1 model
var self = null;
// ------------------------------------------------------------
// constructor
@saevarom
saevarom / Constructor.js
Last active October 7, 2015 14:13 — forked from Integralist/Constructor.js
Private and Privileged methods using the Constructor pattern in JavaScript
function Constructor(){
this.foo = 'foo';
// Needed for Private methods
var self = this;
// Private methods need to be placed inside the Constructor.
// Doesn't perform as well as prototype methods (as not shared across instances)
function private(){
console.log('I am private');

Install necessary packages

Update aptitude

$ apt-get update
$ apt-get upgrade

Install necessary packages

@saevarom
saevarom / README.md
Last active August 29, 2015 14:14
Simple Javascript template rendering using Mustache

Define templates using keys:

Template.register("event-detail",
    '<div class="event-detail">' +
    '  <h2>{{ title }}</h2>' +
    '  <p>{{ description }}</p>' +
    '</div>';
);

Call templates in code:

-- Index hit rate
WITH idx_hit_rate as (
SELECT
relname as table_name,
n_live_tup,
round(100.0 * idx_scan / (seq_scan + idx_scan),2) as idx_hit_rate
FROM pg_stat_user_tables
ORDER BY n_live_tup DESC
),