Skip to content

Instantly share code, notes, and snippets.

@devsnd
devsnd / dnd_ordered_admin.py
Last active October 4, 2023 15:27
Quick hack to implement drag and drop for ordered model django admin
class DragndropOrderedModelAdmin(OrderedModelAdmin):
def move_above_view(self, request, object_id, other_object_id):
obj = get_object_or_404(self.model, pk=unquote(object_id))
other_obj = get_object_or_404(self.model, pk=unquote(other_object_id))
obj.above(other_obj)
# go back 3 levels (to get from /pk/move-above/other-pk back to the changelist)
return HttpResponseRedirect('../../../')
def get_urls(self):
def wrap(view):
@iloveitaly
iloveitaly / stripe_usage_based_billing_with_subscriptions.rb
Created October 24, 2017 00:37
Example of using Stripe Subscriptions to handle usage based billing for recurring payments
# Mike Bianco <[email protected]>
# Description: Example of using Stripe's subscription billing to add usage based billing
# information to the customer's recurring invoice
require 'stripe'
require 'sinatra'
Stripe.api_key = ENV['STRIPE_KEY']
# This example uses sinatra to listen for webhooks. You can easily use rails, or any other framework/language.
@grimzy
grimzy / git-pull-all
Created September 15, 2017 02:15
Git pull all remote branches
#!/usr/bin/env bash
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
@lestephane
lestephane / Dockerfile
Created September 10, 2017 19:35
Dockerized terraform bundler
FROM golang:alpine
RUN apk update && apk upgrade && \
apk add --no-cache git zip
ARG TERRAFORM_VERSION
RUN git clone --single-branch --branch v${TERRAFORM_VERSION} https://github.com/hashicorp/terraform.git /go/src/github.com/hashicorp/terraform
RUN cd $GOPATH/src/github.com/hashicorp/terraform && echo $GOPATH && go install ./tools/terraform-bundle
@shatil
shatil / make.py
Created June 25, 2017 07:07
Generate docker-compose.yml `services` entries dynamically with Python
#!/usr/bin/env python3
from __future__ import print_function
try:
from ruamel import yaml
except ImportError:
import yaml
# Map a Docker Compose "service" name to its image.
@mkokho
mkokho / Dockerfile
Created May 22, 2017 01:59
Ultrahook in a docker container
FROM ruby:2.4-alpine
RUN gem install ultrahook
ENTRYPOINT ["ultrahook"]
@sohelrana820
sohelrana820 / catch-php-output-buffering-data-jquery-ajax.php
Last active May 12, 2024 00:31
Get Streaming Data Over Jquery Ajax
<?php
/**
* Catch php output buffering data over jQuery AJAX
*
* @author: Sohel Rana ([email protected])
* @author url: https://blog.sohelrana.me
* @link: https://blog.sohelrana.me/catch-php-output-buffering-data-jquery-ajax/
* @licence MIT
*/
@kyleferguson
kyleferguson / Dockerfile
Last active December 19, 2023 06:10
Example Laravel deployment for Kubernetes
FROM php:7.1-apache
ADD . /var/www
ADD ./site.conf /etc/apache2/sites-enabled/000-default.conf
RUN apt-get update && apt-get install -y libmcrypt-dev mysql-client && \
docker-php-ext-install mcrypt pdo_mysql opcache && \
pecl install redis-3.1.2 && docker-php-ext-enable redis && \
a2enmod rewrite
@napcs
napcs / flags.elm
Created April 8, 2017 15:16
Elm with Flags
module Main exposing (..)
import Html exposing (Html, div, p, text)
-- Data type for the flags
type alias Flags =
{ user : String
, token : String
}
name: Modal Form Example
type: module
description: 'Modal Form Example module'
package: Example
version: VERSION
core: 8.x