Skip to content

Instantly share code, notes, and snippets.

@lauris
lauris / mongodb-monthly.js
Created May 14, 2020 09:40
MongoDB aggregate entries by month
db.getCollection('users').aggregate(
[
{
$group:
{
_id:
{
month: { $month: "$created" },
year: { $year: "$created" }
},
@lauris
lauris / municipalities.json
Created July 13, 2018 08:49
List of municipalities in Latvia
[
{
"title":"Aglonas novada pašvaldība",
"url":"http://www.aglona.lv"
},
{
"title":"Aizkraukles novada pašvaldība",
"url":"http://www.aizkraukle.lv"
},
{
package models
import play.api.db.slick.Config.driver.simple._
import java.sql.Timestamp
case class ChartCase(id: Option[Long], title: String, query: String, settings: String, db: String, user: Long,
conn: Long, created: Timestamp, team_shared: Boolean = false, public: Boolean = false)
class Chart(tag: Tag) extends Table[ChartCase](tag, "charts") {
def id = column[Long]("id", O.PrimaryKey, O.AutoInc)
package schema
import scalikejdbc.{DBSession, WrappedResultSet, SQL}
import scala.collection.immutable.ListMap
case class FK(name: String, columns: String, referenced_table: String, referenced_columns: String, on_delete: String, on_update: String)
abstract class BaseTable(private val _db: String, private val _table: String)(implicit session: DBSession) {
def createColumn(meta: Map[String, Option[String]]): Int

Keybase proof

I hereby claim:

  • I am lauris on github.
  • I am lauris (https://keybase.io/lauris) on keybase.
  • I have a public key whose fingerprint is AC04 5C5C CBDC ACD2 CE46 8BEB 2E4D 4B0D 613E 83CF

To claim this, I am signing this object:

var data = [
{name: "John", age: 28},
{name: "Jane", age: 25}
];
function orderByKey(data, key) {
var comparator = function (a,b) {
return parseInt(a[key]) - parseInt(b[key]);
};
return data.sort(comparator);
#!/bin/bash
# Datazenit Auto-start
#
# Change /path/to/datazenit/ to the correct path where
# Datazenit is installed
case $1 in
start)
nohup /path/to/datazenit-1.0.0/bin/datazenit > /var/log/datazenit.log &
;;
class OG(string:String){
def unary*~~||~~* = println("it's loc, baby")
def *~~||~~* = println("no joke")
}
val og = new OG
*~~||~~*og*~~||~~*
@lauris
lauris / markov.py
Last active February 6, 2018 15:21
Markov Chains
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import random
import string
import re
from collections import Counter
@lauris
lauris / octopress
Created August 16, 2014 21:38
Octopress default directory tree.
├── CHANGELOG.markdown
├── Gemfile
├── Gemfile.lock
├── README.markdown
├── Rakefile
├── _config.yml
├── config.rb
├── config.ru
├── plugins
│   ├── backtick_code_block.rb