Skip to content

Instantly share code, notes, and snippets.

View ulvidamirli's full-sized avatar

Ulvi Damirli ulvidamirli

View GitHub Profile
@Vibhu-Agarwal
Vibhu-Agarwal / models.py
Last active March 7, 2024 00:28
Example Describing How to Serialize Multiple Models through One Serializer (Case of Foreign Keys) | Django Rest Framework
from django.db import models
class ModelA(models.Model):
fieldA1 = models.CharField(max_length=100, unique=True)
fieldA2 = models.TextField(validators=[URLValidator()], blank=True, null=True)
fieldA3 = models.CharField(max_length=100, unique=True, null=True, blank=True)
field4 = models.BooleanField(default=True)
@xbeta
xbeta / README.md
Last active April 30, 2024 20:08
Macbook Pro Bluetooth + WiFi 2.4GHz interference fix for Mavericks
@codeguy
codeguy / slugify.js
Created September 24, 2013 13:19
Create slug from string in Javascript
function string_to_slug (str) {
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}