Skip to content

Instantly share code, notes, and snippets.

View aaryan79831014's full-sized avatar

Ramasamy Solaiappan aaryan79831014

View GitHub Profile
@aaryan79831014
aaryan79831014 / clearForm.js
Created March 14, 2018 22:31
Clear all inputs jquery modal form when the form closes
$(document).ready(function () {
// clear all the inputs on the form on the modal id documentModal
$('#documentModal').on('hidden.bs.modal', function (e) {
$('input[type=radio]').prop('checked', false);
$('input[type=checkbox]').prop('checked', false);
$(this)
.find("input,textarea,select")
.val('')
.end()
});
@aaryan79831014
aaryan79831014 / ImageMagnifier
Last active March 26, 2018 19:54
Image Magnifier with single image
<html lang="en-US" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$( document ).ready(function() {
console.log( "ready!" );
var isMobile = window.matchMedia("only screen and (max-width: 760px)");
console.log("isMobile : " + isMobile.matches );
var px;
var py;
@aaryan79831014
aaryan79831014 / mobile_touchdevice.js
Created April 3, 2018 15:22
Check for TouchDevice and Mobile browsers js
var touchDevice = (navigator.maxTouchPoints || 'ontouchstart' in document.documentElement);
var isMobile = {
Android: function () {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function () {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function () {
@aaryan79831014
aaryan79831014 / OnlyNumbers.cs
Created April 12, 2018 18:14
Allow only numbers in view with jquery enabled
[RegularExpression("([1-9][0-9]*)", ErrorMessage = "Enter only numeric number")]
public int Amount { get; set; }
@aaryan79831014
aaryan79831014 / ObjectDumper.cs
Created April 25, 2018 22:32
Object Dumper extension using Newtonsoft Json Serializer
static class ObjectHelper
{
public static void Dump<T>(this T x)
{
string json = Newtonsoft.Json.JsonConvert.SerializeObject(x, Formatting.Indented);
Console.WriteLine(json);
}
}
@aaryan79831014
aaryan79831014 / StringExtensions.cs
Created June 4, 2018 20:46
Repeat extension for String
public static class StringExtensions
{
public static string Repeat(this string instr, int n)
{
var result = string.Empty;
for (var i = 0; i < n; i++)
result += instr;
return result;
@aaryan79831014
aaryan79831014 / iOS_iframe_responsive.html
Created September 14, 2018 23:59
fitting iframe content to the screen in iOS (Make the iframe responsive in iOS)
I needed a cross-browser solution. Requirements were:
needed to work on both iOS and elsewhere
don't have access to the content in the iFrame
need it to scroll!
Building off what I learned from @Idra regarding scrolling="no" on iOS and this post about fitting iFrame content to the screen in iOS here's what I ended up with. Hope it helps someone =)
HTML
<div id="url-wrapper"></div>
@aaryan79831014
aaryan79831014 / web.config.txt
Created November 4, 2018 19:08
Log4net debugging changes on web.config
<!--Following are the changes that has to be done in web.config for Log4net debugging (if you think the problem with Log4Net logging module itself)-->
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="log4net.Internal.Debug" value="true"/>
</appSettings>
</configuration>
And the following has to be added as well
@aaryan79831014
aaryan79831014 / episerver.txt
Created November 29, 2018 11:55
Useful links for Episerver
https://world.episerver.com/blogs/Alexander-Haneng/Dates/2012/7/How-to-define-properties-in-EPiServer-7---A-quick-reference/
@aaryan79831014
aaryan79831014 / HomeController.cs
Last active December 21, 2018 23:18
iTextSharp to print pdf
using iTextSharp.text;
using iTextSharp.text.html.simpleparser;
using iTextSharp.text.pdf;
using iTextSharp_PDF.Services;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Hosting;