Skip to content

Instantly share code, notes, and snippets.

def get_phone_listeners(user)
stations = user.stations
return nil unless stations.present?
phone_listeners = NowSession.joins("LEFT JOIN data_gateway ON data_gateway.id=now_session.call_gateway_id").select("now_session.call_ani_e164").where("now_session.call_ani_e164 <> ''").where(call_gateway_id: stations.map(&:id))
end
def area_code_for_listener(listener)
listener[0].slice(0,3) if listener[0].to_s.length == 11 && listener[0].to_s.slice!(0) == "1"
end
import smtplib
import sys, argparse
import re
import base64
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
def banner():
print "#################################"
print "# PyPhisher #"
import smtplib
import sys, argparse
import re
import base64
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
def banner():
print "#################################"
print "# PyPhisher #"
import smtplib
import sys, argparse
import re
import base64
import os
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
def banner():
print "#################################"
@mekhami
mekhami / SassMeister-input.scss
Created May 12, 2015 16:59
Generated by SassMeister.com.
// ----
// libsass (v3.2.2)
// ----
.single-list {
article {
ol {
padding: 0;
li {
font-size: 10px;
@mekhami
mekhami / SassMeister-input.scss
Last active February 27, 2016 18:56
Generated by SassMeister.com.
// ----
// libsass (v3.2.2)
// ----
.single-list article ol {
padding: 0;
li {
font-size: 10px;
.credit {
color: black;
from classes import worker
from pages.frontend import ArticlePage
from classes import seleniumDriver
import time,datetime,unittest,sys
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from classes import PageActions as pgactions
from configobj import ConfigObj
from pages.backend import AddArticlePage as AP
@mekhami
mekhami / views.py
Last active February 27, 2016 18:56
def get_context_data(self, **kwargs):
context = super(ServiceDetail, self).get_context_data(**kwargs)
extra_fields = self.object.service_type.required_inputs()
form = ServiceForm(instance=self.object, extra_fields=extra_fields)
for field in extra_fields:
input_value = ServiceInput.objects.get(service=self.object, key=field).value
form.fields['custom_%s' % field].initial = input_value
context['form'] = form
class ProjectDisplay(LoginRequiredMixin, DetailView):
model = Project
context_object_name = 'project'
def get_context_data(self, **kwargs):
context = super(ProjectDisplay, self).get_context_data(**kwargs)
context['form'] = ServiceTypeForm()
return context
@mekhami
mekhami / tests.py
Last active February 27, 2016 18:56
class ProjectViewsTest(TestCase):
def setUp(self):
self.project = Project.objects.create(name='google')
self.request = RequestFactory().get('/fake-path/')
def test_project_display_context_data(self):
view = ProjectDisplay()
view = setup_view(view, self.request, slug=self.project.slug)
self.assertIn('form', view.get_context_data())