This file contains hidden or 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
@register.filter | |
@stringfilter | |
def stripjs(value): | |
stripped = re.sub(r'<script(?:\s[^>]*)?(>(?:.(?!/script>))*</script>|/>)', \ | |
'', force_unicode(value), flags=re.S) | |
return mark_safe(stripped) |
This file contains hidden or 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
def clean_url(self): | |
INVALID_URLS = ('about', 'admin', 'register') | |
url = self.cleaned_data['url'] | |
try: | |
post = Post.objects.get(url=url) | |
except Post.DoesNotExist: | |
pass | |
else: | |
raise forms.ValidationError(u'%s already exists' % post ) |
This file contains hidden or 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
alias gs='git status ' | |
alias ga='git add ' | |
alias gb='git branch ' | |
alias gc='git commit' | |
alias gd='git diff' | |
alias go='git checkout ' | |
alias gk='gitk --all&' | |
alias gx='gitx --all' | |
alias got='git ' |
This file contains hidden or 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 change(element, increment) { | |
var $el = $(element), | |
elValue = parseInt($el.val(), 10), | |
incAmount = increment || 1, | |
newValue = elValue + incAmount; | |
if ((newValue) > -1) { | |
$el.val(newValue); | |
} | |
} |
This file contains hidden or 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
PROMPT=$C$D$S$T$H$H$H$H$H$H$F$S$P$_$G$S |
This file contains hidden or 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
Execute a function by specifying its name as a string. | |
----- | |
A [Pen](http://codepen.io/anon/pen/AgCDt) by [Anonasaurus Rex](http://codepen.io/anon) on [CodePen](http://codepen.io/). | |
[License](http://codepen.io/anon/pen/AgCDt/license). |
This file contains hidden or 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 Uninstall-NpmPackages { | |
Param ( | |
# Optional path to package.json | |
[String]$pathToPackage = $(Resolve-Path "package.json") | |
) | |
# Read the json content | |
$json = (Get-Content $pathToPackage) -join "`n" | ConvertFrom-Json | |
# Loop over each package in devDependencies |
This file contains hidden or 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 Uninstall-NpmPackagesInDirectory { | |
Param ( | |
# Optional path to node_modules directory | |
[String]$pathToNodeModules = (Get-Item -Path ".\node_modules").FullName | |
) | |
# Loop over each folder in the directory | |
ForEach ($dep in Get-ChildItem -Path $pathToNodeModules | ? { $_.FullName -notmatch ".bin" }) { | |
# Uninstall the package | |
iex "npm uninstall $dep" |
This file contains hidden or 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
/** | |
* Returns an array of elements with a matching data attribute name. | |
* @example | |
* let value = getElementsByDataAttribute('component-name'); | |
*/ | |
export default function getElementsByDataAttribute(name) { | |
var elements = document.querySelectorAll(`[data-${name}]`); | |
return Array.prototype.slice.call(elements); | |
}; |
This file contains hidden or 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
/** | |
* Return data attribute value from a given element. Falls back to `getAttribute()` in older browsers. | |
* @example | |
* let value = getDataAttributeValue(element, 'component-name'); | |
* @example | |
* let value = getDataAttributeValue(element, 'componentName'); | |
*/ | |
export default function getDataAttributeValue(element, dataName, defaultDataValue = '') { | |
const datasetSupported = element.dataset !== undefined; |
OlderNewer