Skip to content

Instantly share code, notes, and snippets.

@subudeepak
subudeepak / angular-loadscript-with-documentwrite.js
Last active September 9, 2024 04:25 — forked from endorama/angular-loadscript.js
Loading scripts on ngInclude (ng route) - Script loading directive
/**
* This module is a variant which supports document.write. If you need document.write use this instead
* Author: Deepak Subramanian @subudeepak(https://github.com/subudeepak)
* Distributed under MIT License
*/
/*global angular */
(function (ng) {
'use strict';
app.directive('script', function() {
return {
@subudeepak
subudeepak / angular-prettyprint.js
Last active May 16, 2017 09:56
Angular Prettyprint with linenums
function replaceText(str)
{
var str1 = String(str);
return str1.replace(/\n/g,"<br/>");
}
app.directive('prettyprint', function() {
return {
restrict: 'C',
link: function postLink(scope, element, attrs) {
@subudeepak
subudeepak / nganimate.css
Created March 21, 2014 14:53
My nganimate for ngview
.view-animate {
padding:10px;
}
.view-animate.ng-enter, .view-animate.ng-leave {
-webkit-transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
-moz-transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
-ms-transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
-o-transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
@subudeepak
subudeepak / WebSockets.md
Last active May 31, 2024 09:36
The problems and some security implications of websockets - Cross-site WebSockets Scripting (XSWS)

WebSockets - An Introduction

WebSockets is a modern HTML5 standard which makes communication between client and server a lot more simpler than ever. We are all familiar with the technology of sockets. Sockets have been fundamental to network communication for a long time but usually the communication over the browser has been restricted. The general restrictions

  • The server used to have a permanent listener while the client (aka browser) was not designated any fixed listener for a more long term connection. Hence, every communication was restricted to the client demanding and the server responding.
  • This meant that unless the client requested for a particular resource, the server was unable to push such a resource to the client.
  • This was detrimental since the client is then forced to check with the server at regular intervals. This meant a lot of libraries focused on optimizing asynchronous calls and identifying the response of asynchronous calls. Notably t
@subudeepak
subudeepak / ClickSimulation.md
Last active August 29, 2015 14:02
The functionality exists but only native implementation seem to be able to use it

The button click in JavaScript

I have always wondered why the button click could be simulated using the document.element.click() event. I mean if only we could ensure that any click event that originates must be a click event because of user interaction, it would make life just a step better right ! So many form submits under malicious circumstances could be avoided. [For the technically informed: Of course there are workarounds that need other mechanisms in place]. A sample code of how this can be done is here

So this week I was working on the HTML5's full screen API. I am not a major audio/visual person so I have not had the pleasure of exploring this API before. I was planning on hosting a presentation online. Like many of us I chose to use JS to write this 'modern' presentation. In my computer, I generally use the presentation mode of chromium thereby making it a good solution without the need to use the terrible api of HTML5. It is not terrible because of the spec

@subudeepak
subudeepak / eqFullLengthLatex.md
Last active March 16, 2023 16:01
Latex - Long Equation in a 2 column environment

What is this

In latex there is a problem with adding long equations to a paper. Suggestions like converting the equation to a figure first are more troublesome than any help. The physics journals have already implemented something called widetext and this is quite useful. That being said, this is a very simple feature. It exists, though guides are not quite useful.

Instructions are below ..

Packages to add

\usepackage{cuted}
\usepackage{flushend}