Skip to content

Instantly share code, notes, and snippets.

View cyberinferno's full-sized avatar
🎯
Focusing

Karthik Panjaje cyberinferno

🎯
Focusing
View GitHub Profile
'use strict'
var express = require('express');
var app = express();
var mcache = require('memory-cache');
app.set('view engine', 'jade');
var cache = (duration) => {
return (req, res, next) => {
@cyberinferno
cyberinferno / port_checker.js
Created December 18, 2019 10:38
Checking if remote port is open using NodeJS
var net = require('net');
var Promise = require('bluebird');
function checkConnection(host, port, timeout) {
return new Promise(function(resolve, reject) {
timeout = timeout || 10000; // default of 10 seconds
var timer = setTimeout(function() {
reject("timeout");
socket.end();
}, timeout);
@cyberinferno
cyberinferno / show_indices.sql
Created August 14, 2019 08:37
Show all indices available in your Postgresql database currently
select
n.nspname as "Schema"
,t.relname as "Table"
,c.relname as "Index"
from
pg_catalog.pg_class c
join pg_catalog.pg_namespace n on n.oid = c.relnamespace
join pg_catalog.pg_index i on i.indexrelid = c.oid
join pg_catalog.pg_class t on i.indrelid = t.oid
where
@cyberinferno
cyberinferno / Drama.cs
Created November 2, 2018 05:40
C# code to create a drama
using System;
using System.Collections.Generic;
class Drama
{
public string name;
public List<string> actors;
Drama(string name)
{
<?php
$dsn = 'mysql:host=localhost;port=3307;dbname=testdb';
$username = 'username';
$password = 'password';
$options = array();
$db = new PDO($dsn, $username, $password, $options);
$name = $_GET['name'];
@cyberinferno
cyberinferno / all_table_row_count.sql
Created October 25, 2017 14:22
Get no of rows in all the tables in a MSSQL database
SELECT sc.name +'.'+ ta.name TableName
,SUM(pa.rows) RowCnt
FROM sys.tables ta
INNER JOIN sys.partitions pa
ON pa.OBJECT_ID = ta.OBJECT_ID
INNER JOIN sys.schemas sc
ON ta.schema_id = sc.schema_id
WHERE ta.is_ms_shipped = 0 AND pa.index_id IN (1,0)
GROUP BY sc.name,ta.name
ORDER BY SUM(pa.rows) DESC
@cyberinferno
cyberinferno / nginx.conf
Created August 12, 2017 08:56
Nginx S3 cache proxy config
http {
gzip off;
# need to setup external DNS resolver
resolver 8.8.8.8;
resolver_timeout 5s;
# configure cache directory with 750G and holding old objects for max 30 days
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=default:500m max_size=750g inactive=30d;
@cyberinferno
cyberinferno / gist:20b4a89d7e6d06541348a64837a18551
Created August 12, 2017 07:26 — forked from mikhailov/gist:9639593
Nginx S3 Proxy with caching
events {
worker_connections 1024;
}
http {
default_type text/html;
access_log /dev/stdout;
sendfile on;
keepalive_timeout 65;
@cyberinferno
cyberinferno / gw2-bot.au3
Created April 25, 2017 10:37
Guild Wars 2 AutoIt Pixel Bot
; AutoIt Version: 3.0
; Language: English
; Platform: Win9x/NT
; Author: ESB
#Region Include
#include <Math.au3>
#include <ButtonConstants.au3>
@cyberinferno
cyberinferno / ldap.php
Created July 21, 2016 14:51
Basic LDAP login using PHP
<?php
if(isset($_POST['username']) && isset($_POST['password'])){
$adServer = "ldap://domaincontroller.mydomain.com";
$ldap = ldap_connect($adServer);
$username = $_POST['username'];
$password = $_POST['password'];
$ldaprdn = 'mydomain' . "\\" . $username;