Skip to content

Instantly share code, notes, and snippets.

View narenaryan's full-sized avatar
🏠
Dreaming Big

N3N narenaryan

🏠
Dreaming Big
View GitHub Profile
@narenaryan
narenaryan / snip1.py
Created January 13, 2015 17:12
Snippet for deleting the duplicate entrys for a model
for row in MyModel.objects.all():
if MyModel.objects.filter(photo_id=row.photo_id).count() > 1:
row.delete()
@narenaryan
narenaryan / logcss.css
Last active August 29, 2015 14:13
This is a common pattern and a simple example for creating login page very quickly in django.Just place these files as described in the comment and Get login page
.vertical-offset-100{
padding-top:100px;
}
@narenaryan
narenaryan / graph_django_models
Last active August 29, 2015 14:13
Tutorial for creating graph visualizations for your Django models
$ pip install django-extensions
#These libraries are necessary before you proceed.
$ sudo apt-get install graphviz
$ sudo apt-get install graphviz-dev
#add django-extensions in project settigns.py
@narenaryan
narenaryan / FreshdeskSSO.py
Last active August 29, 2015 14:15
Freshdesk SSO remote login django view sample script
# Create your views here.
from django.shortcuts import render,redirect
from django.contrib.auth import authenticate
from datetime import datetime
import hmac
def ticket_login(request):
if request.method == 'GET':
return render(request, 'ticketing/login.html')
(do (println "Enter a number")
(let [num (read-string (read-line))]
(println (str "you" "entered" num))
)
)
#!/bin/sh
echo "updating ubuntu"
sudo apt-get -qq update
sudo apt-get -qq upgrade
# development
echo "installing development tools"
sudo apt-get -qq install build-essential
from datetime import datetime, timedelta
import sys,requests,pprint
sys.path.append('/home/naren/Downloads/vtwsclib/Vtiger')
from WSClient import *
class KnowTiger(object):
@narenaryan
narenaryan / graph.py
Last active August 29, 2015 14:22 — forked from moqada/graph.py
# -*- coding: utf-8 -*-
import pygal
from flask import Flask, Response
app = Flask(__name__)
@app.route('/')
def index():
@narenaryan
narenaryan / sieve.jl
Created June 25, 2015 18:37
A Sieve of Eratosthenes implementation in Julia
# Sieve of Eratosthenes, docstrings coming in Julia 0.4
function es(n::Int64) # accepts one 64 bit integer argument
isprime = ones(Bool, n) # n-element vector of true-s
isprime[1] = false # 1 is not a prime
for i in 2:int64(sqrt(n)) # loop integers from 2 to sqrt(n), explicit conversion to integer
if isprime[i] # conditional evaluation
for j in (i*i):i:n # sequence from i^2 to n with step i
isprime[j] = false # j is divisible by i
end
end
def iprimes_upto(limit):
is_prime = [False] * 2 + [True] * (limit - 1)
for n in xrange(int(limit**0.5 + 1.5)): # stop at ``sqrt(limit)``
if is_prime[n]:
for i in range(n * n, limit + 1, n): # start at ``n`` squared
is_prime[i] = False
for i in xrange(limit + 1):
if is_prime[i]: yield i