Skip to content

Instantly share code, notes, and snippets.

View HamidOsouli-zz's full-sized avatar
🖥️
Always Learning

Hamid HamidOsouli-zz

🖥️
Always Learning
View GitHub Profile
To bind a dependency to some class in laravel
$this->app->bind(‘App\Helpers\Stripe’, function($app){
$api_key = config(‘services.stripe.api_key’);
return new \App\Helpers\Stripe($api_key);
});
@HamidOsouli-zz
HamidOsouli-zz / MultiTernary.js
Created November 10, 2018 21:55
this is the multi conditional with ternary operator for Javascript
let i = true;
let j = 14;
ans = i ? (j > 10 ? (j%7 === 7 ? 14 : 54 ) : 66) : 99;
// returns 14 because i === true && j > 10 && j%7 === 0
// There are other ways to enforce a function expression:
!function () { /* ... */ }();
~function () { /* ... */ }();
-function () { /* ... */ }();
+function () { /* ... */ }();
void function () { /* ... */ }();
//In contexts where an expression is expected, wrapping in parentheses is not necessary:
var f = function () { /* ... */ }();
true && function () { /* ... */ }();
0, function () { /* ... */ }();
'use strict'
const path = require('path')
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
@HamidOsouli-zz
HamidOsouli-zz / gist:927b255bdf0500a905583231835e8356
Created February 3, 2019 12:21
Common vendor chunk webpack
templateList.push(
new CommonsChunkPlugin({
name: 'vendor',
filename: 'vendor.weedoo.js',
minChunks: ({ resource }) => /node_modules/.test(resource),
})
);
templateList.push(
new CommonsChunkPlugin({
name: 'common',
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
package adanic.signer.rishe.services;
import com.itextpdf.kernel.geom.Rectangle;
import com.itextpdf.kernel.pdf.PdfDictionary;
import com.itextpdf.kernel.pdf.PdfName;
import com.itextpdf.kernel.pdf.PdfReader;
import com.itextpdf.kernel.pdf.StampingProperties;
import com.itextpdf.signatures.BouncyCastleDigest;
import com.itextpdf.signatures.DigestAlgorithms;
import com.itextpdf.signatures.ExternalBlankSignatureContainer;
@HamidOsouli-zz
HamidOsouli-zz / verification.java
Created September 28, 2020 13:56
verification.java
package com.itextpdf.samples.signatures.chapter05;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfReader;
import com.itextpdf.signatures.PdfPKCS7;
import com.itextpdf.signatures.SignatureUtil;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import java.io.IOException;

ES6 Setup with Babel 7

npm init -y
npm i --save-dev nodemon
npm install --save-dev @babel/core @babel/cli @babel/preset-env @babel/node

Create a .babelrc config in your project root. Insert the following

{
@HamidOsouli-zz
HamidOsouli-zz / AyandehDepositValidator.js
Last active September 19, 2021 19:07
Ayandeh Deposit Validator with Javascript
const checkValidDeposit = (accountNumber) => {
if (accountNumber.length < 13){
return false;
}
let total = Number(accountNumber[11]) * 5;
total += Number(accountNumber[10]) * 7;
total += Number(accountNumber[9]) * 13;
total += Number(accountNumber[8]) * 17;
total += Number(accountNumber[7]) * 19;
total += Number(accountNumber[6]) * 23;