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 extractAddressFromURL(url) { | |
// Find the start of the parameters after '?' | |
var queryStart = url.indexOf('?') + 1; | |
// Extract the substring from the start of the parameters to the end of the URL | |
var queryParams = url.substring(queryStart); | |
// Split the query parameters into an array of key-value pairs | |
var pairs = queryParams.split('&'); | |
for (var i = 0; i < pairs.length; i++) { | |
var pair = pairs[i].split('='); | |
if (pair[0] === 'q' && pair[1]) { |
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
// The MIT License (MIT) - https://gist.github.com/bcatcho/1926794b7fd6491159e7 | |
// Copyright (c) 2015 Brandon Catcho | |
using System; | |
// Place this file in any folder that is or is a descendant of a folder named "Scripts" | |
namespace CatchCo | |
{ | |
// Restrict to methods only | |
[AttributeUsage(AttributeTargets.Method)] | |
public class ExposeMethodInEditorAttribute : Attribute |
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
class BaseModel(models.Model): | |
""" | |
Base abstract model that adds created and modified dates. | |
Inherit from it when defining models. | |
""" | |
class Meta: | |
abstract = True | |
date_created = models.DateTimeField("Date Created", auto_now_add=True) |
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
python3 -m pip install --user --upgrade setuptools wheel | |
python3 setup.py sdist bdist_wheel | |
python3 -m pip install --user --upgrade twine | |
twine upload --repository pypi dist/* |
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
public static class Vector2Extension | |
{ | |
public static Vector2 Rotate(this Vector2 v, float degrees) | |
{ | |
return Quaternion.Euler(0, 0, degrees) * v; | |
} | |
} |
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 angle = Mathf.PI/2 + Mathf.Atan2(-moveDirection.normalized.y, moveDirection.normalized.x);// * Mathf.Rad2Deg; | |
main.startRotation = angle; //this has to be set in radians apparantly |
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
class ExtendedDeviceAdmin(DeviceAdmin): | |
actions = ("send_message", "send_bulk_message", "send_custom_message_bulk", "enable", "disable") | |
def send_custom_message_bulk(self, request, queryset): | |
form = None | |
# TODO: handle situation when results from multiple pages selected (or is it handled automatically in django 2?) | |
if 'apply' in request.POST: # if user pressed 'apply' on intermediate page |
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
# per terminal session | |
# check | |
ulimit -a | |
# set, e.g. 4096 | |
ulimit -n 4096 |
NewerOlder