Skip to content

Instantly share code, notes, and snippets.

@afshinm
afshinm / gist:5023576
Created February 24, 2013 12:04
using PersianJs in ASP.NET web form
<script type="text/javascript" src="scripts/persian.js"></script>
<asp:TextBox ID="TextBox1" runat="server" Text = "" ForeColor = "Gray"></asp:TextBox>
<div id="output"></div>
<script type="text/javascript">
$("#<%=TextBox1.ClientID%>").keypress(function () {
if ($("#<%=TextBox1.ClientID%>").val() != "") {
console.log("key pressed");
$("#output").html(persianJs($("#<%=TextBox1.ClientID%>").val()).englishNumber());
}
});
function Array() {
var foo = this;
var bar = function() {
var ret = "Captured array items are: ";
//notify an attacker. Here we just display it
alert(ret);
};
setTimeout(bar, 100);
}
<script src="https://mail.google.com/mail/c/u/0/data/contactstore"></script>
@afshinm
afshinm / gist:4733756
Last active December 12, 2015 06:59 — forked from arashmilani/gist:4732488
function assertType(obj, type) {
return obj.constructor.name === type.name
}
Object.prototype.assertType = function(type) {
return this.constructor.name === type.name
}
//Preparing test, mock objects
function Book(){};
@afshinm
afshinm / jquery_find_children.js
Last active December 12, 2015 02:28
Example of jQuery `children` and `find` function
$('.box').find('p');
//or
$('.box').children('p');
@afshinm
afshinm / jquery_selector.js
Created February 2, 2013 19:00
An example of jQuery selector
$('.box p');
@afshinm
afshinm / motionjs_example.js
Created November 30, 2012 12:13
motionjs_example
motionjs.transition([{
select: "#hello_world",
duration: '4s',
style: {
top: '200px',
opacity: 1
},
end: function (event) {
alert("End of transition.");
}
@afshinm
afshinm / chat.client.js
Created October 21, 2012 19:01
Simple Chat Server with Socket.IO - Client Code
socket.on('connect', function () {
socket.on('message', function (data) {
var newElement = document.createElement('li');
newElement.innerHTML = data.message[0] + ' says: ' + data.message[1];
document.getElementById("list").appendChild(newElement);
});
socket.on('announcement', function (data) {
var newElement = document.createElement('li');
newElement.className = 'announcement';
@afshinm
afshinm / chat.server.js
Created October 20, 2012 18:41
Simple Chat Server with Socket.IO - Server Code
var buffer = [];
io.sockets.on('connection', function(client) {
client.emit('history', { buffer: buffer });
io.sockets.emit('announcement', client.id + ' connected');
client.on('message', function(message){
var msg = { message: [client.id, message] };
buffer.push(msg);
if (buffer.length > 15) buffer.shift();
io.sockets.emit('message', msg);