Skip to content

Instantly share code, notes, and snippets.

View Sanyambansal76's full-sized avatar
🎯
Focusing

Sanyam Bansal Sanyambansal76

🎯
Focusing
View GitHub Profile
@Sanyambansal76
Sanyambansal76 / gist:9add20e6cde8eedff301044e656df1dc
Last active January 12, 2017 18:48
AWS CodeDeploy and Codeship Intergration
#Create a aws account
#CREATE I AM ROLE
1. Create the IAM role
2. Open the IAM from the your aws dashboard
3. Click on the roles
4. Click on create new role
5. Enter the Role Name CodeDeployInstanceRole
6. Attach Following Policies
a. AmazonEC2RoleforAWSCodeDeploy
@Sanyambansal76
Sanyambansal76 / Create High Quality Image Using Wand
Created January 18, 2017 14:53
Create High Quality Image Using Wand
#Install Wand and Imagemagic Lib on Your System
#Pass the resolution paramenter in the Image Init Method
from wand.image import Image
with Image(filename='file.pdf', resolution=200) as image:
image.compression_quality = 99
image.save(filename='file.jpg')
@Sanyambansal76
Sanyambansal76 / GULP TASK
Created January 19, 2017 06:40
GULP TASK
"use strict";
var gulp = require('gulp');
var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync');
var concat = require('gulp-concat');
var connect = require('gulp-connect');
var imagemin = require('gulp-imagemin');
var newer = require('gulp-newer');
var notify = require('gulp-notify');
@Sanyambansal76
Sanyambansal76 / Tor Setup link
Created January 31, 2017 11:29
Tor Setup link
{
"response": {
"status": "ok",
"userTier": "developer",
"total": 60576,
"startIndex": 1,
"pageSize": 8,
"currentPage": 1,
"pages": 7572,
"orderBy": "relevance",
{
u'title': {
u'title': u'SPORT NEWS IN BRIEF'
},
u'modelVersion': u'1',
u'apiUrl': u'http://api.ft.com/content/items/v1/b0cb0082-97aa-11db-a680-0000779e2340',
u'location': {
u'uri': u'http://www.ft.com/cms/b0cb0082-97aa-11db-a680-0000779e2340.html'
},
u'id': u'b0cb0082-97aa-11db-a680-0000779e2340',
@Sanyambansal76
Sanyambansal76 / Order Book Gdax
Created August 9, 2017 14:11
List contains 3 index [ price, size, num-orders ]
{
u'bids': [
[
u'3272.07',
u'0.10051789',
1
],
[
u'3270.8',
u'3.55364293',
@Sanyambansal76
Sanyambansal76 / sql_replace_in_django_orm.py
Created May 1, 2018 10:17 — forked from simonw/sql_replace_in_django_orm.py
How to use the SQL replace function in a Django ORM query
from django.db.models import F, Func, Value
from myapp.models import MyModel
# Annotation
MyModel.objects.filter(description__icontains='\r\n').annotate(
fixed_description=Func(
F('description'),
Value('\r\n'), Value('\n'),
function='replace',
)
@Sanyambansal76
Sanyambansal76 / Django Access the Request or User Object Inside the Models and Signals.txt
Last active May 3, 2018 02:50
Django Access the Request or User Object Inside the Models and Signals.
#Access Request Object Inside the Models and Signals
#Create a middleware.py inside any app for example :- blog
#middleware.py
import threading
class RequestMiddleware(object):
thread_local = threading.local()
@Sanyambansal76
Sanyambansal76 / speed_test.py
Created September 2, 2018 13:35
Linux Speed Test command line
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2012-2018 Matt Martz
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0