Skip to content

Instantly share code, notes, and snippets.

View SamsadSajid's full-sized avatar

SamsadSajid

View GitHub Profile
@SamsadSajid
SamsadSajid / 0_reuse_code.js
Created May 24, 2017 06:13
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
unicode(object='') -> unicode object
unicode(string[, encoding[, errors]]) -> unicode object
Create a new Unicode object from the given encoded string.
encoding defaults to the current default string encoding.
errors can be 'strict', 'replace' or 'ignore' and defaults to 'strict'.
{u'paging': {u'total': 2219, u'next': u'100'}, u'elements': [{u'slug': u'gamification', u'courseType': u'v2.ondemand', u'name': u'Gamification', u'id': u'69Bku0KoEeWZtA4u62x6lQ'}, {u'slug': u'missing-data', u'courseType': u'v2.ondemand', u'name': u'Dealing With Missing Data', u'id': u'0HiU7Oe4EeWTAQ4yevf_oQ'}, {u'slug': u'vital-signs', u'courseType': u'v2.ondemand', u'name': u'Vital Signs: Understanding What the Body Is Telling Us', u'id': u'5zjIsJq-EeW_wArffOXkOw'}, {u'slug': u'modern-art-ideas', u'courseType': u'v2.ondemand', u'name': u'Modern Art & Ideas', u'id': u'v9CQdBkhEeWjrA6seF25aw'}, {u'id': u'QgmoVdT2EeSlhSIACx2EBw', u'slug': u'evolvinguniverse', u'courseType': u'v2.ondemand', u'name': u'The Evolving Universe'}, {u'slug': u'changing-global-order', u'courseType': u'v2.ondemand', u'name': u'The Changing Global Order', u'id': u'vwcoxOyuEeWLaBLI8fdMlw'}, {u'slug': u'design', u'courseType': u'v2.ondemand', u'name': u'Design: Creation of Artifacts in Society', u'id': u'FlptMGk3EeSiViIACw8GlA'}, {u'id': u
{u'paging': {u'total': 2219, u'next': u'100'}, u'elements': [{u'slug': u'gamification', u'courseType': u'v2.ondemand', u'name': u'Gamification', u'id': u'69Bku0KoEeWZtA4u62x6lQ'}, {u'slug': u'missing-data', u'courseType': u'v2.ondemand', u'name': u'Dealing With Missing Data', u'id': u'0HiU7Oe4EeWTAQ4yevf_oQ'}, {u'slug': u'vital-signs', u'courseType': u'v2.ondemand', u'name': u'Vital Signs: Understanding What the Body Is Telling Us', u'id': u'5zjIsJq-EeW_wArffOXkOw'}, {u'slug': u'modern-art-ideas', u'courseType': u'v2.ondemand', u'name': u'Modern Art & Ideas', u'id': u'v9CQdBkhEeWjrA6seF25aw'}, {u'id': u'QgmoVdT2EeSlhSIACx2EBw', u'slug': u'evolvinguniverse', u'courseType': u'v2.ondemand', u'name': u'The Evolving Universe'}, {u'slug': u'changing-global-order', u'courseType': u'v2.ondemand', u'name': u'The Changing Global Order', u'id': u'vwcoxOyuEeWLaBLI8fdMlw'}, {u'slug': u'design', u'courseType': u'v2.ondemand', u'name': u'Design: Creation of Artifacts in Society', u'id': u'FlptMGk3EeSiViIACw8GlA'}, {u'id': u
python
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib,json
>>> url="https://api.coursera.org/api/courses.v1?search&query=python"
>>> response = urllib.urlopen(url)
>>> data = json.loads(response.read())
>>> print data
{u'paging': {u'total': 2219, u'next': u'100'}, u'elements': [{u'slug': u'gamification', u'courseType': u'v2.ondemand', u'name': u'Gamification', u'id': u'69Bku0KoEeWZtA4u62x6lQ'}, {u'slug': u'missing-data', u'courseType': u'v2.ondemand', u'name': u'Dealing With Missing Data', u'id': u'0HiU7Oe4EeWTAQ4yevf_oQ'}, {u'slug': u'vital-signs', u'courseType': u'v2.ondemand', u'name': u'Vital Signs: Understanding What the Body Is Telling Us', u'id': u'5zjIsJq-EeW_wArffOXkOw'}, {u'slug': u'modern-art-ideas', u'courseType': u'v2.ondemand', u'name': u'Modern Art & Ideas', u'id': u'v9CQdBkhEeWjrA6seF25aw'}, {u'id': u'QgmoVdT2EeSlhSIACx2EBw', u'slug': u'evolvinguniverse', u'courseType': u'v2
@SamsadSajid
SamsadSajid / TODO.py
Created October 19, 2017 05:10
TO: sikkhanobish
"""
I want to do something like this:
"""
class Meta:
permissions = (
('view_task', 'View task'),
)
group = Group.objects.create(name='employees')
assign_perm('change_task', group, task)
@SamsadSajid
SamsadSajid / popcorn.bash
Last active December 10, 2017 13:03
Install Popcorn on ubuntu
sudo apt-get install libudev1
cd /lib/x86_64-linux-gnu/
sudo ln -s libudev.so.1 libudev.so.0
@SamsadSajid
SamsadSajid / picture.py
Last active November 26, 2017 12:22
Picture will be reshaped using PIL from PILLOW
@login_required(login_url='/login/')
@group_required('client_group')
def picture(request):
user = request.user
profile_pictures = django_settings.MEDIA_ROOT + '/profile_pictures/'
if not os.path.exists(profile_pictures):
os.makedirs(profile_pictures)
if request.method == 'POST':
_picture = request.FILES['picture']
filename = profile_pictures + request.user.username + '_' + str(request.user.id) + '.jpg'
==========================
Creating target directory...
==========================
Command start time 2017-12-13 17:02:25
Connection to ajoy.net closed.
SSH command execution finished
host=ajoy.net, exitcode=0
Command end time 2017-12-13 17:02:30
{% extends 'dashboard/test.html' %}
{% load staticfiles %}
{% load i18n %}
{% block content %}
<!-- page content -->
<div class="right_col" role="main">
<div class="">
<div class="page-title">
<div class="title_left">