Skip to content

Instantly share code, notes, and snippets.

View pareksha's full-sized avatar
:octocat:
Code && Coffee

Pareksha Manchanda pareksha

:octocat:
Code && Coffee
  • Chandigarh, India
View GitHub Profile
var Col = require('react-bootstrap/lib/Col')
var PageHeader = require('react-bootstrap/lib/PageHeader')
var React = require('react')
var Row = require('react-bootstrap/lib/Row')
var {connect} = require('react-redux')
var {reduxForm} = require('redux-form')
var DateInput = require('./DateInput')
var FormField = require('./FormField')
var LoadingButton = require('./LoadingButton')
@pareksha
pareksha / EasyWriteCSV.py
Created January 8, 2019 11:16
Easy write on csv file using python (with simple file open and file write commands)
# Make directory if it doesn't exist
directory = 'media/csvs/'
if not os.path.exists(directory):
os.makedirs(directory)
path = directory + 'student_data.csv'
csvFile = open(path, 'w')
csvFile.write('Name,Contact Number,email\n')
# Iterate through queryset or list and do the following for each iteration
@pareksha
pareksha / djangoContactNumberValidation.py
Created January 8, 2019 11:11
Easy validation for contact number/mobile number
valid_contact = True
# Check if contact can be converted to integer (use regex match if chars like + are allowed)
# Although it is suggested to store coutry codes separately
try:
contact_number = int(data['contact_number'])
except ValueError:
valid_contact = False
# Change length according to needs, generally kept between 10 and 15, strictly 10 used here
@pareksha
pareksha / djangoValidateEmail.py
Last active January 8, 2019 11:08
Easy email validation in django.
from django.core.validators import ValidationError
try:
validate_email(email)
except ValidationError:
return Response({"status": "error", "message": "Provided email id is invalid."})
@pareksha
pareksha / djangoCreateDirectoryShortcut.py
Last active January 8, 2019 11:01
This python snippet creates the directory if it doesn't exist.
import os
directory = 'media/csvs/'
if not os.path.exists(directory):
os.makedirs(directory)
from coalib.bearlib.languages.Language import Language
@Language
class VB:
aliases = 'vb',
versions = 14.0, 15.0
extensions = '.vb',
comment_delimiter = "'"
string_delimiters = {'"': '"'}
from coalib.bearlib.languages.Language import Language
@Language
class m4:
versions = 1.4,
extensions = '.m4',
comment_delimiter = '#'
multiline_comment_delimiters = {'/*': '*/'}
string_delimiters = {'`': "'", '"': '"'}
from coalib.bearlib.languages.Language import Language
@Language
class Tcl:
aliases = 'Tcl/Tk',
versions = 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6
extensions = '.tcl',
comment_delimiter = '#'
string_delimiters = {'"': '"', '{': '}'}
[WARNING][12:50:43] Implicit 'Default' section inheritance is deprecated. It will be removed soon. To silence this warning remove settings in the 'Default' section from your coafile. You can use dots to specify inheritance: the section 'all.python' will inherit all settings from 'all'.
Executing section LineLength...
Executing section CheckQuotation...
Executing section UnusedCode...
Executing section pep8...
Executing section SpaceCheck...
Executing section cli...
import random
import sys
import time
def initialiseBoard():
"""Set the grid dimensions according to the user.
Function returns grid_list containing the grid values.
Option to change the size of the board added.