Skip to content

Instantly share code, notes, and snippets.

View Winston1029's full-sized avatar

Winston Winston1029

  • MelonSail
  • Singapore
View GitHub Profile
@Winston1029
Winston1029 / gist:0ad523acfd7f6d055f2c35cd2550c9e0
Created May 29, 2016 13:56 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# 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*
# 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
[
{
"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"
function submit_search()
{
$.ajax(
{
data:
{
query: document.search_form.query.value
},
datatype: 'json',
success: function(data, textStatus, XMLHttpRequest)
<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>
@Winston1029
Winston1029 / init_template.js
Created November 14, 2013 04:07
simple bootstrap code for javascript exercise
<!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">
from tastypie.throttle import CacheThrottle
class NoteResource(Resource):
class Meta:
allowed_methods = ['get']
resource_name = 'notes'
throttle = CacheThrottle()
def prepend_urls(self):
@Winston1029
Winston1029 / Duplicate Items in List and Index
Created August 7, 2013 02:10
Find duplicate items and list all its index
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]}
@Winston1029
Winston1029 / Sort Multiple List Together
Created August 7, 2013 02:00
Sort multiple lists that reference index each other
list1, list2, list3 = (list(t) for t in zip(*sorted(zip(list1, list2, list3))))
final_dict = dict(dict1.items() + dict2.items())
# OR memory saving method
final_dict = dict( chain(dict1.items(), dict2.items()) )