Skip to content

Instantly share code, notes, and snippets.

🖥
Working on better world

Amir Irani iraniamir

🖥
Working on better world
Block or report user

Report or block iraniamir

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@iraniamir
iraniamir / main.go
Created May 8, 2019
IPv4 to Mongo ObjectID
View main.go
package main
import (
"encoding/hex"
"fmt"
"strings"
"gopkg.in/mgo.v2/bson"
)
@iraniamir
iraniamir / main.go
Last active May 1, 2019
Instagram, show summary email address
View main.go
package main
import (
"fmt"
"strings"
)
func main() {
fmt.Print(hideEmailAddress("emailAddress@gmail.com"))
@iraniamir
iraniamir / form-validation.jsx
Created Oct 28, 2018
React html5 form validation
View form-validation.jsx
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { EMLINK } from 'constants';
export default class FormValidation extends Component {
static propTypes = {
children: PropTypes.node,
submit: PropTypes.func.isRequired
};
@iraniamir
iraniamir / server.js
Created Sep 16, 2018
CacheRestServer
View server.js
const express = require('express');
const axios = require('axios');
const cacheAdapter = require('axios-cache-adapter');
const app = express()
const port = 3210
const fetchCache = cacheAdapter.setup({
cache: {
maxAge: 15 * 60 * 1000
}
@iraniamir
iraniamir / index.html
Created Aug 21, 2018
Chunk upload file
View index.html
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Fanap Drive Upload</title>
</head>
<body>
View data.js
{
"hasError": false,
"referenceNumber": "207899",
"errorCode": 0,
"count": 0,
"ott": "ad341b80f845cd2e",
"result": {
"id": 132,
"hash": "M9XRVIRGBQEQW5BW",
"ownerId": 0,
View gist:542efea7984bbcb3ccc2315f1d36f46e
DirectoryIndex /application/index.html
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /application/index.html [L]
<IfModule mod_expires.c>
ExpiresActive Off
</IfModule>
@iraniamir
iraniamir / gist:58460372cf2e4c54fc7679a614b114cb
Created Jan 29, 2018
Block all countries except IRAN for linux servers in iptables with geoip
View gist:58460372cf2e4c54fc7679a614b114cb
iptables -A INPUT -m geoip --src-cc A1 -j DROP &&
iptables -A INPUT -m geoip --src-cc A2 -j DROP &&
iptables -A INPUT -m geoip --src-cc AD -j DROP &&
iptables -A INPUT -m geoip --src-cc AE -j DROP &&
iptables -A INPUT -m geoip --src-cc AF -j DROP &&
iptables -A INPUT -m geoip --src-cc AG -j DROP &&
iptables -A INPUT -m geoip --src-cc AI -j DROP &&
iptables -A INPUT -m geoip --src-cc AL -j DROP &&
iptables -A INPUT -m geoip --src-cc AM -j DROP &&
iptables -A INPUT -m geoip --src-cc AO -j DROP &&
@iraniamir
iraniamir / preview-form.jsx
Created Jan 28, 2018
Mithril Bootstrap Forms
View preview-form.jsx
import m from "mithril";
module.exports = (options, ...elements) => {
return (
<form {...options.attrs} class="form needs-validation">
{
elements.map(e => {
@iraniamir
iraniamir / preview-pagination.jsx
Created Jan 28, 2018
Mithril Bootstrap Pagination
View preview-pagination.jsx
import m from "mithril";
export default {
go(number) {
this.node.state[this.state] = number;
this.redraw();
},
eachPage(number, active = false) {
You can’t perform that action at this time.