Skip to content

Instantly share code, notes, and snippets.

View Caffe1neAdd1ct's full-sized avatar
💻
Working on multiple projects

Kevin Andrews Caffe1neAdd1ct

💻
Working on multiple projects
View GitHub Profile
@nick-merrill
nick-merrill / merge_model_objects.py
Created December 5, 2014 01:07
A variation on a snippet that handles one-to-one relationships by recursively migrating those relationships' field data to the `primary_object`'s related object.
# Based on https://djangosnippets.org/snippets/2283/
from django.db import transaction
from django.db.models import get_models, Model
from django.contrib.contenttypes.generic import GenericForeignKey
@transaction.atomic
def merge_model_objects(primary_object, alias_objects=None, keep_old=False):
"""
Use this function to merge model objects (i.e. Users, Organizations, Polls,
@aaronsilber
aaronsilber / scrapyd
Last active February 25, 2020 14:48
CentOS Scrapyd web crawler init script (w/ chkconfig support)
#!/bin/bash
#
# scrapyd This shell script enables scrapyd server on boot
#
# Author: Aaron Silber <aaron@brandthropology.com>
#
# chkconfig: - 50 01
#
# description: Autostart scrapyd web scraper framework daemon
# processname: scrapyd
@edelvalle
edelvalle / merge.py
Last active April 9, 2020 08:08
Merging model instances in Django 1.9
from django.db import transaction
from django.apps import apps
from django.contrib.contenttypes.fields import GenericForeignKey
from django.db.models.fields.related import ManyToManyField
@transaction.atomic()
def merge(primary_object, *alias_objects):
"""Merge several model instances into one, the `primary_object`.
Use this function to merge model objects and migrate all of the related
@RobThree
RobThree / SoapClientEx.class.php
Created November 20, 2012 13:23
PHP SoapClient with timeout and authentication
<?php
//**NOTE**: This has *NOT* been tested yet; please provide feedback in the comments
//Drop-in replacement for PHP's SoapClient class supporting connect and response/transfer timeout and authentication
//Usage: Exactly as PHP's SoapClient class, except that some new options are available:
// timeout The response/transfer timeout in milliseconds; 0 == default SoapClient / CURL timeout
// connecttimeout The connection timeout; 0 == default SoapClient / CURL timeout
// sslverifypeer FALSE to stop SoapClient from verifying the peer's certificate
// sslversion The SSL version (2 or 3) to use. By default PHP will try to determine this itself, although in some cases this must be set manually
// sslverifyhost 1 to check the existence of a common name in the SSL peer certificate. 2 to check the existence of a common name and also verify that
@anisur3036
anisur3036 / .bablerc
Last active December 20, 2020 11:15
Tailwindcss with Gulp
{
"presets": ["env"]
}
@warlord0
warlord0 / template.sh
Last active October 21, 2021 09:01
Bash Script Template
#!/bin/bash
EXAMPLE="example default"
# Plugin variable description
PROGNAME=$(basename $0)
RELEASE="Revision 1.0.0"
AUTHOR="(c) 2020 Warlord0"
# Functions plugin usage
@paolorossi
paolorossi / async-task-queue.js
Last active December 17, 2021 04:36
Javascript Queue for sequencing AJAX requests and other asynchronous tasks. Demo http://jsfiddle.net/rusci/26Dud/6/
// Queue class for serializing AJAX calls.
//
// Inspired by Raynos http://stackoverflow.com/a/4797596/1194060
//
// Queue has a public append method that expects some kind of task.
// A task is a generic function passed as callback.
// Constructor expects a handler which is a method that takes a ajax task
// and a callback. Queue expects the handler to deal with the ajax and run
// the callback when it's finished
@larsvegas
larsvegas / xdebug.php.ini
Created September 19, 2012 15:25
xdebug php.ini default config
xdebug.auto_trace=1
;;Type: boolean, Default value: 0
;;When this setting is set to on, the tracing of function calls will be enabled just before the script is run. This makes it possible to trace code in the auto_prepend_file.
xdebug.cli_color=1
;;Type: integer, Default value: 0, Introduced in Xdebug 2.2
;;If this setting is 1, Xdebug will color var_dumps and stack traces output when in CLI mode and when the output is a tty. On Windows, the ANSICON tool needs to be installed.
;;If the setting is 2, then Xdebug will always color var_dumps and stack trace, no matter whether it's connected to a tty or whether ANSICON is installed. In this case, you might end up seeing escape codes.
;xdebug.collect_assignments=0
@chrispian
chrispian / woocommerce-filter-related-categories-by-taxonmy-term.php
Last active February 26, 2022 16:01
Only shows related products from the primary category set by Yoast
@normykinz
normykinz / laravel_make_typed_collection_command
Last active March 7, 2023 14:52
Lavel Typed Collection Make Command
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
class CollectionCommand extends Command
{
protected $signature = 'make:collection {model}';