Skip to content

Instantly share code, notes, and snippets.

View dpnishant's full-sized avatar
🎯
Focusing

Nishant Das Patnaik dpnishant

🎯
Focusing
View GitHub Profile
if (typeof YAHOO == "undefined" || !YAHOO) {
var YAHOO = {}
}
YAHOO.namespace = function () {
var A = arguments,
E = null,
C, B, D;
for (C = 0; C < A.length; C = C + 1) {
D = ("" + A[C])
.split(".");
@dpnishant
dpnishant / htmlEncode.js
Created September 20, 2013 11:45
htmlEncoder
function htmlEncode(str) {
var div = document.createElement('div');
div.appendChild(document.createTextNode(str));
return div.innerHTML.replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;").replace(/`/g,"&#x60;");
}
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/trunk/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/trunk/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
if(location.href.match(/^https:\/\//gi)) {
var DOM = document.head.innerHTML.toString() + document.body.innerHTML.toString();
var http_urls = DOM.match(/http:\/\/[^\"\'\s]*/gi);
if(http_urls) {
for(var i=http_urls.length-1;i>=0;i--) {
if (http_urls[i] !== 'http://') {
if (http_urls[i].slice(-3).match(/png|jpg|gif|css|\.js|swf|mp4|svg/gi))
document.write(http_urls[i] + '<br/><br/>');
}
}}}
@dpnishant
dpnishant / cframebusting.js
Created February 27, 2015 10:12
Conditional Framebusting
function matchInArray(arr, subject) {
var parser = document.createElement('a');
parser.href = subject; //using DOM-trickery to parse URLs
if(Object.prototype.toString.call(arr) !== '[object Array]') {
arr = arr.split(); //array typecast
}
if((new RegExp('\\b' + arr.join('\\b|\\b') + '\\b')).test(parser.hostname)) {
return true;
@dpnishant
dpnishant / classifier.py
Last active December 14, 2015 11:31 — forked from zacstewart/classifier.py
Document Classification with scikit-learn
import os
import numpy
from pandas import DataFrame
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB
from sklearn.pipeline import Pipeline
from sklearn.cross_validation import KFold
from sklearn.metrics import confusion_matrix, f1_score
NEWLINE = '\n'
@dpnishant
dpnishant / postMessage_security.md
Last active February 2, 2016 11:16 — forked from jedp/gist:3005816
postMessage() security review checklist

Security-Reviewing Uses of postMessage()

The postMessage() API is an HTML5 extension that permits string message-passing between frames that don't share the same origin. It is available in all modern browsers. It is not supported in IE6 and IE7.

postMessage is generally considered very secure as long as the programmer is careful to check the origin and source of an arriving

10a11,13
> apt-get install -y aptitude
> aptitude purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
> add-apt-repository ppa:ondrej/php
16,19c19,22
< apt-get install -y php5
< apt-get install -y php5-common
< apt-get install -y php5-curl
< apt-get install -y libapache2-mod-php5
---
var page = require('webpage').create();
var system = require('system');
page.onConsoleMessage = function(msg) {
system.stderr.writeLine('Console Message: ' + msg);
};
page.onInitialized = function() {
page.evaluate(function() {
document.addEventListener('DOMContentLoaded', function() {
@dpnishant
dpnishant / README.md
Created October 20, 2016 19:39 — forked from hofmannsven/README.md
My simply Git Cheatsheet