Skip to content

Instantly share code, notes, and snippets.

var https = require('https'),
events = require('events');
const userAgent = 'GCLNodejs';
const version = 0.1;
const loginURL = '/accounts/ClientLogin';
const googleHost = 'www.google.com';
/**
* Helps to log in to any google service with the clientlogin method
#!/bin/sh
# Must be called with two command-line args.
# Example: git-svn-relocate.sh http://old.server https://new.server
if [ $# -ne 2 ]
then
echo "Please invoke this script with two command-line arguments (old and new SVN URLs)."
exit $E_NO_ARGS
fi
@Ajnasz
Ajnasz / bookmarklet.html
Created June 4, 2011 13:56
google +1 hup.hu article titles
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>A</title>
</head>
<body>
<a href="javascript:(function(){var doc=document,a=Array.prototype.slice.call(doc.querySelectorAll('h2.title a')).filter(function (a) {return a.href!==''&&a.parentNode.className!=='nnew';}),b=doc.createElement('span');a.forEach(function(l,i){var c=b.cloneNode(true),id='plusone'+i;c.id=id;a[i].parentNode.appendChild(c);gapi.plusone.render(id,{size:'small',count:true,href:l.href});});Array.prototype.slice.call(doc.querySelectorAll('.comment')).forEach(function(comment,i){var href=comment.previousSibling.previousSibling.id;if(href){var span=doc.createElement('span'),id='commentcount'+i;span.id=id;comment.querySelector('.submitted').appendChild(span);gapi.plusone.render(id,{href:doc.location.href+'#'+href,count:true,size:'small'});}});}());
">+1</a>
</body>
</html>
@Ajnasz
Ajnasz / require_these.js
Created June 6, 2011 08:03
Recursive require
/* override require for testing, comment it out */
var require = function (what, cb) {
console.log('request: ' + what.join(', '));
setTimeout(function () {
require.ready(cb);
}, 300);
};
require.ready = function (cb) {
cb();
};
(function () {
var a = ['lorem', 'ipsum', 'dolor'];
var repeat = true;
var i = 0;
var f = function () {
console.log(a[i]);
var finished = i + 1 >= a.length;
if (!finished || repeat) {
i = finished && repeat ? 0 : i + 1;
@Ajnasz
Ajnasz / cookies.js
Created July 25, 2011 14:59
cookies to object
var a= {};document.cookie.split(';').forEach(function(c){var b = c.split('=');a[b[0]]=b[1];});
@Ajnasz
Ajnasz / git-svn-commit-rev.sh
Created August 30, 2011 09:52
Get svn revision number from git svn log
git log --grep=... --format=format:%b | awk '/@/ {print gensub(/^.*@([0-9]+).*$/, "\\1", 1)}' | sort -n | tr '\n' ','
@Ajnasz
Ajnasz / pre-commit.jssyntax.sh
Created October 7, 2011 08:29
Precommit hook for git to check js syntax
#!/bin/sh
# Precommit hook to check js syntax
gitstatus=$(git st --short | awk '/^M.+js$/ {print $2}');
echo $gitstatus | while read i; do
if [ ! -z "$i" ]; then
echo "parse: $i";
output=$(js -e "parse(read('$i'))" 2>&1);
if [ ! -z "$output" ]; then
@Ajnasz
Ajnasz / jafov-demo.js
Created December 10, 2011 18:44
yafov example
$(document).ready(function () {
// add custom method
$.yafov.addMethod('[type="tel"]', 'telfoobar', function (value, element, cb) {
// imagine that this is an ajax call, and the function is the callback
setTimeout(function () {
var isValid = value !== '123';
cb(isValid);
}, 1000);
});
$.yafov.setMessage('telfoobar', 'value shouldn\'t be 123');
@Ajnasz
Ajnasz / foo.js
Created December 24, 2011 13:12
doctorjs bug example
var Foo = function () {};
exports.Foo = Foo;