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
| # first: | |
| lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done | |
| sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.* | |
| # To recap, the best way (I've found) to completely uninstall node + npm is to do the following: | |
| # go to /usr/local/lib and delete any node and node_modules | |
| cd /usr/local/lib | |
| sudo rm -rf node* |
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
| # API authentication | |
| from social.apps.django_app.utils import strategy | |
| from rest_framework.authtoken.models import Token | |
| from rest_framework.views import APIView | |
| from rest_framework import parsers | |
| from rest_framework import renderers | |
| from rest_framework.authentication import get_authorization_header | |
| from rest_framework.response import Response |
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
| [ | |
| { | |
| "tour":{ | |
| "tour_ending_time":"2014-07-05 00:39:21", | |
| "tour_name":"Test Gallery 2 for Skypark No Data", | |
| "contents":[ | |
| { | |
| "link":"https://s3-ap-southeast-1.amazonaws.com/melonwaveuatugc/20140705/25/1404492392466.jpg", | |
| "type":2, | |
| "updated_time":"2014-07-05 00:49:25" |
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 submit_search() | |
| { | |
| $.ajax( | |
| { | |
| data: | |
| { | |
| query: document.search_form.query.value | |
| }, | |
| datatype: 'json', | |
| success: function(data, textStatus, XMLHttpRequest) |
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
| <pre><code> | |
| <div id="login_form" title="Log in"> | |
| <form> | |
| <fieldset> | |
| <label for="login">Login</label> | |
| <input type="text" name="login" id="login" class="text ui-widget-content ui-corner-all" /><br /> | |
| <label for="password">Password</label> | |
| <input type="password" name="password" id="password" class="text ui-widget-content ui-corner-all" /><br /> | |
| </fieldset> | |
| </form> |
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
| <!DOCTYPE HTML> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Title</title> | |
| </head> | |
| <body> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"> | |
| </script> | |
| <script src="http://documentcloud.github.com/underscore/underscore-min.js"> |
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
| from tastypie.throttle import CacheThrottle | |
| class NoteResource(Resource): | |
| class Meta: | |
| allowed_methods = ['get'] | |
| resource_name = 'notes' | |
| throttle = CacheThrottle() | |
| def prepend_urls(self): |
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
| from collections import defaultdict | |
| D = defaultdict(list) | |
| for i, item in enumerate(mylist): | |
| D[item].append(i) | |
| D = {k: v for k, v in D.items() if len(v) > 2} | |
| # mylist = [20, 30, 25, 20] | |
| # D = {20: [0, 3]} |
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
| list1, list2, list3 = (list(t) for t in zip(*sorted(zip(list1, list2, list3)))) |
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
| final_dict = dict(dict1.items() + dict2.items()) | |
| # OR memory saving method | |
| final_dict = dict( chain(dict1.items(), dict2.items()) ) |
NewerOlder