Skip to content

Instantly share code, notes, and snippets.

View jfromaniello's full-sized avatar
😀
coding

José F. Romaniello jfromaniello

😀
coding
View GitHub Profile
@jfromaniello
jfromaniello / bcompare-git.md
Last active April 5, 2024 21:53
Integrate beyond compare 4 with git

Install command line tools:

then run this:

git config --global diff.tool bc3
git config --global difftool.bc3 trustExitCode true
git config --global merge.tool bc3
@jfromaniello
jfromaniello / continous-qunit.ps1
Created August 4, 2011 14:22
The powershell continuously watch for file changes in a directory, then it executes PhantomJs with the Run-Qunit.js attached to your htm qunit test harness.
# watch a file changes in the current directory,
# execute all tests when a file is changed or renamed
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = get-location
$watcher.IncludeSubdirectories = $true
$watcher.EnableRaisingEvents = $false
$watcher.NotifyFilter = [System.IO.NotifyFilters]::LastWrite -bor [System.IO.NotifyFilters]::FileName
while($TRUE){
@jfromaniello
jfromaniello / gist:8418116
Last active September 19, 2023 23:38
Example of authenticating websockets with JWTs.
var WebSocketServer = require('ws').Server;
var wss = new WebSocketServer({port: 8080});
var jwt = require('jsonwebtoken');
/**
The way I like to work with 'ws' is to convert everything to an event if possible.
**/
function toEvent (message) {
try {
@jfromaniello
jfromaniello / gist:4087861
Last active February 6, 2022 03:53
socket-io.client send the cookies!
/*
* Little example of how to use ```socket-io.client``` and ```request``` from node.js
* to authenticate thru http, and send the cookies during the socket.io handshake.
*/
var io = require('socket.io-client');
var request = require('request');
/*
* This is the jar (like a cookie container) we will use always
if (!process.env.http_proxy) return;
var url = require('url');
var tunnel = require('tunnel');
var proxy = url.parse(process.env.http_proxy);
var tunnelingAgent = tunnel.httpsOverHttp({
proxy: {
host: proxy.hostname,
port: proxy.port
//lets say you want to find the property on the `resp` object
//that contains the url of the request
request.get('http://example.com/foo/bar', (err, resp, body) => {
console.dir(findMatchingProperty(resp, v => typeof v === 'string' && v.match(/\/foo\/bar/)));
});
/**
The result is:
@jfromaniello
jfromaniello / Users.js
Created September 12, 2013 13:21
Fetch all the groups a user is member of with ldapjs
var nconf = require('nconf');
var ldap = require('ldapjs');
var async = require('async');
ldap.Attribute.settings.guid_format = ldap.GUID_FORMAT_D;
var Users = module.exports = function(){
var options = this._options = {
url: process.env["LDAP_URL"],
base: process.env["LDAP_BASE"],
bindDN: process.env["LDAP_BIND_USER"],
var profiler = require('v8-profiler');
process.on('SIGUSR2', () => {
const snapshot = profiler.takeSnapshot();
const fileName = `/tmp/my-project-${Date.now()}.heapsnapshot`;
snapshot.export()
.pipe(fs.createWriteStream(fileName))
.on('finish', () => {
console.log(`snapshot ${fileName} has been stored`);
snapshot.delete();
@jfromaniello
jfromaniello / keybindings.json
Created March 7, 2018 18:08
my keybindings for vscode (similar to sublime)
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "ctrl+left",
"command": "subwordNavigation.cursorSubwordLeft",
"when": "editorTextFocus"
},
{
"key": "ctrl+right",
"command": "subwordNavigation.cursorSubwordRight",
@jfromaniello
jfromaniello / README.md
Created August 11, 2014 14:12
CoreOS template for CloudFormation with two EBS disks on /var/lib/docker

This is a fork from the original CoreOS cloud formation template. It adds two EBS disks of 30G, mounted to /var/lib/docker.

This is intended to be used with an m3.large machine which comes with 30G of SSD.

The reason I add two of 30 and not one of 60 is because a BTRFS limitation.

You can use the "btrfs add" approach in the units to create a BTRFS raid.