Skip to content

Instantly share code, notes, and snippets.

View Nearhan's full-sized avatar

Farhan Syed Nearhan

View GitHub Profile
@Nearhan
Nearhan / Drop & Cascade Tables
Last active December 11, 2015 16:19
Drops and Cascades all tables in Django
python manage.py sqlclear myapp auth sites sessions contenttypes | sed 's/";/" CASCADE;/' | python manage.py dbshell
@Nearhan
Nearhan / gist:5446779
Last active December 16, 2015 14:09
Combing Two Mixins
class CityAndStateInputMixin(object):
def __init__(self, *args, **kwargs):
super(CityAndStateInputMixin, self).__init__(*args, **kwargs)
#add custom error_class
self.error_class = CustomListError
#adding State Selct Widget and dynamic css edits
self.fields['state'] = forms.ChoiceField(choices=US_STATES,
widget=StateSelectWidget)
@Nearhan
Nearhan / ES
Created January 6, 2015 13:46
ES
body = {
"aggs" : {
"hashtags" : {
"terms" : {
"field" : "hashtags",
"size": 0
}
}
}
}
# you can override this using by setting a system property, for example -Des.logger.level=DEBUG
es.logger.level: INFO
rootLogger: ${es.logger.level}, console, file
logger:
# log action execution errors for easier debugging
action: DEBUG
# reduce the logging for aws, too much is logged under the default INFO
com.amazonaws: WARN
# gateway
@Nearhan
Nearhan / gist:978182b5238a5262e17b
Created April 3, 2015 19:38
Add Tags To Feed Items
  • How to add Tags from the Command Line

    • maven run python trackmaven/manage.py create_test_tags --ws= 1 --tags=77 --num=1000
    • this will add tweet objects to the es_index

Keybase proof

I hereby claim:

  • I am nearhan on github.
  • I am nearhan (https://keybase.io/nearhan) on keybase.
  • I have a public key whose fingerprint is E0C0 DBED DE06 6619 DE1A 9046 AFBB 0235 3BF3 88AB

To claim this, I am signing this object:

<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Say>I will pause 10 seconds starting now!</Say>
<Pause length="10"/>
<Say>I just paused 10 seconds</Say>
</Response>
@Nearhan
Nearhan / test stats d
Created March 1, 2016 18:38
test stats d
from datadog import statsd
statsd.increment('test.test.test')
statsd.event('This is a test Event', 'This is a a Test Event')
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"sync"
)

ProtoFile

syntax = "proto3";
package server;

message Payload {
    string name = 1;
    string id = 2;