Skip to content

Instantly share code, notes, and snippets.

@johnschimmel
johnschimmel / jsonify_route.py
Created November 6, 2012 16:12
Sample Flask route to create JSON from Dictionary
from flask import jsonify
@app.route('/data/ideas')
def data_ideas():
# query for the ideas - return oldest first, limit 10
ideas = models.Idea.objects().order_by('+timestamp').limit(10)
if ideas:
@rupert-ong
rupert-ong / header.php
Created November 19, 2012 14:57
Wordpress: Page Indexing
<?php if ( (is_home() && (!$paged || $paged ==1)) || is_page() || is_single() || is_category()) :?>
<meta name="googlebot" content="index,archive,follow,noodp" />
<meta name="robots" content="all,index,follow" />
<meta name="msnbot" content="all,index,follow" />
<?php else : ?>
<meta name="googlebot" content="noindex,noarchive,follow,noodp" />
<meta name="robots" content="noindex,follow" />
<meta name="msnbot" content="noindex,follow" />
<?php endif; ?>
@ndarville
ndarville / business-models.md
Last active January 13, 2024 17:27
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
rand = (max =10, min = 0) ->
Math.floor(Math.random() * (max - min + 1)) + min
console.log rand()
console.log rand 100
console.log 50, 10
@denji
denji / nginx-tuning.md
Last active July 23, 2024 23:45
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@heyalexej
heyalexej / bootstrap.scss
Created February 2, 2014 10:24
Bootstrap Components
// Core variables and mixins
@import "variables";
@import "mixins";
// Reset
@import "normalize";
@import "print";
// Core CSS
@import "scaffolding";
#coding: utf-8
from __future__ import unicode_literals
from faker.providers import BaseProvider
class Provider(BaseProvider):
formats = [
"{{verb}} {{noun}}",
"{{verb}} for {{noun}}",
"{{verb}} and {{verb}} {{noun}} {{project_type}}",
"{{verb}} {{noun}} in {{location}}",
@Kartones
Kartones / postgres-cheatsheet.md
Last active July 25, 2024 09:09
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
<?php
function fix_file($source) {
$problems = array(
"/(<trkpt.*)\/>/",
"/<\/trkseg>\s*<trkseg>/"
);
$fixes = array(
"$1></trkpt>",