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
public void getOrCreateUser(final ParseUser parseUser, final String email, final ProgressDialog dialog){ | |
String URL = "https://example.co/api/accounts?email="+ email +"&action=get_or_create"; | |
JsonArrayRequest req = new JsonArrayRequest(URL, new com.android.volley.Response.Listener<JSONArray>() { | |
@Override | |
public void onResponse(JSONArray jsonArray) { | |
try { | |
JSONObject apiUser = jsonArray.getJSONObject(0); | |
parseUser.put("email", email); | |
parseUser.put("api_token", apiUser.getString("token")); | |
parseUser.put("api_id", apiUser.getInt("id")); |
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
# models | |
from django.db import models | |
from django.contrib.auth.models import User | |
# Create your models here. | |
class Task(models.Model): | |
owner = models.ForeignKey('auth.User', related_name='tasks') | |
completed = models.BooleanField(default=False) |
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
import functools | |
from channels.handler import AsgiRequest | |
from rest_framework.exceptions import AuthenticationFailed | |
from rest_framework.settings import api_settings | |
authenticators = [auth() for auth in api_settings.DEFAULT_AUTHENTICATION_CLASSES] | |
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 ajax(options) { | |
return new Promise(function (resolve, reject) { | |
$.ajax(options).done(resolve).fail(reject); | |
}); | |
} | |
then run: | |
ajax({ | |
url: YOUR_URL, |
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
[program:celery_beat] | |
command=/opt/env/bin/celery --app=project.celery:app beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler | |
directory=/opt/project | |
user=root | |
stdout_logfile=/opt/logs/celery_beat/beat.log | |
stderr_logfile=/opt/logs/celery_beat/beat.error.log | |
autostart=true | |
autorestart=true | |
startsecs=10 |
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
class Computer(object): | |
name = None | |
serial = None | |
model = None | |
kind = None | |
attrs_with_value = None | |
def __init__(self, *args, **kwargs): | |
self.name = kwargs.get('name', None) | |
self.serial = kwargs.get('serial', None) |
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
@shared_task | |
def generate_pdf(user_id, body): | |
user = User.objects.get(id=user_id) | |
files = body['new_files'] | |
tabs = {} | |
for pic in files: | |
file = FileDetail.objects.get(filename=pic['filename']) | |
tab = file.story_set.get().channel.tab_set.first() |
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
# download | |
scp -r [email protected]:/folder ./ | |
# upload | |
scp -r my_dir/ [email protected]:/folder |
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
# | |
# This is the main Apache HTTP server configuration file. It contains the | |
# configuration directives that give the server its instructions. | |
# See <URL:http://httpd.apache.org/docs/2.2> for detailed information. | |
# In particular, see | |
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html> | |
# for a discussion of each configuration directive. | |
# | |
# Do NOT simply read the instructions in here without understanding | |
# what they do. They're here only as hints or reminders. If you are unsure |
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
countries = [ | |
{'timezones': ['Europe/Andorra'], 'code': 'AD', 'continent': 'Europe', 'name': 'Andorra', 'capital': 'Andorra la Vella'}, | |
{'timezones': ['Asia/Kabul'], 'code': 'AF', 'continent': 'Asia', 'name': 'Afghanistan', 'capital': 'Kabul'}, | |
{'timezones': ['America/Antigua'], 'code': 'AG', 'continent': 'North America', 'name': 'Antigua and Barbuda', 'capital': "St. John's"}, | |
{'timezones': ['Europe/Tirane'], 'code': 'AL', 'continent': 'Europe', 'name': 'Albania', 'capital': 'Tirana'}, | |
{'timezones': ['Asia/Yerevan'], 'code': 'AM', 'continent': 'Asia', 'name': 'Armenia', 'capital': 'Yerevan'}, | |
{'timezones': ['Africa/Luanda'], 'code': 'AO', 'continent': 'Africa', 'name': 'Angola', 'capital': 'Luanda'}, | |
{'timezones': ['America/Argentina/Buenos_Aires', 'America/Argentina/Cordoba', 'America/Argentina/Jujuy', 'America/Argentina/Tucuman', 'America/Argentina/Catamarca', 'America/Argentina/La_Rioja', 'America/Argentina/San_Juan', 'America/Argentina/Mendoza', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Ushuai |
OlderNewer