Skip to content

Instantly share code, notes, and snippets.

@sposmen
sposmen / img_url_select.sql
Created August 20, 2013 21:48
Select from an XML the img src
select id, url from
(
select id, array_to_string(regexp_matches(possible, 'src=[\s\\]*"(https?:\/\/.*)"', 'g'), ',') as url
from (
select id, array_to_string(regexp_matches(xml::text , '(<img .*?>)', 'g'), ',') as possible from victorious_squirrel_widgets
where xml::text ~ '(<img .*?>)'
) as foo
) as foo2
where url not like '%URL_NOT_NEEDED%'
order by id
@sposmen
sposmen / kinesis-2013-11-04.js
Last active December 29, 2015 10:29 — forked from chrishamant/kinesis-2013-11-04.js
DEPRECATED - Actually AWS-SDK-JS has kinesis support

Its relatively easy to stub in support for new services using their sdks. I have an application I'm trying this service out with and have stubbed rudimentary support for this service.

Just fetch this library locally, install the deps and npm link it.

  • copy kinesis-2013-11-04.js to lib/services/api/kinesis-2013-11-04.js
  • copy kinesis.js to lib/services/kinesis.js
  • you'll also need to add the line 'require('./services/kinesis');' to lib/services.js Since this is a json based api this pretty much works how I want it - only nag is I have to manually base64 encode/decode a Buffer for the 'Data' field of 'putRecord'

The service definition is really woefully incomplete with only input parameters specified for 'createStream','describeStream','getNextRecords','getShardIterator','listStreams' and 'putRecord' - you'll have to add the parameters for the other operations yourself if needed. I didn't waste too much time doing this cause I'm pretty sure this stuff just gets automagically generated from a service defin

To make a full hard disk image in linux we will use several small programs and a livecd.

Next to this we need a place to store the image (external hard disk?). Which livecd you use is not that important. Just make sure that you access the place where you want to store the image and that you have access to gzip, dd and swapoff (if there is a swap partition).

So let us see the steps to take:

  1. Boot into the livecd
  2. Make sure you can access the place where you want to store the image
  3. (1) Disable the swap partition on the hard disk you want to image
  4. (2) Start the image-making process

Two Different Repositories (USB or Different Path)

  1. Create (option --no-hardlinks)

    mkdir /path/to/repository.git git clone --local --bare [--no-hardlinks] . /path/to/repository.git

  2. Initial Data From branchname(could be master)

@sposmen
sposmen / README.md
Created April 14, 2014 15:02
How to create a new repository from an specific branch

How to create a new repository from an specific branch

ORIGINAL: Original repository directory

NEW_REPO: New reposotory directory

OLD_BRANCH: Branch which you want to be the master on NEW_REPO

  1. Clone ORIGNAL from branch that you want to clone
@sposmen
sposmen / browser_helper.js
Last active August 29, 2015 13:59 — forked from todoubled/spec_helper.coffee
Emulate browser inside nodejs
var window;
if (typeof window === "undefined" || window === null) {
window = {};
}
if (typeof jQuery === "undefined" || jQuery === null) {
global.$ = require('jquery');
}
java 1.7.0_55
hadoop 2.4.0
hive 0.11
postgres 9.3
@sposmen
sposmen / completeToLength.js
Last active August 29, 2015 14:01
Complete a string (number) to the specified length. Useful when you needs a formatted number as '00000123'
/**
* Generates a string length of a specific character
* @param char Character to repeat
* @param times How many times
* @returns {string}
*/
String.prototype.repeat= function(n){
n= n || 1;
return Array(n+1).join(this);
}
// Connect to origin db
use some_database; // This will be named db
// Connecto to destiny db2
db2 = db.getSiblingDB('some_other_db');
// Only if needed clean destiny collection
db2.some_or_other_collection.remove({});
// Search all origin collection and copy each to destiny collection
'use strict';
var urlLib = require('url');
function UrlAdapter(urlString) {
this.urlObj = urlLib.parse(urlString, true);
// XXX remove the search property to force format() to use the query object when transforming the url object to a string
delete this.urlObj.search;
}
UrlAdapter.prototype.parse = urlLib.parse;