Skip to content

Instantly share code, notes, and snippets.

View dotpot's full-sized avatar

Lukas Šalkauskas dotpot

  • Vilnius, Lithuania
View GitHub Profile
@dotpot
dotpot / README.md
Created July 12, 2018 07:23 — forked from rantav/README.md
Find slow queries in mongo DB

A few show tricks to find slow queries in mongodb

Enable profiling

First, you have to enable profiling

> db.setProfilingLevel(1)

Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...

Effective Engineer - Notes

What's an Effective Engineer?

  • They are the people who get things done. Effective Engineers produce results.

Adopt the Right Mindsets

Effective Engineer - Notes

What's an Effective Engineer?

  • They are the people who get things done. Effective Engineers produce results.

Adopt the Right Mindsets

@dotpot
dotpot / app.py
Created January 17, 2017 10:39 — forked from jmvrbanac/app.py
Using Jinja2 with Falcon
import os
import falcon
import jinja2
def load_template(name):
path = os.path.join('templates', name)
with open(os.path.abspath(path), 'r') as fp:
return jinja2.Template(fp.read())
@dotpot
dotpot / springer-free-maths-books.md
Created December 28, 2015 21:51 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of maths books available for free, here are the direct links
@dotpot
dotpot / temp.py
Last active August 29, 2015 14:23 — forked from Paulius-Maruska/temp.py
def space(s, n):
"""inserts a space every n characters in string s
>>> space('0123456789', 3)
'012 345 678 9'
>>> space('0123456789', 4)
'0123 4567 89'
"""
return ' '.join(s[i:i+n] for i in range(0, len(s), n))

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
import logging
from logging import config
ON_LOGGERS = True
config.dictConfig({
'version': 1,
'formatters': {
'fmt_root': {'format': '[ / ] - %(levelname)s - %(name)s - %(message)s'},
'fmt_pkg': {'format': '[ /pkg ] - %(levelname)s - %(name)s - %(message)s'},
'fmt_pkg_sub': {'format': '[ /pkg/sub ] - %(levelname)s - %(name)s - %(message)s'},

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results