Skip to content

Instantly share code, notes, and snippets.

View alihesari's full-sized avatar
🏠
Working from home

Ali Hesari alihesari

🏠
Working from home
View GitHub Profile
@alihesari
alihesari / webpack.config.js
Last active January 18, 2018 06:58
This web pack config convert assets file (images and fonts) to base64
var webpack = require('webpack');
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: './src/js/main.js',
output: {
path: path.resolve(__dirname, 'dist/'),
publicPath: 'dist/',
filename: 'bundle.js'
var webpack = require('webpack');
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: './src/js/main.js',
output: {
path: path.resolve(__dirname, 'dist/'),
publicPath: 'dist/',
filename: 'bundle.js'
@alihesari
alihesari / README.md
Created May 13, 2018 15:18 — forked from joyrexus/README.md
Form/file uploads with hapi.js

Demo of multipart form/file uploading with hapi.js.

Usage

npm install
npm run setup
npm run server

Then ...

@alihesari
alihesari / app.js
Created August 31, 2018 11:26 — forked from stongo/app.js
Joi validation in a Mongoose model
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var db = mongoose.connection;
db.on('error', function() {
return console.error.bind(console, 'connection error: ');
});
@alihesari
alihesari / letsencrypt_2018.md
Created September 2, 2018 21:44 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@alihesari
alihesari / countries.json
Last active September 18, 2018 07:58
JSON List of countries of the world
[
{
"name": "Afghanistan",
"shortName": "AF",
"capital": "Kabul",
"continent": "Asia"
},
{
"name": "Aland Islands",
"shortName": "AX",
@alihesari
alihesari / user.js
Created January 1, 2019 15:15 — forked from EtienneR/user.js
XMLHttpRequest RESTful (GET, POST, PUT, DELETE)
// Get all users
var url = "http://localhost:8080/api/v1/users";
var xhr = new XMLHttpRequest()
xhr.open('GET', url, true)
xhr.onload = function () {
var users = JSON.parse(xhr.responseText);
if (xhr.readyState == 4 && xhr.status == "200") {
console.table(users);
} else {
console.error(users);
@alihesari
alihesari / createBill.js
Created February 16, 2020 14:17
Shenase.ir - Create Bill
const axios = require('axios');
// Send a POST request
axios({
method: 'post',
url: 'http://shenase.net/api/bills/create',
data: {
username: 'ali',
password: 'ali12@34',
billType: 0,
@alihesari
alihesari / getBillStatus.js
Created February 16, 2020 14:47
shenase.ir - Get bill status
const axios = require('axios');
// Send a POST request
axios({
method: 'post',
url: 'http://shenase.net/api/bills/stateByIds',
data: {
username: 'ali',
password: 'ali12@34',
billId: 5431,
@alihesari
alihesari / checkout.js
Created February 16, 2020 14:49
Shenase.ir - Checkout
const axios = require('axios');
// Send a POST request
axios({
method: 'post',
url: 'http://shenase.net/api/service/settle/request',
data: {
username: 'ali',
password: 'ali12@34',
card_id: 5,