Skip to content

Instantly share code, notes, and snippets.

@vkurup
vkurup / config.yml
Last active January 29, 2024 16:06
Config file for mac-dev-playbook
---
# Config file to override default-config.yml from git@github.com:geerlingguy/mac-dev-playbook.git
configure_dotfiles: false
configure_terminal: false
configure_osx: false
homebrew_installed_packages:
- aspell
- autoconf
- awscli
@vkurup
vkurup / success.json
Created October 14, 2017 01:35
Successful run
TASK [tequila-django : upload github key] ******************************************************************************************************************************************************************
task path: /home/vkurup/dev/epicallieshq/deployment/roles/tequila-django/tasks/main.yml:74
changed: [staging] => {
"changed": true,
"checksum": "838396e7a90480edfd99021278843b6b2ee9d0cf",
"dest": "/home/epicallieshq/.ssh/github",
"diff": [],
"failed": false,
"gid": 1014,
"group": "epicallieshq",
@vkurup
vkurup / failure.json
Last active October 14, 2017 01:36
Failed run
TASK [tequila-django : upload github key] ******************************************************************************************************************************************************************
task path: /home/vkurup/dev/epicallieshq/deployment/roles/tequila-django/tasks/main.yml:74
ok: [staging] => {
"changed": false,
"checksum": "838396e7a90480edfd99021278843b6b2ee9d0cf",
"diff": {
"after": {
"path": "/home/epicallieshq/.ssh/github"
},
"before": {
@vkurup
vkurup / get_speed.py
Created February 2, 2017 02:40
Showing how to get arbitrary nodes in XML
(tcx)vinod@cartman:~/dev/python-tcxparser(master) $ python
Python 2.7.10 (default, Oct 14 2015, 16:09:02)
[GCC 5.2.1 20151010] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tcxparser
>>> tcx = tcxparser.TCXParser('test.tcx')
>>> tcx.root
<Element {http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2}TrainingCenterDatabase at 0x7f97eb2689e0>
>>> namespace = 'http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2'
>>> tcx.root.findall('.//ns:Extensions', namespaces={'ns': namespace})
import urllib
import boto3
import requests
print('Loading function')
s3 = boto3.client('s3')
# someday i will need to learn how to use AWS
s3_resource = boto3.resource('s3')
@vkurup
vkurup / generate_factories.py
Last active April 16, 2021 20:03 — forked from tobiasmcnulty/generate_factories.py
Django management command to generate factory-boy boilerplate factory definitions for all the models in a given app. The code is not intended to be usable right off the bat, it just provides a few sane defaults based on the structure of your models.
from django.core.management.base import BaseCommand
from django.db.models import get_models, get_app, fields
from django.db.models.fields import related
class Command(BaseCommand):
help = """Generate factory-boy factories for the given app"""
def handle(self, *args, **options):
assert len(args) == 1, 'Must specify app name as first and only argument'

Keybase proof

I hereby claim:

  • I am vkurup on github.
  • I am vkurup (https://keybase.io/vkurup) on keybase.
  • I have a public key whose fingerprint is 01AC F6AB EA98 0D16 5777 C37D DA8E 3DB4 6683 2BC1

To claim this, I am signing this object:

@vkurup
vkurup / gist:491f95a7c08819009275
Created July 23, 2014 13:47
Possible race condition
@transaction.atomic
def get_pending_messages():
"""Return a list of messages to be sent out and mark them as 'sent' in the db."""
msg_qs = SMSSyncMessage.objects.select_for_update().filter(backend_name=self.name,
date_sent=None)
messages = [dict(message=m.text, to=m.identity)
for m in msg_qs]
if msg_qs:
msg_qs.update(date_sent=now())
@vkurup
vkurup / gist:b23cb6c563727d4ed720
Created May 21, 2014 20:32
clojurescript install
vinod@cartman:~/dev/vkcljs $ git clone git://github.com/clojure/clojurescript.git
Cloning into 'clojurescript'...
remote: Reusing existing pack: 15002, done.
remote: Counting objects: 42, done.
remote: Compressing objects: 100% (38/38), done.
remote: Total 15044 (delta 13), reused 2 (delta 0)
Receiving objects: 100% (15044/15044), 3.56 MiB | 1.49 MiB/s, done.
Resolving deltas: 100% (6516/6516), done.
Checking connectivity... done.
vinod@cartman:~/dev/vkcljs $ cd clojurescript/
@vkurup
vkurup / gist:00c660135278f307e5d4
Created May 7, 2014 15:27
show git branch on command line
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
PS1="\u@\h:\w\$(parse_git_branch) $ "