// jQuery
$(document).ready(function() {
// code
})
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
from django.core.management.base import BaseCommand, CommandError | |
from django.core import serializers | |
from optparse import make_option | |
class Command(BaseCommand): | |
""" | |
Generate a fixture file for a specific model. | |
Useage: ./manage.py generate_fixtures app.models.MyModel --file=MyModelsOutputFile.json | |
""" |
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
from django import forms | |
from django.contrib.auth.models import User | |
from django.contrib.auth.forms import UserCreationForm | |
from django.utils.translation import ugettext as _ | |
class SignupForm(UserCreationForm): | |
def __init__(self, *args, **kwargs): | |
super(SignupForm, self).__init__(*args, **kwargs) | |
self.fields.pop('username') | |
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
from django.utils.functional import lazy | |
from django.core.urlresolvers import reverse | |
reverse_lazy = lazy(reverse, unicode) |
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
from django import template | |
register = template.Library() | |
@register.tag(name="raw") | |
def raw(parser, token): | |
# Whatever is between {% raw %} and {% endraw %} will be preserved as | |
# raw, unrendered template code. | |
text = [] |
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 Set<String> getNamedGroupCandidates(String regex) { | |
Set<String> namedGroups = new TreeSet<>(); | |
Matcher m = Pattern.compile("\\(\\?<([a-zA-Z0-9]*)>").matcher(regex); | |
while (m.find()) { | |
namedGroups.add(m.group(1)); | |
} | |
return namedGroups; | |
} |
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 <T> Optional<T> resolve(Supplier<T> resolver) { | |
try { | |
T result = resolver.get(); | |
return Optional.ofNullable(result); | |
} catch (NullPointerException e) { | |
return Optional.empty(); | |
} | |
} |
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 class Format { | |
public static String format(String source, String ... args) { | |
return String.format(source.replaceAll("\\$\\w+", "%s"), (Object[]) args); | |
} | |
} |
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
import android.support.annotation.NonNull; | |
import com.annimon.stream.function.Consumer; | |
import rx.Observable; | |
import rx.Scheduler; | |
import rx.Subscriber; | |
import rx.Subscription; | |
public class RetroObservable<T> { |
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
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.function.Supplier; | |
@SuppressWarnings("unused") | |
public class Scenario<T> { | |
private State state; | |
private final String description; | |
private final Supplier<T> contextSupplier; |
OlderNewer