This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const widget = new ListWidget() | |
widget.backgroundColor = Color.black() | |
const amount = (number) => '$' + new Intl.NumberFormat().format(Math.round(number)) | |
const text = (text, fontSize) => { | |
const t = widget.addText(text) | |
t.font = new Font('Avenir-Heavy', fontSize) | |
t.textColor = Color.white() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CLOUDFLARE_API_KEY=changeme | |
CLOUDFLARE_DNS_RECORD=*.somewildcard.yourdomain.com | |
CLOUDFLARE_DNS_RECORD_ID= | |
CLOUDFLARE_ZONE=yourdomain.com | |
CLOUDFLARE_ZONE_ID= | |
if [[ "${CLOUDFLARE_ZONE_ID}" == "" ]]; then | |
CLOUDFLARE_ZONES=`curl -s "https://api.cloudflare.com/client/v4/zones" \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import OrderedDict | |
from myproject.api.views import APIRootView | |
from rest_framework import permissions, routers | |
from rest_framework_nested.routers import NestedSimpleRouter | |
class Router(routers.DefaultRouter): | |
include_root_view = True | |
include_format_suffixes = False | |
root_view_name = 'index' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat > openssl.cnf <<-EOF | |
[req] | |
distinguished_name = req_distinguished_name | |
x509_extensions = v3_req | |
prompt = no | |
[req_distinguished_name] | |
CN = *.${PWD##*/}.dev | |
[v3_req] | |
keyUsage = keyEncipherment, dataEncipherment | |
extendedKeyUsage = serverAuth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Zendesk timezones are represented by friendly names that map to tz database names. | |
For example, an API request returns "Eastern Time (US & Canada)" instead of "America/New_York". | |
You can map the friendly names to the tz database names by referencing the Constants > Mapping | |
section of the Ruby on Rails TimeZone object doc. | |
https://developer.zendesk.com/rest_api/docs/core/users#time-zone |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var geocoder = new google.maps.Geocoder(); | |
var trips = [ | |
{ action: 'trip', date_start: '2000-10-21', date_end: '2000-10-29', city: 'Fuerteventura', country: 'Spain' }, | |
{ action: 'trip', date_start: '2000-10-29', date_end: '2000-12-28', city: 'Nottingham', country: 'UK' }, | |
{ action: 'trip', date_start: '2000-12-28', date_end: '2001-01-04', city: 'Lagos', country: 'Portugal' }, | |
{ action: 'trip', date_start: '2001-01-04', date_end: '2001-04-08', city: 'Nottingham', country: 'UK' }, | |
{ action: 'trip', date_start: '2001-04-08', date_end: '2001-04-15', city: 'Paphos', country: 'Cyprus' }, | |
{ action: 'trip', date_start: '2001-04-15', date_end: '2001-08-27', city: 'Nottingham', country: 'UK' }, | |
{ action: 'trip', date_start: '2001-08-27', date_end: '2001-08-31', city: 'Nice', country: 'France' }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH RECURSIVE doc_key_and_value_recursive(key, value) AS ( | |
SELECT | |
t.key, | |
t.value | |
FROM ideas, json_each(ideas.custom) AS t | |
WHERE ideas.bucket_id = 889 | |
UNION ALL | |
SELECT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config valid only for Capistrano 3.1 | |
lock '3.1.0' | |
namespace :db do | |
desc "Push database" | |
task :push do | |
run_locally do | |
app_server = roles(:app).first | |
db_server = 'db.server.example.com' | |
user = 'simpleweb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var KeyHook = { | |
init: function(e) { | |
if (e.keyCode == 13) { | |
if (!e.target || !e.target.form) return; | |
var button; | |
if (this.isSubmitButton(e.target)) { | |
button = e.target; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from django.db.models import signals | |
from django.utils.functional import curry | |
from rest_framework import authentication | |
class UserstampMiddleware(object): | |
"""Add user created_by and updated_by foreign key refs to any model automatically. | |
Almost entirely taken from https://github.com/Atomidata/django-audit-log/blob/master/audit_log/middleware.py""" | |
def process_request(self, request): |
NewerOlder