Skip to content

Instantly share code, notes, and snippets.

@vishnuvp
vishnuvp / autoScroll.js
Last active August 29, 2015 14:02
Scroll to element on click on anchor
jQuery('a.menu-link').click(function(e){
e.preventDefault();
var href= jQuery(this).attr("href");
jQuery('html, body').animate({
scrollTop: jQuery(href).offset().top - 50}, 1000); });
@vishnuvp
vishnuvp / no-select.css
Created June 20, 2014 07:30
CSS to avoid selection of elements
.no-select {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
@vishnuvp
vishnuvp / migrate_user_d2d.php
Created June 27, 2014 08:48
Migrate new user accounts from Drupal 6 site to Drupal 7 site. Run this in devel php. Source: stackoverflow
<?php
require_once "./includes/password.inc";
//connect to Drupal 6 database
//syntax:mysqli(hostname,username,password,databasename);
$db= new mysqli('localhost','root','rootpwd','db');
if(mysqli_connect_errno()) {
echo "Conection error. Could not connect to Drupal 6 site!";
exit;
@vishnuvp
vishnuvp / bleichenbacherSimulatedAttack.py
Last active August 29, 2015 14:21
Practical padding oracle attack on RSA (http://secgroup.dais.unive.it/wp-content/uploads/2012/11/Practical-Padding-Oracle-Attacks-on-RSA.html) - Blaichenbacher Attack Simulation based on Chosen Ciphertext Attacks Against Protocols Based on the RSA Encryption Standard PKCS #1 by Daniel Bleichenbacher (http://archiv.infsec.ethz.ch/education/fs08/s…
#!/usr/bin/python
from subprocess import *
from binascii import *
import sys
import os
def sO(y):
rr = hexlify(unhexlify('%0256x' % y))
#print rr[0:4]
/*
For some reason, the change() event only fires when the input field loses focus.
Binding to other options ('change keypress paste focus textInput input') will
fire the event several times, which is bad. The below code works even when
content is pasted into the text field, and only fires once as expected.
*/
$('#search-form .term').bind('input', function(){
console.log('this actually works');
});
@vishnuvp
vishnuvp / crt.py
Created February 11, 2016 06:32
A simple python Chinese Reminder Theorem snippet to solve a system of congruences
def extendedEuclid(a,b):
#print 'extendedEuclid of ',a,b
if b==0:
return (a,1,0)
tuplPrime = extendedEuclid(b,a % b)
return [tuplPrime[0], tuplPrime[2], (tuplPrime[1] - (a//b)*tuplPrime[2])]
@vishnuvp
vishnuvp / DockerINSTALL
Last active January 17, 2017 07:13
Docker installation steps on Ubuntu16.04
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates
# Add new GPG key
sudo apt-key adv \
--keyserver hkp://ha.pool.sks-keyservers.net:80 \
--recv-keys 58118E89F3A912897C070ADBF76221572C52609D
# If the above keyserver is not available, try hkp://pgp.mit.edu:80 or hkp://keyserver.ubuntu.com:80.
@vishnuvp
vishnuvp / config-check.sh
Created February 7, 2017 05:45
Docker Config Check Script
#!/usr/bin/env bash
set -e
EXITCODE=0
# bits of this were adapted from lxc-checkconfig
# see also https://github.com/lxc/lxc/blob/lxc-1.0.2/src/lxc/lxc-checkconfig.in
possibleConfigs=(
'/proc/config.gz'
@vishnuvp
vishnuvp / config-check.sh
Created February 7, 2017 05:45
Docker Config Check Script
#!/usr/bin/env bash
set -e
EXITCODE=0
# bits of this were adapted from lxc-checkconfig
# see also https://github.com/lxc/lxc/blob/lxc-1.0.2/src/lxc/lxc-checkconfig.in
possibleConfigs=(
'/proc/config.gz'
{"EndpointGroups":[{"name":"Group1","Policies":[{"name":"Policy1","Rules":[{"name":"Rule1","protocol":"tcp","port":"22","direction":"out","ip-address":"0.0.0.0"}]}]}]}