Skip to content

Instantly share code, notes, and snippets.

View nixon1333's full-sized avatar
Moving Fast

Ashraful Islam Nixon nixon1333

Moving Fast
View GitHub Profile
@nixon1333
nixon1333 / twik.js
Last active February 3, 2018 18:04
// similar behavior as an HTTP redirect
window.location.replace("http://sidanmor.com");
// similar behavior as clicking on a link
window.location.href = "http://sidanmor.com";
//get value of a input item(of a id) using raw js
document.getElementById('inputID').value;
//get value of a input item(of a name) using raw js

virtualenv open-env source open-env/bin/activate touch requirements.txt nano requirements.txt django==1.10.5 djangorestframework psycopg2 djangorestframework-jwt pip install -r requirements.txt django-admin startproject openx

@nixon1333
nixon1333 / raw_query.py
Last active February 9, 2017 19:34
Run raw SQL query in Django
#it's the system's default database connection
from django.db import connection
def use_raw_query(self):
#raw sql query here
query = "SELECT * FROM `table` WHERE `row`= 1 "
#a cursor object
with connection.cursor() as cursor:
#execute the query
@nixon1333
nixon1333 / .htaccess
Created December 30, 2016 16:13
301 redirect(all pages) to new Domain
Options +FollowSymLinks
RewriteEngine on
#here http://www.ainixon.me/rss/ is the new domain link where we want to redirect all our traffic.
RewriteRule (.*) http://www.ainixon.me/rss/ [R=301,L]
@nixon1333
nixon1333 / SendSmsCommand.php
Last active December 14, 2016 23:00
Simple CLI Command using Symfony
<?php
// this is the file structure of the command file.
// src/SmsBundle/Command/SendSmsCommand.php
namespace SmsBundle\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
//we need this to take inputs from the console.
use Symfony\Component\Console\Input\InputArgument;
@nixon1333
nixon1333 / banglaNumber.js
Created February 22, 2016 09:53
English number to Bangla number convertion
function toBangla (str)
{
//check if the `str` is not string
if(!isNaN(str)){
//if not string make it string forcefully
str = String(str);
}
//start try catch block
try {
@nixon1333
nixon1333 / banglaNumber.php
Created February 20, 2016 10:20
Bangla number conversion from English
<?php
function toBangla ($str)
{
$convert = array (
'0' => '০',
'1' => '১',
'2' => '২',
'3' => '৩',
'4' => '৪',
'5' => '৫',
@nixon1333
nixon1333 / print-file.html
Created January 4, 2016 07:50
print page demo
<style>
body {
}
table
{
width: 100%;
}
table,th,td
@nixon1333
nixon1333 / wkhtmltopdf.php
Created December 13, 2015 07:16
how to parse a secured file in php and make it available in pdf using wkhtmltopdf
//if expected template available in string formate
if($string1)
{
//write the expected template in a unique html file
write_file("uploads/$classId/Result-$classId-part$number.html", $string1);
//make the unique url for the html
$fileUrl = base_url()."uploads/$classId/Result-$classId-part$number.html";
//run exec funtion and fee the html link to wkhtml function with requed pdf link(unique)
exec('"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe" '.$fileUrl. ' uploads/'.$classId.'/'.$number.".pdf");
//after execution remove the html file
@nixon1333
nixon1333 / README.md
Created November 19, 2015 05:24 — forked from oodavid/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/