Skip to content

Instantly share code, notes, and snippets.

View mort3za's full-sized avatar
🕸️

Morteza Ziyaeimehr mort3za

🕸️
View GitHub Profile
@mort3za
mort3za / number-format.twig
Last active October 26, 2021 14:50
Human readable number format in Twig. Example: human_readable(22111, 1) ===> 22.1K
{% macro human_readable(input, fraction) %}
{% spaceless %}
{% set kilo = 1000 %}
{% set mega = kilo * 1000 %}
{% set giga = mega * 1000 %}
{% set tera = giga * 1000 %}
{% if input < kilo %}
{{ input ~ ' B' }}
{% elseif input < mega %}
@mort3za
mort3za / lighthouse.js
Created May 29, 2019 15:12
Run lighthouse programmatically for multiple pages
// yarn add --dev lighthouse cross-env
// in package.json:
// scripts: { "lighthouse-dev": "cross-env NODE_ENV=development node ./lighthouse.js",
// "lighthouse-prod": "cross-env NODE_ENV=production CHROME_FLAGS=--headless node ./lighthouse.js" }
const lighthouse = require('lighthouse')
const chromeLauncher = require('chrome-launcher')
const fs = require('fs')
const mode = process.env.NODE_ENV
const chromeFlags = '-headless'
{"lastUpload":"2021-08-11T08:01:24.621Z","extensionVersion":"v3.4.3"}
@mort3za
mort3za / twitter-api-description.md
Last active July 7, 2021 08:40
Summary of what I understood from Twitter API

There is two versions of Twitter API: 1.1 & 2

Version 2 is still in development and subjects to changes. It's better to use v1.1 for now.

There is two versions of OAuth: 1.0a and 2

Version 1.0a is for doing actions on behalf of authenticated user. It needs consumer keys and access tokens.
Version 2 is for doing actions directly from your application. It's suitable to work with public API of twitter, e.g. get a user details.

To work with Oauth v1.0a, there is a nice Node.js package: https://github.com/FeedHive/twitter-api-client/

@mort3za
mort3za / server.js
Created July 3, 2021 06:58 — forked from jeffrafter/server.js
Twitter OAuth with node-oauth for node.js+express
var express = require('express');
var sys = require('sys');
var oauth = require('oauth');
var app = express.createServer();
var _twitterConsumerKey = "YOURTWITTERCONSUMERKEY";
var _twitterConsumerSecret = "YOURTWITTERCONSUMERSECRET";
function consumer() {
[{"flag":"https://restcountries.eu/data/afg.svg","name":"Afghanistan","callingCodes":["93"]},{"flag":"https://restcountries.eu/data/ala.svg","name":"Åland Islands","callingCodes":["358"]},{"flag":"https://restcountries.eu/data/alb.svg","name":"Albania","callingCodes":["355"]},{"flag":"https://restcountries.eu/data/dza.svg","name":"Algeria","callingCodes":["213"]},{"flag":"https://restcountries.eu/data/asm.svg","name":"American Samoa","callingCodes":["1684"]},{"flag":"https://restcountries.eu/data/and.svg","name":"Andorra","callingCodes":["376"]},{"flag":"https://restcountries.eu/data/ago.svg","name":"Angola","callingCodes":["244"]},{"flag":"https://restcountries.eu/data/aia.svg","name":"Anguilla","callingCodes":["1264"]},{"flag":"https://restcountries.eu/data/ata.svg","name":"Antarctica","callingCodes":["672"]},{"flag":"https://restcountries.eu/data/atg.svg","name":"Antigua and Barbuda","callingCodes":["1268"]},{"flag":"https://restcountries.eu/data/arg.svg","name":"Argentina","callingCodes":["54"]},{"flag":"
@mort3za
mort3za / jquery-global.md
Last active December 14, 2020 07:14
Add jQuery to window object in Webpack 4
import jQuery from 'jquery'
window.jQuery = window.$ = window.jquery = jQuery
module: {
    rules: [
      {
 test: require.resolve('jquery'),
# Set permission of all files and folders. 755 and 644.
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
find ./app/cache -type d -exec chmod 777 {} \;
find ./app/logs -type d -exec chmod 777 {} \;
find ./web/upload -type d -exec chmod 777 {} \;
#find /opt/lampp/htdocs -type d -exec chmod 755 {} \;
#find /opt/lampp/htdocs -type f -exec chmod 644 {} \;
@mort3za
mort3za / sorinethotels-maryam-features.txt
Created October 8, 2017 15:57
ویژگی‌های اصلی هتل سورینت مریم
<div class="row">
<div class="large-4 column">
<h2 class="sec-title">ویژگی‌های اصلی هتل</h2>
</div>
<div class="large-20 column">
<dl class="row large-up-4">
<dd class="column"><i class="fa fa-wifi"></i>اینترنت وای‌فای</dd>
<dd class="column"><i class="fa fa-plane"></i>انتقال از فرودگاه</dd>
<dd class="column"><i class="fa fa-bell"></i>روم سرویس</dd>