Skip to content

Instantly share code, notes, and snippets.

View motyar's full-sized avatar
🟢
I may be slow to respond.

Motyar motyar

🟢
I may be slow to respond.
View GitHub Profile
function typewriter(el,text,pos,no){
ctext=text.substring(0,pos)+(pos%2?'_':'<blink>_</blink>');
$(el).html(ctext);
if(pos==text.length){
$(el).html(text+"<blink>_</blink>");
}
else
window.setTimeout('typwriter("'+el+'","'+text+'",'+(pos+1)+','+1+');',800);
}
@motyar
motyar / Simplest AJAX
Created November 24, 2011 07:17
Simplest AJAX call with Raw JavaScript
window.onload = function(){
var xhr;
if(typeof XMLHttpRequest !== 'undefined') xhr = new XMLHttpRequest();
else {
var versions =["MSXML2.XmlHttp.5.0","MSXML2.XmlHttp.4.0","MSXML2.XmlHttp.3.0","MSXML2.XmlHttp.2.0","Microsoft.XmlHttp"];
for(var i = 0, len = versions.length; i < len; i++) {
try {
@motyar
motyar / json_template.html
Created December 15, 2011 09:13
Displaying JSON values with JavaScript : Basics of JSON Template with JavaScript
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Displaying JSON values with JavaScript : Basics of JSON Templating with JavaScript</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
article, aside, figure, footer, header, hgroup,
@motyar
motyar / fireFly
Created January 11, 2012 13:28
FireFly Effect on web
<!doctype html>
<head>
<style>
body{
background:black;
}
#header{
width:700px;
height:300px;
@motyar
motyar / .vimrc
Last active August 29, 2015 13:57
Auto start and stop ssh tunnel, for super fast remote editing with Vim
"{{{ Start and stop ssh tunnel, Fast remote editing idea via http://www.erikzaadi.com/2013/03/07/fast-remote-editing-with-vim/
function! StartSshTunnel(machine)
let shellcmd = "ssh ".a:machine." -f -N -o ControlMaster=auto -o ControlPath=/tmp/%r@%h:%p"
let tunnel=system(shellcmd)
endfunction
function! StopSshTunnel()
let kill = system("lsof -i -n | grep ssh | awk '{print $2}' | xargs kill -9")
endfunction
# Simple test for gist.io
This is second line
-------------------
I dont have much to write just now.
` try
code
sd `
@motyar
motyar / out.xml
Created August 4, 2014 06:12
out.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<books>
<course number="1">
<name>First course</name>
<page>1</page>
</course>
<course number="2">
<name>Getting started</name>
<page>2</page>
</course>
@motyar
motyar / parsexml.html
Last active November 3, 2019 03:57
Parsing XML data with AngularJS
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
<script type="text/javascript" src="https://raw.githubusercontent.com/abdmob/x2js/master/xml2json.min.js" charset="UTF-8"></script>
<meta charset="utf-8">
<title>Parsing XML in ajgularJS</title>
</head>
<body ng-app="todosApp">
<h2>Parsing XML data with AngularJS</h2>
@motyar
motyar / livestream
Created August 28, 2014 11:28 — forked from deandob/livestream
// Live video stream management for HTML5 video. Uses FFMPEG to connect to H.264 camera stream,
// Camera stream is remuxed to a MP4 stream for HTML5 video compatibility and segments are recorded for later playback
var liveStream = function (req, resp) { // handle each client request by instantiating a new FFMPEG instance
// For live streaming, create a fragmented MP4 file with empty moov (no seeking possible).
var reqUrl = url.parse(req.url, true)
var cameraName = typeof reqUrl.pathname === "string" ? reqUrl.pathname.substring(1) : undefined;
if (cameraName) {
try {
cameraName = decodeURIComponent(cameraName);
<h1>Alert</h1>
<p>Bootstrap JS</p>
<div class="alert fade in">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Holy guacamole!</strong> Best check yo self, you're not looking too good.
</div>
<p></p><a ng-click="alert=true">Open Alert (AngularJS)</a></p>
<div class="alert fade" ng-class="{in:alert}">
<button type="button" class="close" ng-click="alert=false">×</button>