Skip to content

Instantly share code, notes, and snippets.

Vlad GURDIGA gurdiga

Block or report user

Report or block gurdiga

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
gurdiga / getCookieByName.js
Last active Feb 25, 2016
A little function to get a cookie by name. Useful to debug from the the browser console.
View getCookieByName.js
function getCookieByName(name) {
return unescape(
(document.cookie.split(/; /g)||[])
.filter(function(pair) {
return pair.split('=')[0] === name;

Per-directory Bash history (w/o aliasing cd)

I use Bash’s PROMPT_COMMAND variable:

The value of the variable PROMPT_COMMAND is examined just before Bash prints each primary prompt. If PROMPT_COMMAND is set and has a non-null value, then the value is executed just as if it had been typed on the command line.

The source code should be pretty straight forward, but if not, please ask in the comments. Put this in your .bashrc or similar:

# per-directory Bash history
View JS interface composition with

JS interface composition with promises

Inspired by Mr. Robert C. Martin’s episodes on SOLID principles that I’ve watched lately, and by the idea of “programming to interfaces” I’ve tried to come up with a schema that would allow me to have the concerns separated, but still composable.

These are a few modules from an Angular project.

So, I have an AuthenticationService module that does user account house-keeping:

// app/authentication-service/authentication-service.js
(function() {
View random-password.js
function randomPassword(lenght) {
function random() {
return parseFloat('.' + crypto.getRandomValues(new Uint32Array(1))[0]);
var characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
password = '',
for (i = 0; i < 10; i++)
mencoder dvd:// -mc 0 -noskip -ovc copy -oac copy -nosub -aid 131 -o Desktop/transcoded.avi

Web server comparison experiment: threaded Ruby vs. Node.js

Since a few weeks I’m working on a Node.js project at my day work, and I kind of loved the idea of the event loop, and then, because I just got off a Rails project, was wondering why wouldn’t that be possible with Ruby?

Googled a couple of evenings to find how Node.js manages to serve multiple requests on the same thread, and how its IO works. Then did the same for Ruby, read a bit about GIL, and found that in the end, there is not that much of a difference between what you can get from a threaded Ruby server and Node.js.

Played a bit with hello worlds and ended up with similar results from the speed and concurency standpoint: max 2 concurent requests on my 2CPU laptop.

For Ruby I spawn a separated Thread for every request. And from what I could google, Node.js uses a thread pool to handle the IO and one single other to run JS, which is kind of similar as far as I can understand these things. Now, I’ve tried hello world Rails and Sinatra proj

gurdiga /
Created Oct 8, 2013
Grunt task to run jasmine-node without PhantomJS when you don’t need it.

Grunt task to run jasmine-node without PhantomJS

I’m working on a project where I write a webservice on Node.js and I find that grunt-contrib-jasmine is a bit slow to start. I couldn’t find amy module on npm that would do that, so I wrote my own task:

grunt.registerTask('jasmine', [], function() {
  var exec = require('child_process').exec,
      done = this.async();

  var child = exec('jasmine-node --matchall test', function(error, stdout, stderr) {
    if (error) grunt.warn(error);
gurdiga / Wikipedia.css
Created Oct 3, 2013
Personalized Web Options for Wikipedia
View Wikipedia.css
#mw-content-text {
width: 40em;
#toc {
float: right;
margin: 0 0 1em 1em;
gurdiga / Kindle Library.html
Created Sep 30, 2013
Personalized Web Options for Kindle Library to delete an item with a double click.
View Kindle Library.html
<script src="//"></script>
var q = jQuery.noConflict(true);
q(function($) {
$('table#orderList').on('dblclick', 'tr[id~="collapse"]', function() {
var $tr = $(this),
sessionId = document.cookie.split(';')
.map(function(item) { return item.split('=', 2).map(function(token) { return token.toString().trim(); }); })
.filter(function(pair) { return pair[0] == 'session-id'; })[0][1];
gurdiga /
Last active Mar 1, 2019
JS AES encryption example.

JS AES encryption example

This is a quick example of how to get symmetric encryption in JS using [aes.js from the crypto-js project][1]:

// at this point should be loaded

var data = 'a JSON blob or something',
    password = 'my long and very secretive passphrase';

var encrypted = CryptoJS.AES.encrypt(data, password).toString();
You can’t perform that action at this time.