Skip to content

Instantly share code, notes, and snippets.

View aregee's full-sized avatar
🎯
“continuously refactoring towards deeper insight”

Rahul Gaur aregee

🎯
“continuously refactoring towards deeper insight”
View GitHub Profile
from django.http import HttpResponse
from tastypie import http
from tastypie.exceptions import ImmediateHttpResponse
from tastypie.resources import convert_post_to_put
class PublicEndpointResourceMixin(object):
""" Public endpoint dispatcher, for those routes upon which you don't want
to enforce the current resources authentication limits."""
class ProfileResource(ModelResource):
user = fields.ForeignKey(UserResource, 'user')
def prepend_urls(self):
urls = [
url(r'^(?P<resource_name>%s)/(?P<username>[\w\d_.-]+)/$' %\
self._meta.resource_name, self.wrap_view('user_by_username'),
name='profile_user_by_username')
]
return urls
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
AWS S3 Gzip compression utility
Author: Dmitriy Sukharev
Modified: 2013-09-11
-------
Synchronizes directory with gzipped content of Amazon S3 bucket with local
@aregee
aregee / json_pagination.sql
Last active March 15, 2023 12:23 — forked from fritzy/json_pagination.sql
Getting JSON paginated results of a table SELECT
SELECT json_build_object(
'total', (SELECT n_live_tup FROM pg_stat_user_tables WHERE relname='sometable'),
'count', count(sometable_rows.*),
'offset', 0,
'results', json_agg(row_to_json(sometable_rows))
)
FROM (SELECT * FROM test_log_clj)
ORDER BY "time"
LIMIT 10 OFFSET 0)
sometable_rows;
@aregee
aregee / nginx.conf
Created January 28, 2016 13:59 — forked from calebwoods/nginx.conf
Sample Nginx config for deployment of Angular.js app
server { listen 80;
server_name example.com;
access_log /var/log/example.com/nginx.access.log;
error_log /var/log/example.com/nginx.error.log;
root /var/www/apps/example.com/public;
charset utf-8;
location / {
rewrite ^ https://$host$request_uri? permanent;
}
@aregee
aregee / introrx.md
Created February 1, 2016 11:13 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@aregee
aregee / first.md
Created January 18, 2020 22:41 — forked from taxigy/first.md
Learning Clojure
layout title date categories crossposted
post
How I learned Clojure while solving easy coding challenges
2015-08-03
coding
logdown

I decided to learn Clojure (and therefore ClojureScript, since the two intersect significantly) by doing. Who'd ever blame me with that?

Scalr
http://highscalability.com/blog/2010/3/22/7-secrets-to-successfully-scaling-with-scalr-on-amazon-by-se.html
http://stackoverflow.com/questions/10061843/how-to-convert-linux-cron-jobs-to-the-amazon-way
Cron Jobs Are Hard To Distribute
Watch out when scaling out instances with cron jobs on them. Cron jobs aren't designed for the cloud. If the machine image holding your cron job scales out to 20 instances, your cron job will be executed 20 times more often.
This is fine if the scope of your cron job is limited to the instance itself, but if the scope is larger, the above becomes a serious problem. And if you single out a machine to run those cron jobs, you run the risk of not having it executed if that machine goes down.