Skip to content

Instantly share code, notes, and snippets.

💭
Busy in that 1% learning!

Nanda Kishore none-da

View GitHub Profile
View pom.xml
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>${protobuf-maven-plugin.version}</version>
<configuration>
<protocArtifact>
com.google.protobuf:protoc:3.3.0:exe:${os.detected.classifier}
</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>
View test.proto
syntax = "proto3";
option java_multiple_files = true;
option java_package = "io.grpc.java.testing_service";
option java_outer_classname = "TestingServiceProto";
option objc_class_prefix = "HLW";
package testing_service;
service Testing {
View HeaderClientInterceptor.java
package example.grpc.clients.testing_service;
import io.grpc.CallOptions;
import io.grpc.Channel;
import io.grpc.ClientCall;
import io.grpc.ClientInterceptor;
import io.grpc.ForwardingClientCall.SimpleForwardingClientCall;
import io.grpc.ForwardingClientCallListener.SimpleForwardingClientCallListener;
import io.grpc.Metadata;
import io.grpc.MethodDescriptor;
View TestServiceSampler.java
package example.grpc.clients.testing_service.jmeter;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
import org.apache.jmeter.samplers.SampleResult;
import example.grpc.clients.testing_service.TestingServiceClient;
import io.grpc.StatusRuntimeException;
View TestServiceClient.java
package example.grpc.clients.testing_service;
import java.util.concurrent.TimeUnit;
import io.grpc.ManagedChannel;
import io.grpc.Metadata;
import io.grpc.java.testing_service.TestingGrpc;
import io.grpc.java.testing_service.TestingGrpc.TestingBlockingStub;
import io.grpc.java.testing_service.TestingRequest;
import io.grpc.java.testing_service.TestingResponse;
View terminal.sh
PS1="[\u@\h \w]\\$ "
alias grep='grep -s --color'
alias ls='ls --color'
alias vi='vim'
export COLUMNS=150
cd <your_workspace_path>
View python_django_vimrc.sh
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
set incsearch nohlsearch
noremap <F4> :set hls!<CR>
View mymodels.py
from django.db import models
from utils.models import BaseModel
class ActiveQuestionManager(models.Manager):
def get_query_set(self):
return super(ActiveQuestionManager, self).get_query_set().filter(is_active=True)
class PublicQuestionManager(models.Manager):
def get_query_set(self):
return super(PublicQuestionManager, self).get_query_set().filter(visible=True)
View django_project_imports_checker.py
from django.core.management.base import BaseCommand
class Command(BaseCommand):
option_list = BaseCommand.option_list
help = "Scans through the given app for faulty imports, or the entire project directory if no apps are specified"
args = '[appname ...]'
requires_model_validation = False
def import_statement_extractor(self, directory_path, python_file):
python_file = '%s/%s' % (directory_path, python_file)
View login_as_anybody_in_django.py
def login_using_email(request, email):
'''DONT EVER USE this method for normal purposes. This is only there, for debugging specific problems related to users'''
from django.contrib.auth import get_backends
backend = get_backends()[0]
from django.contrib.auth.models import User
user = User.objects.get(email=email)
user.backend = "%s.%s" % (backend.__module__, backend.__class__.__name__)
from django.contrib.auth import login as django_login
django_login(request, user)
#set_any_extra_session_variables(request)
You can’t perform that action at this time.