Skip to content

Instantly share code, notes, and snippets.

View tonytan4ever's full-sized avatar

Tony Tan tonytan4ever

View GitHub Profile
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/eventlet/greenpool.py", line 82, in _spawn_n_impl
func(*args, **kwargs)
File "/media/sf_Rackspace/neutron/neutron/agent/l3/agent.py", line 471, in _process_router_update
self.pd.process_prefix_update()
File "/usr/local/lib/python2.7/dist-packages/oslo_concurrency/lockutils.py", line 271, in inner
return f(*args, **kwargs)
File "/media/sf_Rackspace/neutron/neutron/agent/linux/pd.py", line 284, in process_prefix_update
pd_info.bind_lla)
File "/media/sf_Rackspace/neutron/neutron/agent/linux/dibbler.py", line 126, in enable
$ sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
@tonytan4ever
tonytan4ever / is_ascii.py
Created January 26, 2017 15:34
if a unicode character exists in a string
def is_ascii(s):
return all(ord(c) < 128 for c in s)
failed: [sl_test] (item={u'name': u'BSTS'}) => {"changed": false, "cmd": ["R-install-package", "BSTS", "cran"], "delta": "0:00:00.951372", "end": "2016-12-24 07:28:24.959896", "failed": true, "invocation": {"module_args": {"_raw_params": "R-install-package\n BSTS\n cran\n ", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": true}, "module_name": "command"}, "item": {"name": "BSTS"}, "rc": 1, "start": "2016-12-24 07:28:24.008524", "stderr": "Error: package 'BSTS' is not available (for R version 3.3.2)\nExecution halted", "stdout": "", "stdout_lines": [], "warnings": []}
@tonytan4ever
tonytan4ever / gist:d7e2dc7e736c65f3c1ac00a52cc888be
Last active November 5, 2016 03:49
edx update user to superuser
sudo -u www-data /edx/bin/python.edxapp ./manage.py lms --settings aws shell
from django.contrib.auth.models import User
me = User.objects.get(username="<user_name_of_the_user_you_want_to_be_super_user>")
me.is_superuser = True
me.is_staff = True
me.active = True
me.save()
alias paver-collectstatic='cd /edx/app/edxapp/edx-platform; date; time python manage.py lms --settings=aws collectstatic --noinput'
alias paver-compile='cd /edx/app/edxapp/edx-platform; time paver update_assets lms --settings=aws'
alias paver-compile-debug='cd /edx/app/edxapp/edx-platform; time paver update_assets lms --settings=aws --debug'
alias paver-go='cd /edx/app/edxapp/edx-platform; paver update_assets lms --settings=aws; paverdevstack lms --fast'
alias paver-run='cd /edx/app/edxapp/edx-platform; paver devstack lms --fast'
alias theme-base='cd /edx/app/edxapp/themes/dentalpost-theme/lms/static/sass/partials/base'
@tonytan4ever
tonytan4ever / bash_aliase
Last active November 4, 2016 13:47
Open Edx
alias su-edxapp-user='sudo su edxapp -s /bin/bash'
alias su-www-user='sudo su www-data -s /bin/bash'
alias django-admin-help='sudo -u edxapp /edx/bin/python.edxapp /edx/app/edxapp/edx-platform/man
age.py lms --settings=aws help'
alias django-shell='sudo -u www-data /edx/bin/python.edxapp /edx/app/edxapp/edx-platform/manage.py lms --settings aws shell'
alias build-edx-certs='sudo /edx/bin/supervisorctl stop certs:; date; time sudo /edx/bin/update read-only-certificate-code ; date'
alias build-edx-configuration='sudo /edx/bin/supervisorctl stop edxapp:; date; time sudo /edx/bin/update configuration master; date'
alias build-edx='date; time sudo /edx/bin/update edx-platform dentalpost-eucalyptus; date'
alias fix-mongo='sudo /etc/init.d/mongod stop; sudo rm /edx/var/mongo/mongodb/mongod.lock; sudo mongod -repair --config /etc/mongod.conf; sudo chown -R mongodb:mongodb /edx/var/mongo/.; sudo /etc/init.d/mongod start'
alias git-fetch-edx-platform='cd /edx/app/edxapp/edx-platform; sudo git fetch --all'
{
"AFFILIATE_COOKIE_NAME": "dev_affiliate_id",
"ANALYTICS_DASHBOARD_URL": "http://localhost:18110/courses",
"ANALYTICS_DATA_URL": "",
"ANALYTICS_SERVER_URL": "",
"AWS_SES_REGION_ENDPOINT": "email.us-east-1.amazonaws.com",
"AWS_SES_REGION_NAME": "us-east-1",
"BOOK_URL": "",
"BUGS_EMAIL": "[email protected]",
"BULK_EMAIL_DEFAULT_FROM_EMAIL": "[email protected]",
{
"resources": [
{
"links": [
{
"href": "http://127.0.0.1:9696/v2.0/subnets",
"rel": "self"
}
],
"name": "subnet",
An integer X and a non-empty zero-indexed array A consisting of N integers are given. We are interested in which elements of A are equal to X and which are different from X. The goal is to split array A into two parts, such that the number of elements equal to X in the first part is the same as the number of elements different from X in the other part. More formally, we are looking for a number K such that:
0 <= K <= N
the number of elements equal to X in A[0..K−1] is the same as the number of elements different from X in A[K..N−1]. (For K = 0, A[0..K−1] does not contain any elements. For K = N, A[K..N−1] does not contain any elements.)
A[0] = 5
A[1] = 5
A[2] = 1
A[3] = 7
A[4] = 2