Skip to content

Instantly share code, notes, and snippets.

View smali-kazmi's full-sized avatar
💭
trying to learn machine learning

Mudaser Ali smali-kazmi

💭
trying to learn machine learning
View GitHub Profile
# get total requests by status code
awk '{print $9}' /var/log/nginx/access.log | sort | uniq -c | sort -rn
# get top requesters by IP
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head | awk -v OFS='\t' '{"host " $2 | getline ip; print $0, ip}'
# get top requesters by user agent
awk -F'"' '{print $6}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head
# get top requests by URL
@smali-kazmi
smali-kazmi / number.js
Created August 18, 2020 16:47
Native JS Number Formatting
var number = 123456.789;
// German uses comma as decimal separator and period for thousands
console.log(number.toLocaleString('de-DE'));
// → 123.456,789
// Arabic in most Arabic speaking countries uses Eastern Arabic digits
console.log(number.toLocaleString('ar-EG'));
// → ١٢٣٤٥٦٫٧٨٩
/**
* @author SM@K <[email protected]>
*
* @format
* @flow strict-local
*/
import React, { Component } from 'react';
import { SafeAreaView, StyleSheet, View, Text, SectionList } from 'react-native';
@smali-kazmi
smali-kazmi / nginx.conf
Created August 28, 2019 22:03
Nginx + Node.js on mac
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@smali-kazmi
smali-kazmi / nginx.conf
Created August 28, 2019 22:03
Nginx + Node.js on mac
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@smali-kazmi
smali-kazmi / example.com
Created August 28, 2019 22:01
Nginx + Node.js on mac
upstream example.com {
server 127.0.0.1:3000;
keepalive 32;
}
server {
listen 80;
listen [::]:80;
server_name example.com;
access_log /usr/local/etc/nginx/logs/example.access.log;
@smali-kazmi
smali-kazmi / app.js
Last active August 28, 2019 22:00
Nginx + Node.js on mac osx
// content of app.js
const http = require('http')
const port = 3000
const requestHandler = (request, response) => {
console.log(request.url)
response.end('Hello Node.js Server!')
}
const server = http.createServer(requestHandler)
@smali-kazmi
smali-kazmi / Vagrantfile
Created March 24, 2016 03:24
Basic Demo Node.js Airport Api
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
@smali-kazmi
smali-kazmi / gist:1bb61a21a7d6551e319f
Last active January 20, 2017 11:01
Install squidman

Copy paste following template into your Squidman template

# ----------------------------------------------------------------------
# WARNING - do not edit this template unless you know what you are doing
# ----------------------------------------------------------------------

# the parent cache
cache_peer %PARENTPROXY% parent %PARENTPORT% 7 no-query no-digest no-netdb-exchange default
@smali-kazmi
smali-kazmi / gist:b6e8a59fa5a92290c1bc
Created September 15, 2014 17:45
Install Elasticsearch plugin (elasticsearch-river-jdbc) for Ubuntu on Vagrant
cd /usr/share/elasticsearch
sudo ./bin/plugin --install jdbc --url http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-river-jdbc/1.1.0.2/elasticsearch-river-jdbc-1.1.0.2-plugin.zip
sudo curl -o mysql-connector-java-5.1.28.zip -L 'http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.28.zip/from/http://cdn.mysql.com/'
sudo unzip mysql-connector-java-5.1.28.zip -d mysql-connector
sudo cp mysql-connector/mysql-connector-java-5.1.28/mysql-connector-java-5.1.28-bin.jar ./plugins/jdbc/
sudo /etc/init.d/elasticsearch restart
#Create new index using example commands on https://github.com/jprante/elasticsearch-river-jdbc