Skip to content

Instantly share code, notes, and snippets.

add_to_21([2, 32, 11, 1, 34, 18])
[]

add_to_21([1, 23, 19, 32, 1, 20, 7, 14])
[20, 1]
@numan
numan / webhook-request.sh
Last active September 24, 2018 20:03
Sample HRIS Webhook Request
curl --header "X-HRIS-AUTHENTICATION: 773603159c636db69c1e596c68a6368624305bcb" \
--header "Content-Type: application/json" \
-X POST \
-d '{"users": [{"phone_number": "+1 223-334-4355", "last_name": "Doe", "profile_image": {"url": "https://s3.amazonaws.com/publicassets.7geese.com/misc/765-default-avatar.png", "last_modified": 23323123123123, "cache_info": "sadsaDSds343GzzZ"}, "manager": {"hris_id": "E9923443"}, "active": true, "hris_id": "1FdzdQf35CffSd53", "first_name": "John", "employee_id": "E123556", "departments": ["Engineering > Mobile Team", "Customer Success > Support > Mobile Support", "Sales > Sales Engineer"], "email": "[email protected]", "job_title": "VP Engineering"}]}' \
https://app.7geese.com/hriswebhook/sync/e4a777a9021349fc9d061bd60fe1ec20/
@numan
numan / webhook-data-example.json
Last active September 24, 2018 20:01
HRIS Webhook Data Example
{
"users": [
{
"hris_id": "1FdzdQf35CffSd53",
"first_name": "John",
"last_name": "Doe",
"email": "[email protected]",
"job_title": "VP Engineering",
"phone_number": "+1 223-334-4355",
"employee_id": "E123556",
@numan
numan / schema.json
Last active September 24, 2018 19:59
HRIS Webhook Data Schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"users": {
"type": "array",
"items": {
"type": "object",
"properties": {
"hris_id": {
@numan
numan / resource.py
Last active May 17, 2016 21:00
Custom model resource for caching django-tastypie responses with django-cache-machine
from caching.invalidation import make_key
from functools import partial
def get_response_key(request):
smooshed = []
cache_keys = request.GET.keys()
cache_keys.sort()
for key in cache_keys:
@numan
numan / tastypie_caching.py
Created July 28, 2013 00:33
customized cached_with for django-cache-machine to use with django-tastypie
from caching.base import cached_with as official_cached_with
def cached_with(obj, f, f_key, timeout=None):
"""Helper for caching a function call within an object's flush list."""
if hasattr(obj, "exists") and not obj.exists():
return f()
return official_cached_with(obj, f, f_key, timeout=timeout)
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'root': {
'level': 'WARNING',
'handlers': ['sentry'],
},
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
@numan
numan / django-crossdomainxhr-middleware.py
Created May 2, 2012 18:32 — forked from vicalejuri/django-crossdomainxhr-middleware.py
Middlware to allow's your django server to respond appropriately to cross domain XHR (postMessage html5 API).
import re
from django.utils.text import compress_string
from django.utils.cache import patch_vary_headers
from django import http
try:
import settings
XS_SHARING_ALLOWED_ORIGINS = settings.XS_SHARING_ALLOWED_ORIGINS
@numan
numan / autoscaling_boto.py
Created July 17, 2011 00:42
Example of setting up AWS auto scaling using boto API
"""
The MIT License (MIT)
Copyright (c) 2011 Numan Sachwani
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
@numan
numan / lb_boto.py
Created July 16, 2011 21:29
Create a load balancer using the boto API
from boto.ec2.elb import ELBConnection
from boto.ec2.elb import HealthCheck
conn_elb = ELBConnection(AWS_ACCESS_KEY, AWS_SECRET_KEY)
#For a complete list of options see http://boto.cloudhackers.com/ref/ec2.html#module-boto.ec2.elb.healthcheck
hc = HealthCheck('healthCheck',
interval=20,
target='HTTP:80/index.html',